forked from ZhangFengze/NeoXResearch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
52 lines (43 loc) · 1.62 KB
/
main.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
# -*- coding: utf-8 -*-
import os
import sys
import decrypt_buffer
import nxs2pyc
import decrypt_pyc
import decompile_pyc
import pathlib2
if __name__ == "__main__":
failedFiles = []
files = pathlib2.Path(sys.argv[1]).glob("*")
files = sorted(files, key=lambda file: file.stat().st_size)
for file in files:
if file.name == "redirect.nxs":
continue
with open(str(file), "rb") as infile:
data = infile.read()
data = decrypt_buffer.Decrypt(data)
data = nxs2pyc.nxs2pyc(data)
filename, data = decrypt_pyc.decrypt_pyc(data)
# uncompyle6 python2 docstring有问题,反编译挪到python3执行
# try:
# data = decompile_pyc.decompile_pyc(data)
# except KeyboardInterrupt as k:
# raise k
# except Exception as e:
# print("decompile %s %s failed" % (file, filename))
# continue
pycPath = pathlib2.Path(sys.argv[2])/(filename+"c")
pycPath.parent.mkdir(exist_ok=True, parents=True)
with open(str(pycPath), "wb") as outfile:
outfile.write(data)
# 注意用python3
pyPath = pathlib2.Path(sys.argv[3])/filename
decompileSuccess = os.system(
"uncompyle6 -o %s %s" % (str(pyPath), str(pycPath)))
if decompileSuccess != 0:
failedFiles.append((str(file), str(pycPath)))
print("failed with:")
for fail in failedFiles:
print(fail)
with open("failed", "wb") as outfile:
outfile.write(str(failedFiles))