-
Notifications
You must be signed in to change notification settings - Fork 2
/
utils.py
60 lines (55 loc) · 2.79 KB
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import os, plistlib, sys, subprocess, fetch, os.path
def openFolder(savePath):
print('[*] File should be in:', savePath)
os.system('open ' + savePath)
#subprocess.run(['explorer', os.path.realpath(args.path + 'SaveMe-Tickets/' + i['ecid'] + '/' + version + '/' )])
def checkManifest(fileLocation, device, boardconfig, element, savePath, isOTA):
otaPath = ""
if isOTA:
otaPath = "AssetData/boot/"
fileName = os.path.expanduser(fileLocation)
if os.path.exists(fileName):
with open(fileName, 'rb') as f:
pl = plistlib.load(f)
if device in pl['SupportedProductTypes']:
print("[Found] %s in " % device + "BuildManifest")
for i in pl['BuildIdentities']:
if boardconfig in i['Info']['DeviceClass']:
print("[Found] %s version in BuildManifest" %i['ProductMarketingVersion'])
print("[Found] %s boardconfig entry in BuildManifest" %i['Info']['DeviceClass'])
print("[Found] SEP at path:[%s] in BuildManifest" %i['Manifest']['SEP']['Info']['Path'])
fetch.downloadFileFromIPSW(element, ["%s" %otaPath + "%s" %i['Manifest']['SEP']['Info']['Path']], savePath)
if 'iPhone' in device:
print("[Found] Baseband at path:[" + otaPath + "%s" %i['Manifest']['BasebandFirmware']['Info']['Path'] + "] in BuildManifest")
fetch.downloadFileFromIPSW(element, ["%s" %otaPath + "%s" %i['Manifest']['BasebandFirmware']['Info']['Path']], savePath)
else:
print("[Warning] %s does not use Baseband for restores!" %device)
return
else:
print("[Error] BoardConfig: [%s] does not match entry in BuildManifest, check again!"%boardconfig)
else:
print("[Error] Counldn't match %s to entry in BuildManifest" %device)
else:
print('[Error] %s does not exist, so can\'t be read' % fileName)
return
def deviceExtractionTool(binaryName, stripValue, grepValue, replace):
if sys.platform == "darwin":
command = binaryName + " | grep " + grepValue
if sys.platform == "win32":
command = binaryName + " | findstr " + grepValue
command = binaryName + " | grep " + grepValue
process = subprocess.Popen(command,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,encoding="utf8")
output = process.communicate()
stdOutput, stdErrValue = output
stdOutput = stdOutput.strip()
stdOutput = stdOutput[stripValue:]
if replace == True:
stdOutput = stdOutput.replace(" ", "")
return dataReturn(stdOutput, stdErrValue)
def dataReturn(output, error):
ret = None
if error != None:
ret = error
if output != None:
ret = output
return ret