-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsave_firefox_session
More file actions
executable file
·39 lines (28 loc) · 1.14 KB
/
save_firefox_session
File metadata and controls
executable file
·39 lines (28 loc) · 1.14 KB
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
#!/usr/bin/env python3
"""Save lz4 and decompressed versions of the firefox recovery.json file.
Supported input: json or jsonlz4 recovery files
Inspired by: https://gist.github.com/tmonjalo/33c4402b0d35f1233020bf427b5539fa
"""
DECOMPRESS = False # do we want to save the decompressed version?
import time
import lz4.block
import shutil
timestamp = time.strftime( "%Y-%m-%dT%H:%M:%S", time.localtime())
DEFAULT = "/home/darren/.mozilla/firefox/u6g0fs57.default/sessionstore-backups/recovery.jsonlz4"
OUTFILE = "firefox-recovery-%s.json" % timestamp
if __name__ == '__main__':
# make a copy of the original recovery.jsonlz4 file.
shutil.copyfile(DEFAULT, OUTFILE+"lz4")
print("firefox-recovery-%s.jsonlz4 written." % timestamp)
if DECOMPRESS:
# decompress the lz4 format
window_number = 0
file_obj = open(DEFAULT, "rb")
b = file_obj.read()
if b[:8] == b'mozLz40\0':
b = lz4.block.decompress(b[8:])
# write out the decompressed version
g = open(OUTFILE, "wb")
g.write(b)
g.close()
print("firefox-recovery-%s.json written." % timestamp)