-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
33 lines (26 loc) · 1.06 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
import os
import uncompyle6
def decompile(your_directory):
"""
Compiles decompiled Python files and extracts them to the same folder
:param your_directory: decompiled files
:return: void
"""
for dirpath, b, filenames in os.walk(your_directory):
# files to be bypassed, not scanned
if 'venv' in dirpath or 'env' in dirpath or '.git' in dirpath:
continue
for filename in filenames:
if not filename.endswith('.pyc'):
continue
filepath = dirpath + '/' + filename
original_filename = filename.split('.')[0]
original_filepath = dirpath + '/' + original_filename + '.py'
with open(original_filepath, 'w') as f:
try:
uncompyle6.decompile_file(filepath, f)
print("decompiled file: " + filepath)
except Exception as ex:
print("Decompiled Error filename -> " + filepath + ". " + ex)
if __name__ == '__main__':
decompile("/home/cevher/decompiled_project")