def create_info_plist(self): root_node = self.lockdown.getValue() info = { "BuildVersion": root_node["BuildVersion"], "DeviceName": root_node["DeviceName"], "Display Name": root_node["DeviceName"], "GUID": "---", "ProductType": root_node["ProductType"], "ProductVersion": root_node["ProductVersion"], "Serial Number": root_node["SerialNumber"], "Unique Identifier": self.udid.upper(), "Target Identifier": self.udid, "Target Type": "Device", "iTunes Version": "10.0.1" } if root_node.has_key("IntegratedCircuitCardIdentity"): info["ICCID"] = root_node["IntegratedCircuitCardIdentity"] if root_node.has_key("InternationalMobileEquipmentIdentity"): info["IMEI"] = root_node["InternationalMobileEquipmentIdentity"] info["Last Backup Date"] = datetime.datetime.now() iTunesFiles = [ "ApertureAlbumPrefs", "IC-Info.sidb", "IC-Info.sidv", "PhotosFolderAlbums", "PhotosFolderName", "PhotosFolderPrefs", "iPhotoAlbumPrefs", "iTunesApplicationIDs", "iTunesPrefs", "iTunesPrefs.plist" ] afc = AFCClient(self.lockdown) iTunesFilesDict = {} iTunesFiles = afc.read_directory("/iTunes_Control/iTunes/") #print iTunesFiles for i in iTunesFiles: data = afc.get_file_contents("/iTunes_Control/iTunes/" + i) if data: iTunesFilesDict[i] = plistlib.Data(data) info["iTunesFiles"] = iTunesFilesDict iBooksData2 = afc.get_file_contents("/Books/iBooksData2.plist") if iBooksData2: info["iBooks Data 2"] = plistlib.Data(iBooksData2) #pprint(info) print self.lockdown.getValue("com.apple.iTunes") info["iTunes Settings"] = self.lockdown.getValue("com.apple.iTunes") #self.backupPath = self.udid #if not os.path.isdir(self.backupPath): # os.makedirs(self.backupPath) #print info #raw_input() print "Creating %s" % os.path.join(self.udid, "Info.plist") self.write_file(os.path.join(self.udid, "Info.plist"), plistlib.writePlistToString(info))
def install_or_upgrade(self, ipaPath, cmd="Install", options=None, handler=None, *args): afc = AFCClient(self.lockdown) afc.set_file_contents("/" + os.path.basename(ipaPath), open(ipaPath, "rb").read()) cmd = {"Command": cmd, "PackagePath": os.path.basename(ipaPath)} if options: cmd.update(options) self.service.sendPlist(cmd) # print "%s : " % (cmd, bundleID) print "%s : %s\n" % (cmd, self.watch_completion(handler, args))
def house_arrest(lockdown, applicationId): try: mis = lockdown.startService("com.apple.mobile.house_arrest") except: lockdown = LockdownClient() mis = lockdown.startService("com.apple.mobile.house_arrest") if mis == None: return mis.sendPlist({"Command": "VendDocuments", "Identifier": applicationId}) res = mis.recvPlist() if res.get("Error"): print "Unable to Lookup the selected application: You probably trying to access to a system app..." return None return AFCClient(lockdown, service=mis)
def house_arrest(lockdown, applicationId): try: mis = lockdown.startService("com.apple.mobile.house_arrest") except: lockdown = LockdownClient() mis = lockdown.startService("com.apple.mobile.house_arrest") if mis == None: return mis.sendPlist({"Command": "VendDocuments", "Identifier": applicationId}) res = mis.recvPlist() error = res.get("Error") if error: print res["Error"] return None return AFCClient(lockdown, service=mis)
def mobile_install(lockdown,ipaPath): #Start afc service & upload ipa afc = AFCClient(lockdown) afc.set_file_contents("/" + os.path.basename(ipaPath), open(ipaPath,'rb').read()) mci = lockdown.startService("com.apple.mobile.installation_proxy") #print mci.sendPlist({"Command":"Archive","ApplicationIdentifier": "com.joystickgenerals.STActionPig"}) mci.sendPlist({"Command":"Install", #"ApplicationIdentifier": "com.gotohack.JBChecker", "PackagePath": os.path.basename(ipaPath)}) while True: z = mci.recvPlist() if not z: break completion = z.get('PercentComplete') if completion: print 'Installing, %s: %s %% Complete' % (ipaPath, z['PercentComplete']) if z.get('Status') == 'Complete': print "Installation %s\n" % z['Status'] break
def install_ipa(self, ipaPath): #Start afc service & upload ipa filename = os.path.basename(ipaPath) with AFCFile(name='/' + filename, mode='wb', afc=AFCClient(self.lockdown)) as f: f.write(open(ipaPath, 'rb').read()) self.service.sendPlist({'Command': 'Install', 'PackagePath': filename}) while True: response = self.service.recvPlist() if not response: break completion = response.get('PercentComplete') if completion: print 'Installing, %s: %s %% Complete' % (ipaPath, completion) status = response.get('Status') if status == 'Complete': print 'Installation %s' % status break
def create_info_plist(self): root_node = self.lockdown.allValues #print pprint(root_node) info = { "BuildVersion": root_node.get("BuildVersion") or "", "DeviceName": root_node.get("DeviceName") or "", "Display Name": root_node.get("DeviceName") or "", "GUID": "---", "ProductType": root_node.get("ProductType") or "", "ProductVersion": root_node.get("ProductVersion") or "", "Serial Number": root_node.get("SerialNumber") or "", "Unique Identifier": self.udid.upper(), "Target Identifier": self.udid, "Target Type": "Device", "iTunes Version": "10.0.1" } info["ICCID"] = root_node.get("IntegratedCircuitCardIdentity") or "" info["IMEI"] = root_node.get( "InternationalMobileEquipmentIdentity") or "" info["Last Backup Date"] = datetime.datetime.now() afc = AFCClient(self.lockdown) iTunesFilesDict = {} iTunesFiles = afc.read_directory("/iTunes_Control/iTunes/") for i in iTunesFiles: data = afc.get_file_contents("/iTunes_Control/iTunes/" + i) if data: iTunesFilesDict[i] = plistlib.Data(data) info["iTunesFiles"] = iTunesFilesDict iBooksData2 = afc.get_file_contents("/Books/iBooksData2.plist") if iBooksData2: info["iBooks Data 2"] = plistlib.Data(iBooksData2) info["iTunes Settings"] = self.lockdown.getValue("com.apple.iTunes") print "Creating %s" % os.path.join(self.udid, "Info.plist") self.write_file(os.path.join(self.udid, "Info.plist"), plistlib.writePlistToString(info))