本文整理汇总了Python中lockdown.LockdownClient类的典型用法代码示例。如果您正苦于以下问题:Python LockdownClient类的具体用法?Python LockdownClient怎么用?Python LockdownClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LockdownClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, lockdown = None,backupPath = None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
try:
self.udid = lockdown.getValue("", "UniqueDeviceID")#lockdown.udid
except:
self.lockdown = LockdownClient()
self.udid = self.lockdown.getValue("", "UniqueDeviceID")
self.service = self.lockdown.startService("com.apple.mobilebackup2")
if not self.service:
raise Exception("MobileBackup2Client init error : Could not start com.apple.mobilebackup2")
if backupPath:
self.backupPath = backupPath
else:
self.backupPath = "backups" #self.udid
if not os.path.isdir(self.backupPath):
os.makedirs(self.backupPath,0o0755)
print "Starting new com.apple.mobilebackup2 service with working dir: %s" % self.backupPath
self.password = ""
DLMessageVersionExchange = self.service.recvPlist()
#print DLMessageVersionExchange
version_major = DLMessageVersionExchange[1]
self.service.sendPlist(["DLMessageVersionExchange", "DLVersionsOk", version_major])
DLMessageDeviceReady = self.service.recvPlist()
#print DLMessageDeviceReady
if DLMessageDeviceReady and DLMessageDeviceReady[0] == "DLMessageDeviceReady":
#print "Got DLMessageDeviceReady"
self.version_exchange()
else:
raise Exception("MobileBackup2Client init error %s" % DLMessageDeviceReady)
示例2: house_arrest
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)
示例3: __init__
def __init__(self, lockdown=None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.service = self.lockdown.startService('com.apple.mobile.installation_proxy')
示例4: SpringboardClient
class SpringboardClient(object):
def __init__(self, lockdown=None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.service = self.lockdown.startService("com.apple.springboardservices")
def get_iconstate(self):
return self.service.sendRequest({
'command': 'getIconState',
'formatVersion': '2'
})[0]
def set_iconstate(self, state):
self.service.sendPlist({
'command': 'setIconState',
'iconState': state
})
def get_iconpngdata(self, bundleid):
return self.service.sendRequest({
'command': 'getIconPNGData',
'bundleId': bundleid
})['pngData'].data
def get_interface_orientation(self):
response = self.service.sendRequest({'command': 'getInterfaceOrientation'})
if response is None or 'interfaceOrientation' not in response:
raise RuntimeError('Unable to retrieve interface orientation')
return response['interfaceOrientation']
def get_wallpaper_pngdata(self):
return self.service.sendRequest({'command': 'getHomeScreenWallpaperPNGData'})['pngData'].data
示例5: __init__
def __init__(self, lockdown = None,backupPath = None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
ProductVersion = self.lockdown.getValue("", "ProductVersion")
if ProductVersion[0] < "5":
raise DeviceVersionNotSupported
self.udid = lockdown.getValue("", "UniqueDeviceID")
self.willEncrypt = lockdown.getValue("com.apple.mobile.backup", "WillEncrypt")
self.service = self.lockdown.startService("com.apple.mobilebackup2")
if not self.service:
raise Exception("MobileBackup2 init error : Could not start com.apple.mobilebackup2")
if backupPath:
self.backupPath = backupPath
else:
self.backupPath = "backups"
if not os.path.isdir(self.backupPath):
os.makedirs(self.backupPath,0o0755)
print "Starting new com.apple.mobilebackup2 service with working dir: %s" % self.backupPath
self.password = ""
DLMessageVersionExchange = self.service.recvPlist()
version_major = DLMessageVersionExchange[1]
self.service.sendPlist(["DLMessageVersionExchange", "DLVersionsOk", version_major])
DLMessageDeviceReady = self.service.recvPlist()
if DLMessageDeviceReady and DLMessageDeviceReady[0] == "DLMessageDeviceReady":
self.version_exchange()
else:
raise Exception("MobileBackup2 init error %s" % DLMessageDeviceReady)
示例6: __init__
def __init__(self, lockdown=None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.c = self.lockdown.startService("com.apple.syslog_relay")
self.c.send("watch")
示例7: house_arrest
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)
示例8: __init__
def __init__(self, lockdown=None, serviceName='com.apple.afc', service=None):
"""
Constructor method of `AFCClient`.
Note:
`serviceName` is obsolete when `service` parameter is used.
Although it will be saved as attribute.
Args:
`lockdown` (optional): The `LockdownClient` class that should be used for almost everything.
`serviceName` (optional): Service ID of the protocol, defaults to 'com.apple.afc'.
Used for abstract class purposes although you can modify if you have good reasons.
`service` (optional): Useful when you already have a service running.
"""
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
if service:
self.service = service
else:
self.service = self.lockdown.startService(serviceName)
self.serviceName = serviceName
self.packet_num = 0
示例9: screenshotr
class screenshotr(object):
def __init__(self, lockdown=None, serviceName='com.apple.mobile.screenshotr'):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
#Starting Screenshot service
self.service = self.lockdown.startService(serviceName)
#hand check
DLMessageVersionExchange = self.service.recvPlist()
#assert len(DLMessageVersionExchange) == 2
version_major = DLMessageVersionExchange[1]
self.service.sendPlist(["DLMessageVersionExchange", "DLVersionsOk", version_major ])
DLMessageDeviceReady = self.service.recvPlist()
def stop_session(self):
self.service.close()
def take_screenshot(self):
self.service.sendPlist(['DLMessageProcessMessage', {'MessageType': 'ScreenShotRequest'}])
res = self.service.recvPlist()
assert len(res) == 2
assert res[0] == "DLMessageProcessMessage"
if res[1].get('MessageType') == 'ScreenShotReply':
data = res[1]['ScreenShotData'].data
return data
return None
示例10: FileRelayClient
class FileRelayClient(object):
def __init__(self, lockdown=None, serviceName="com.apple.mobile.file_relay"):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.service = self.lockdown.startService(serviceName)
self.packet_num = 0
def stop_session(self):
print "Disconecting..."
self.service.close()
def request_sources(self, sources=["UserDatabases"]):
print "Downloading sources ", sources
self.service.sendPlist({"Sources":sources})
res = self.service.recvPlist()
if res:
if res.has_key("Status"):
if res["Status"] == "Acknowledged":
z = ""
while True:
x = self.service.recv()
if not x:
break
z += x
return z
return None
示例11: Syslog
class Syslog(object):
def __init__(self, lockdown=None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.c = self.lockdown.startService("com.apple.syslog_relay")
self.c.send("watch")
def watch(self,procName=None,logFile=None):
while True:
d = self.c.recv(4096)
if not d:
break
if procName:
procFilter = re.compile(procName,re.IGNORECASE)
if len(d.split(" ")) > 4 and not procFilter.search(d):
continue
print d.strip("\n\x00\x00")
if logFile:
with open(logFile, 'a') as f:
f.write(d.replace("\x00", ""))
示例12: __init__
def __init__(self, lockdown=None, serviceName="com.apple.mobile.notification_proxy"):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
self.service = self.lockdown.startService(serviceName)
self.packet_num = 0
示例13: do_operation
def do_operation(self, opcode, data=""):
try:
self.dispatch_packet(opcode, data)
return self.receive_data()
except:
self.lockdown = LockdownClient()
self.service = lockdown.startService(serviceName)
return self.do_operation(opcode, data)
示例14: __init__
def __init__(self, lockdown=None, serviceName="com.apple.afc", service=None):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
if service:
self.service = service
else:
self.service = self.lockdown.startService(serviceName)
self.packet_num = 0
示例15: __init__
def __init__(self, lockdown=None, serviceName="com.apple.mobile.file_relay"):
if lockdown:
self.lockdown = lockdown
else:
self.lockdown = LockdownClient()
ProductVersion = self.lockdown.getValue("", "ProductVersion")
if ProductVersion[0] >= "8":
raise DeviceVersionNotSupported
self.service = self.lockdown.startService(serviceName)
self.packet_num = 0