|
|
@ -52,18 +52,28 @@ def code_to_bytecode(code, mtime=0, source_size=0):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(sys.argv) < 3:
|
|
|
|
if len(sys.argv) < 3:
|
|
|
|
print("Usage %s <in_path> <out_path>" % sys.argv[0])
|
|
|
|
print("Usage %s <in_path> <pyc_path> <py_path>" % sys.argv[0])
|
|
|
|
sys.exit(1)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
in_path = Path(sys.argv[1])
|
|
|
|
in_path = Path(sys.argv[1])
|
|
|
|
out_path = Path(sys.argv[2])
|
|
|
|
pyc_path = Path(sys.argv[2])
|
|
|
|
|
|
|
|
py_path = Path(sys.argv[3])
|
|
|
|
|
|
|
|
|
|
|
|
for path in in_path.rglob("*.co"):
|
|
|
|
for path in in_path.rglob("*.co"):
|
|
|
|
with open(str(path), "rb") as file:
|
|
|
|
try:
|
|
|
|
data = file.read()
|
|
|
|
co = marshal.loads(path.read_bytes())
|
|
|
|
co = marshal.loads(data)
|
|
|
|
|
|
|
|
pyc = code_to_bytecode(co, time.time())
|
|
|
|
pyc = code_to_bytecode(co, time.time())
|
|
|
|
out_file = out_path / path.relative_to(in_path)
|
|
|
|
|
|
|
|
out_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
pyc_file = pyc_path / path.relative_to(in_path).with_suffix(".pyc")
|
|
|
|
with open(str(out_file), "wb") as file:
|
|
|
|
pyc_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(str(pyc_file), "wb") as file:
|
|
|
|
file.write(pyc)
|
|
|
|
file.write(pyc)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
py_file = py_path / path.relative_to(in_path).with_suffix(".py")
|
|
|
|
|
|
|
|
py_file.parent.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open(str(py_file), 'w') as decompiled:
|
|
|
|
|
|
|
|
uncompyle6.main.decompile_file(str(pyc_file), decompiled)
|
|
|
|
|
|
|
|
except:
|
|
|
|
|
|
|
|
print("Failed to decompile %s" % path)
|
|
|
|