from progressbar import ProgressBar from usbmux import usbmux from util import hexdump, sizeof_fmt import datetime import hashlib import struct import os CMD_DUMP = 0 CMD_PROXY = 1 kIOFlashStorageOptionRawPageIO = 0x002 kIOFlashStorageOptionBootPageIO = 0x100 class IOFlashStorageKitClient(object): def __init__(self, udid=None, host="localhost", port=2000): self.host = host self.port = port self.connect(udid) def connect(self, udid=None): mux = usbmux.USBMux() mux.process(1.0) if not mux.devices: print "Waiting for iOS device" while not mux.devices: mux.process(1.0) if not mux.devices: print "No device found" return dev = mux.devices[0] try: self.s = mux.connect(dev, self.port) except: raise Exception("Connexion to device %s port %d failed" % (dev.serial, self.port)) def send_command(self, cmd): return self.s.send(struct.pack("