-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
136 lines (127 loc) · 3.8 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
import pyfiglet
from colorama import Fore, Back, Style, init
import time
from platform import system
import base64
from sys import exit
from signal import signal, SIGINT
import os
from cryptography.fernet import Fernet
def handler(signal_received, frame):
print(Fore.GREEN + "\n\nGoodbye!" + Style.RESET_ALL)
exit(0)
def main():
path = None
def base32en():
imports_array = ['import base64']
code_array = []
code_str = ""
try:
input_file = open(path).read().splitlines()
except:
print(Fore.RED + "Invalid file path!" + Style.RESET_ALL)
return
for i in input_file:
if i.startswith("import") or i.startswith("from"):
imports_array.append(i)
else:
code_array.append(i)
try:
os.mkdir("output")
except:
pass
output_file = open(os.path.join("output", "output.py"), "w+")
for i in imports_array:
output_file.write(i + '\n')
for i in code_array:
code_str += '\n' + i
encoded = base64.b32encode(bytes(code_str, "utf-8"))
output_file.write('\n' + "exec(base64.b32decode(" + str(encoded) + "))")
output_file.close()
def ferneten():
imports_array = ['from cryptography.fernet import Fernet']
code_array = []
code_str = ""
try:
input_file = open(path).read().splitlines()
except:
print(Fore.RED + "Invalid file path!" + Style.RESET_ALL)
return
for i in input_file:
if i.startswith("import") or i.startswith("from"):
imports_array.append(i)
else:
code_array.append(i)
try:
os.mkdir("output")
except:
pass
output_file = open(os.path.join("output", "output.py"), "w+")
for i in imports_array:
output_file.write(i + '\n')
for i in code_array:
code_str += '\n' + i
key = Fernet.generate_key()
f = Fernet(key)
encrypted = f.encrypt(bytes(code_str, "utf-8"))
output_file.write('\n' + "key = " + str(key) + "\nf = Fernet(key)" + "\n\nexec(f.decrypt(" + str(encrypted) + "))")
output_file.close()
def base64en():
imports_array = ['import base64']
code_array = []
code_str = ""
try:
input_file = open(path).read().splitlines()
except:
print(Fore.RED + "Invalid file path!" + Style.RESET_ALL)
return
for i in input_file:
if i.startswith("import") or i.startswith("from"):
imports_array.append(i)
else:
code_array.append(i)
try:
os.mkdir("output")
except:
pass
output_file = open(os.path.join("output", "output.py"), "w+")
for i in imports_array:
output_file.write(i + '\n')
for i in code_array:
code_str += '\n' + i
encoded = base64.b64encode(bytes(code_str, "utf-8"))
output_file.write('\n' + "exec(base64.b64decode(" + str(encoded) + "))")
output_file.close()
print("\nUse the \"help\" command to display options\n")
while True:
prompt = input(Fore.YELLOW + "(Pycrypter$) " + Style.RESET_ALL)
if prompt == "base64":
path = input("Enter the absolute path of your file: ")
base64en()
elif prompt == "base32":
path = input("Enter the absolute path of your file: ")
base32en()
elif prompt == "fernet":
path = input("Enter the absolute path of your file: ")
ferneten()
elif prompt == "path":
print("Your current path is: " + str(path))
elif prompt == "exit":
print(Fore.GREEN + "\nGoodbye!" + Style.RESET_ALL)
exit(0)
elif prompt == "help":
print("Encrytion types: fernet, base32, base64\nOptions: help, exit, path")
elif prompt == "clear":
if system() == "Linux":
os.system("clear")
elif system() == "Windows":
os.system("cls")
else:
print(Fore.RED + "Invalid option" + Style.RESET_ALL)
if __name__ == '__main__':
signal(SIGINT, handler)
if system() == "Windows":
init(convert=True)
print(Fore.RED + pyfiglet.figlet_format('Pycrypter', font='slant') + Style.RESET_ALL)
print(Back.BLUE + "*A Python encrypter for bypassing AV*" + Style.RESET_ALL + "\n" + Back.RED + " By Dom13377 " + Style.RESET_ALL)
main()