-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patholdDumpDecrypter.py
62 lines (47 loc) · 1.89 KB
/
oldDumpDecrypter.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
61
62
import argparse
import os
from galileo.databases.local import LocalDatabase, UnknownDumpTypeError
from galileo.dump import Dump, DumpResponse, MEGADUMP
from galileo.utils import x2a
from galileo.megadumpDecrypter import decrypt
def main():
parser = argparse.ArgumentParser(description='Decrypt dumps collected earlier')
parser.add_argument('trackerId')
args = parser.parse_args()
dumpDir = '~/.galileo'
db = LocalDatabase(dumpDir)
trackerId = args.trackerId
trackerDumpDir = db.getDeviceDirectoryName(trackerId)
key = db.loadKey(trackerId)
files = os.listdir(trackerDumpDir)
files = [x for x in files if not 'dec' in x]
for filename in files:
dumpname = os.path.join(trackerDumpDir, filename)
file = open(dumpname)
data = file.read()
pieces = data.split('\n\n')
responsePresent = len(pieces)==2
if responsePresent:
[megadumpData, megadumpResponseData] = pieces
else:
[megadumpData] = pieces
megadump = Dump(MEGADUMP)
megadump.data = bytearray(x2a(megadumpData))
megadump.megadump()
try:
decrypt(megadump, key)
except UnknownDumpTypeError:
print('Encountered an UnknownDumpTypeError in the dump of file: '+ filename)
megadump.toFile(dumpname.replace('.txt','_dec.txt'))
if responsePresent:
CHUNK_LEN = 20
megadumpResponse = DumpResponse(x2a(megadumpResponseData), CHUNK_LEN)
megadumpResponse.megadump()
try:
decrypt(megadumpResponse, key, offset=10)
except UnknownDumpTypeError:
print('Encountered an UnknownDumpTypeError in the responsedump of file: '+ filename)
megadumpResponse.toFile(dumpname.replace('.txt','_resp_dec.txt'))
if __name__ == "__main__":
#execute only when if run as a script
main()