Git Product home page Git Product logo

pymobiledevice's Introduction

pymobiledevice

License

pymobiledevice is a cross-platform implementation of the mobiledevice library that talks the protocols to support iPhone®, iPod Touch®, iPad® and Apple TV® devices.

Requirements

  • Python 2.7 and 3.x
  • M2Crypto
  • construct >= 2.9.29
  • pyasn1
  • future
  • six
  • biplist
  • usbmuxd must be installed and running

Lockdownd.py [com.apple.lockownd]

This script can be used in order to pair with the device & starts other services.

Other services can only be accessed after successful pairing. Succesful pairing requires the device to be unlocked and the user to click "Trust this device" on their phone screen.

afc.py [com.apple.afc]

This service is responsible for things such as copying music and photos. AFC Clients like iTunes are allowed accessing to a “jailed” or limited area of the device filesystem. Actually, AFC clients can only access certain files, namely those located in the Media folder.

house_arrest.py [com.apple.mobile.house_arrest]

This service allows accessing to AppStore applications folders and their content. In other words, by using an AFC client, a user/attacker can download the application resources and data. It also includes the “default preferences” file where credentials are sometimes stored.

installation_proxy.py [com.apple.mobile.installation_proxy]

The installation proxy manages applications on a device. It allows execution of the following commands:

  • List installed applications
  • List archived applications
  • ...

mobilebackup.py & mobilebackup2.py [ com.apple.mobilebackup & com.apple.mobilebackup2 ]

Those services are used by iTunes to backup the device.

diagnostics_relay.py [com.apple.mobile.diagnostics_relay]

The diagnostic relay allows requesting iOS diagnostic information. The service handles the following actions:

  • [ Sleep ]Puts the device into deep sleep mode and disconnects from host.
  • [ Restart ] Restart the device and optionally show a user notification.
  • [ Shutdown ] Shutdown of the device and optionally show a user notification.
  • [ NAND, IORegistry, GasGauge, MobileGestalt ] Querry diagnostic informations.
  • ...

filerelay.py [com.apple.mobile.file_relay]

Depending of the iOS version, the file relay service may support the following commands: Accounts, AddressBook, AppleSupport, AppleTV, Baseband, Bluetooth, CrashReporter, CLTM Caches, CoreLocation, DataAccess, DataMigrator, demod, Device-o-Matic, EmbeddedSocial, FindMyiPhone GameKitLogs, itunesstored, IORegUSBDevice, HFSMeta, Keyboard, Lockdown, MapsLogs, MobileAsset, MobileBackup, MobileCal, MobileDelete, MobileInstallation, MobileMusicPlayer, MobileNotes, NANDDebugInfo Network, Photos, SafeHarbor, SystemConfiguration, tmp, Ubiquity, UserDatabases, VARFS, VPN, Voicemail WiFi, WirelessAutomation.

All the files returned by the iPhone are stored in clear text in a gziped CPIO archive.

pcapd.py [com.apple.pcapd]

Starting iOS 5, apple added a remote virtual interface (RVI) facility that allows mirroring networks trafic from an iOS device. On Mac OSX the virtual interface can be enabled with the rvictl command. This script allows to use this service on other systems.

How to contribute

Contributors are essential to pymobiledevice (as they are to most open source projects). Drop us a line if you want to contribute. We also accept pull request.

Reporting issues

Questions

It is OK so submit issues to ask questions (more than OK, encouraged). There is a label "question" that you can use for that.

Bugs

If you have installed pymobiledevice through a package manager (from your Linux or BSD system, from PyPI, etc.), please get and install the current development code, and check that the bug still exists before submitting an issue.

Please label your issues "bug".

If you're not sure whether a behavior is a bug or not, submit an issue and ask, don't be shy!

Enhancements / feature requests If you want a feature in pymobiledevice, but cannot implement it yourself or want some hints on how to do that, open an issue with label "enhancement".

Explain if possible the API you would like to have (e.g., give examples of function calls, etc.).

pymobiledevice's People

Contributors

gotohack avatar guyingzhao avatar jerryginger avatar qtateam avatar tech234a avatar v1k1nghawk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pymobiledevice's Issues

[bug] [util/cpio.py] invalid literal for int() with base 8: '', during file_relay extract

Opening ticket for the following issue. Certain files are extracted but not all.

[master][~/Documents/pentest/mobile/pymobiledevice]$ ./file_relay.py -e ./extracts
Connecting to device:
Using iTunes pair record: .plist
Connecting to device:
Connecting to device:
Downloading sources ['Baseband', 'CrashReporter', 'Caches', 'MobileAsset', 'HFSMeta', 'Lockdown', 'MobileBackup', 'MobileDelete', 'MobileInstallation', 'MobileNotes', 'Network', 'UserDatabases', 'WiFi', 'WirelessAutomation', 'NANDDebugInfo', 'SystemConfiguration', 'Ubiquity', 'tmp']
{'Status': 'Acknowledged'}
Data saved to: /Users//Documents/pentest/mobile/pymobiledevice/fileRelay_dump_9L6dcv.dmp
[+] Extracting files from CPIO archive
Traceback (most recent call last):
File "./file_relay.py", line 122, in
cpio.extract_files(files=None,outpath=options.extractpath)
File "/Users//Documents/pentest/mobile/pymobiledevice/util/cpio.py", line 89, in extract_files
hdr = int(self.ifile.read(6),8)
ValueError: invalid literal for int() with base 8: ''

from pymobiledevice import screenshotr will raise traceback

