-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
104 lines (52 loc) · 2.2 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import os
import logging
import base64
from cryptography.fernet import Fernet
from pyoxidizer import build
def obfuscate_file(filename: str, key: bytes):
with open(filename, "rb") as f:
data = f.read()
f = Fernet(key)
encrypted_data = f.encrypt(data)
with open(f"obfuscated_{filename}", "wb") as f:
f.write(encrypted_data)
logging.info(f"File obfuscated successfully as 'obfuscated_{filename}'")
def encode_file(filename: str):
with open(filename, "rb") as f:
data = f.read()
obf_data = base64.b64encode(data)
with open(f"encoded_{filename}", "w") as f:
f.write("# This file has been encoded using white obfuscate\n\n")
f.write(f"import base64\nexec(base64.b64decode({repr(obf_data)}))")
logging.info(f"File encoded successfully as 'encoded_{filename}'")
def main():
while True:
print("""
+-------------------------------------------------------------------+
│ │
│ 1. Obfuscate File │
│ │
│ 2. Encode File │
│ │
│ 3. Exit │
│ │
+-------------------------------------------------------------------+
""")
choice = input("Enter your choice: ")
if choice == "1":
filename = input("Enter the name of the file to be obfuscated: ")
key = Fernet.generate_key()
obfuscate_file(filename, key)
elif choice == "2":
filename = input("Enter the name of the file to be encoded: ")
encode_file(filename)
elif choice == "3":
break
else:
print("[ERROR!] Invalid input, please try again.")
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO)
# Build the executable using PyOxidizer
build()
# Run the main function
main()