-
-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy path__init__.py
More file actions
50 lines (42 loc) · 1.15 KB
/
__init__.py
File metadata and controls
50 lines (42 loc) · 1.15 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
40
41
42
43
44
45
46
47
48
49
50
import sys
import python_obfuscator
from python_obfuscator.techniques import one_liner
import argparse
def convert_file(args):
file_path = args.input
obfuscate = python_obfuscator.obfuscator()
# removed techniques
remove = []
if not args.one_liner:
remove.append(one_liner)
with open(file_path, "r") as f:
data = f.read()
obfuscated_data = obfuscate.obfuscate(data, remove_techniques=remove)
if args.replace:
with open(file_path, "w+") as f:
f.write(obfuscated_data)
else:
print(obfuscated_data)
def cli():
parser = argparse.ArgumentParser(description="Process CLI args")
parser.add_argument(
"-i", "--input", help="File to obfuscate", required=True, type=str
)
parser.add_argument(
"-r",
"--replace",
help="Replace the file specified",
required=False,
default=False,
type=bool,
)
parser.add_argument(
"-ol",
"--one-liner",
help="Add the one liner technique",
required=False,
default=False,
type=bool,
)
args = parser.parse_args()
convert_file(args)