Python 2.7.11 (default, Mar 12 2016, 09:16:51) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from pymobiledevice import screenshotr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/site-packages/pymobiledevice/screenshotr.py", line 26, in <module>
    from pymobiledevice.lockdown import LockdownClient
  File "/usr/local/lib/python2.7/site-packages/pymobiledevice/lockdown.py", line 31, in <module>
    from ak_vendor.usbmux import default_mux as mux
  File "/usr/local/lib/python2.7/site-packages/ak_vendor/usbmux.py", line 279, in <module>
    default_mux = USBMux()
  File "/usr/local/lib/python2.7/site-packages/ak_vendor/usbmux.py", line 266, in __init__
    self.listener.listen()
  File "/usr/local/lib/python2.7/site-packages/ak_vendor/usbmux.py", line 224, in listen
    ret = self._exchange(self.proto.TYPE_LISTEN)
  File "/usr/local/lib/python2.7/site-packages/ak_vendor/usbmux.py", line 216, in _exchange
    self.proto.sendpacket(req, mytag, payload)
  File "/usr/local/lib/python2.7/site-packages/ak_vendor/usbmux.py", line 165, in sendpacket
    self, self.TYPE_PLIST, tag, plistlib.writePlistToBytes(payload))
AttributeError: 'module' object has no attribute 'writePlistToBytes'

pydeviceinfo error

This is really great work! after successfully installed, I type pydeviceinfo, pylockdown...etc. when I type in pydeviceinfo, I got following:
pydeviceinfo
Traceback (most recent call last):
File "/usr/local/bin/pydeviceinfo", line 33, in
sys.exit(load_entry_point('pymobiledevice==1.3.0', 'console_scripts', 'pydeviceinfo')())
File "/usr/local/bin/pydeviceinfo", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/local/lib/python3.9/importlib/metadata.py", line 77, in load
module = import_module(match.group('module'))
File "/usr/local/lib/python3.9/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1030, in _gcd_import
File "", line 1007, in _find_and_load
File "", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'pymobiledevice.ideviceinfo'

Can I know what am I missing? Thanks

Issue backing up with iTunes after backup with pymobiledevice

iTunes refuses to backup my devices after performing a backup with pymobiledevice

Code used for backup:

backup_object = MobileBackup2(udid=sn, logger=self.logging, backupPath=self.output)
backup_object.backup()

Error message is:
Capture

Backup with pymobiledevice seems to complete successfully in my target directory
Devices are iPhone XS and iPhone X both on iOS 12

Building on Windows with Python27

any ideas?

C:\CODE\pymobiledevice-master>C:\Python27\python setup.py build
running build
running build_py
file pymobiledevice.py (for module pymobiledevice) not found
file pymobiledevice.py (for module pymobiledevice) not found

License violating derivative project

The pymobiledevice3 project appears to violate the license provided by this project. See doronz88/pymobiledevice3#972

Could you please assert confirmation of notice of breaking the license within that issue so that the clause in GPL 3.0 requiring Copyright notice to be present and remain takes effect and 30 days is granted to correct the issue?

lockdown can not start services(for iOS 8)

By using afc.py(iOS 8), I got the error.
Connecting to device: xxx
Using iTunes pair record: xxx.plist
StartService: None
ERROR
Traceback (most recent call last):
File "afc.py", line 525, in
AFCShell().cmdloop("Hello iPhone!")
File "afc.py", line 368, in init
self.afc = AFCClient(self.lockdown, "com.apple.afc")
File "afc.py", line 138, in init
self.service = self.lockdown.startService(serviceName)
File "/Users/spring/Documents/git/pymobiledevice/lockdown.py", line 242, in startService
if StartService.get("Error"):
AttributeError: 'NoneType' object has no attribute 'get'

I debugged it deeply, and got the error from lockdown.py, startService
StartService = self.c.recvPlist()

the return value of StartService is None. I do not know why it returns None.

For iOS 7, there is no such error.

Thank you.

License file does not match README

Readme has an icon of GPL >= 2 while LICENSE Is GPL3

Since GPL3 requires anything that links to this module also be GPL 3, please either set the LICENSE to GPL2 if that was what was intended or use LGPL3 if it was not intended that works using this module also be GPL

R

Already paired device fails to vailidate_pair

I am running usbmuxd from libimobiledevice proper. I have paired the device using idevicepair.

It seems that this line in lockdown.py:

    self.udid = self.allValues.get("UniqueDeviceID").replace('-','')

if breaking compatibility with that library as libimobiledevice stores the filename with the - in it. Removing .replace('-','') restored compatibility

Faild to start plists_service (iPhoneX or newer)

I have used the code to build a project to transfer the files to iPhone from Windows.It works on the iPhone 8 or any older one .But it faild on iPhoneX or any newer one.
hope for any help
thank you!

Install m2crypto failed in Windows 10 with Python 3.7

Try to install the requirements:

pip install -r requirements.txt

Get the following error:

...
  _m2crypto_wrap.c
  SWIG/_m2crypto_wrap.c(3561): fatal error C1083: Cannot open include file: 'openssl/err.h': No such file or directory
  error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.24.28314\\bin\\HostX86\\x64\\cl.exe' failed with exit status
 2
...
```
Any hint?

Please provide basic instructions on how to use

For example, how to transfer the call history database from the iPhone to computer.
How to list files inside the iPhone.
How to install an app into the iPhone.
How to transfer any file to an iPhone app, as iTunes does.
How to list and get photos from the iPhone to computer.
How to install photos into the iPhone Photos app.
How to get or install music into the iPhone Music app.

These are just examples. Any documentation will help.

Support for Simulators

Since socket is transferred via USB to device, it seems possible to support similar access to simulators without a lot of work. (Unless the protocol is a bit different.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.