This repository was archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeobfuscator.py
46 lines (37 loc) · 1.68 KB
/
deobfuscator.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
import os
import sys
import glob
from loader import args
from loaded import deobfuscators
from logger import error, header
print("""\033[92m
_____ _____ _ __ _
| __ \ | __ \ | | / _| | |
| |__) | _| | | | ___ ___ | |__ | |_ _ _ ___ ___ __ _| |_ ___ _ __
| ___/ | | | | | |/ _ \/ _ \| '_ \| _| | | / __|/ __/ _` | __/ _ \| '__|
| | | |_| | |__| | __/ (_) | |_) | | | |_| \__ \ (_| (_| | || (_) | |
|_| \__, |_____/ \___|\___/|_.__/|_| \__,_|___/\___\__,_|\__\___/|_|
__/ |
|___/
\033[0m""")
# exit if input file or directory doesn't exist
if not os.path.exists(args.input):
error('directory or file \'{0}\' does not exist!'.format(args.input))
sys.exit(0)
# recursively read all files in the input dir to an array
input_files = [f for f in glob.glob('{0}/**/*.py'.format(args.input.rstrip('/')), recursive=True)] \
if os.path.isdir(args.input) \
else [args.input]
deobfuscator = next(d for d in deobfuscators if d.name == args.deobfuscator)
header(' using \033[94m{0}\033[0m deobfuscator '.format(deobfuscator.name))
deobfuscator.set_parsed_arguments(args)
# map input files to output files
io = {}
for input_file in input_files:
output_file = input_file.replace(args.input, args.output)
# recursively create output directories
output_dir = os.path.dirname(output_file)
if not os.path.exists(output_dir):
os.makedirs(output_dir)
io[input_file] = output_file
deobfuscator.deobfuscate(io)