forked from Endermanch/MalwareDatabase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddom.py
331 lines (262 loc) · 10.3 KB
/
ddom.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
# росия🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢🤢
import sys
import re
import urllib.request
import urllib.error
import urllib.parse
import random
import hashlib
import requests
import os
import argparse
import pyvirtualdisplay
from selenium import webdriver
import datetime
timestamp_now = datetime.datetime.now().strftime('%Y-%m-%d')
print("""\n
# Daily Dose of Malware (DDoM)
#
# Original author: https://github.com/notnop
# Rewritten by Enderman and Matt in Python 3!
#
# %%%%&&&&..............%%%/ Malware is art!
# %%%%&&&&.........&&&..%%%%% Don't let it become a filthy criminal's tool!
# %%%%&&&&.........&&&..%%%%%%%
# %%%%&&&&.........&&&..%%%%%%% https://malwarewatch.org
# %%%%&&&&.........,,,..%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
# %%%% _________________ .%%%%
# %%%% _________________ .%%%%
# %%%% _________________ .%%%%
# %%%% _________________ .%%%%
# %%%% _________________ .%%%%
# %%%% _________________ .%%%%
# %&&% ,%&&%
# %&&%%%%%%%%%%%%%%%%%%%%%%%&&%
# %&&%%%%%%%%%%%%%%%%%%%%%%%&&%\n""")
# Flags
parser = argparse.ArgumentParser(description='DDoM v2.0')
parser.add_argument("-c", "--count", nargs=1, type=int, help="Defines the number of malware samples you want, up to 5000. If the argument is omitted, sets to 100 by default.",
required=False, default=argparse.SUPPRESS, metavar="SAMPLES")
parser.add_argument("-r", "--rename", help="[Not recommended] Makes the samples executable. Don't use this unless you're confident you won't execute them on your host.",
required=False, action="store_const", const=True)
parser.add_argument("-y", "--yes-to-all", help="Skips the confirmation prompt.",
required=False, action="store_const", const=True)
def confirmation(question, default="no"):
valid = {"yes": True, "y": True, "ye": True,
"no": False, "n": False}
if default is None:
prompt = " [y/n] "
elif default == "yes":
prompt = " [Y/n] "
elif default == "no":
prompt = " [y/N] "
validInputEntered = False
while not validInputEntered:
data = input("{}{}".format(question, prompt)).lower()
if data in valid:
validInputEntered = True
return valid[data]
if data == "":
validInputEntered = True
return default
args = parser.parse_args()
print(args)
if not "count" in args:
print("[*] Argument was omitted - going with 100 samples by default")
scount = 100
else:
scount = args.count[0]
# Global variables
final_list = [] # Malware address collector
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.3'
}
print("""\nYou'll get latest {} samples from:
\t# http://malc0de.com
\t# http://vxvault.net
\t# http://tracker.h3x.eu
""".format(scount))
confirmed = confirmation("Confirm and start downloading {} samples?".format(scount), "no")
if not confirmed:
sys.exit(0)
print("\nSearching...")
# Malc0de
def malc0de(samples):
global final_list
url_list = []
if samples <= 50:
pages = 1
else:
pages = (samples // 50) + 1
# Browsing pages
for i in range(0, pages):
address = "https://malc0de.com/database/?&page=" + str(i)
try:
#req = requests.get(address, headers=headers)
#con = urllib.request.urlopen(req, timeout=60).read()
req = requests.get(address, headers=headers)
con = req.content.decode("utf-8")
b = re.findall("<td>[\d]{4}-[\d]{2}-[\d]{2}<\/td>\n.+\n", con)
if b:
for i in b:
date = re.search("<td>([\d]{4}-[\d]{2}-[\d]{2})<\/td>", i)
malware = re.search("\t<td>(.+)<\/td>", i)
if date and malware:
malware = re.sub("<br\/>", "", malware.group(1))
url_list.append(malware)
except Exception as e:
print("Malc0de: " + str(e))
final_list += url_list
print("[*] Malc0de - Done ", len(url_list))
# VXVault
def vxvault(nr_samples):
global final_list
url_list = []
address = "http://vxvault.net/ViriList.php?s=0&m=" + str(nr_samples)
try:
#req = urllib.request.Request(address, None, headers)
#con_page = urllib.request.urlopen(req).read()
req = requests.get(address, headers=headers)
con_page = req.content.decode("utf-8")
# Find all malware addresses
page = con_page.split("\r")
for i in page:
match = re.search(
"href='ViriFiche\.php\?ID=[\d]+'>(.+)</a></TD>", i)
if match:
temp_mal_address = match.group(1)
if not re.search("[\d]{1,2}-[\d]{1,2}", temp_mal_address):
# Add malware addresses
url_list.append(temp_mal_address)
final_list += url_list
except Exception as e:
#print("vxvault: " + str(e))
raise e
print("[*] VXVault - Done ", len(url_list))
def h3x_get(nr_samples):
lst = []
address = "http://tracker.h3x.eu/"
req = urllib.request.Request(address, None, headers)
con_page = urllib.request.urlopen(req).readlines()
# Print con_page
for linie in con_page:
address = re.findall("href='/site/([A-Za-z0-9%\._-]+)", linie.decode("utf-8"))
lst += address
if len(lst) >= nr_samples:
return lst
return lst
def h3x_clean(x=1000):
global final_list
list = h3x_get(x)
new_list = []
# Cleaning
for i in list:
i = re.sub("%3A", ":", i)
i = re.sub("%2F", "/", i)
new_list.append(i)
final_list += new_list
print("[*] tracker.h3x - Done ", len(new_list))
def google(export_bool=False, output_bool=False):
dorks = {"Pony": ["intitle:Authorization inurl:panel*/admin.php intext:Authorization. Sign in.",
"intitle:Authorization inurl:panel*/*admin.php",
"intitle:Authorization inurl:*admin.php Authorization. User Password Save password. Login. TF."],
"WannaCry": "intitle:\"index of\" \"@[email protected]",
"Stealer": "intitle:\"(c) Bilal Ghouri\"",
"LokiBot": "inurl:PvqDq929BSx_A_D_M1n_a.php intitle:Auth",
"1ms0rry": "intitle:1ms0rry MINERPANEL",
"SpyEye": "intitle:FRMCP intext:Please, enter password"}
info = {}
links_list = []
directory = "google" + timestamp_now
# now Firefox will run in a virtual display.
# you will not see the browser.
print("[*] Google - Starting Firefox...")
print("[*] Google - NOTE: Do not control Firefox while it is running!")
browser = webdriver.Firefox()
for i in dorks.keys(): # for every dork in dictionary
if i == "Pony": # for Pony is more than one dork
for j in dorks[i]:
browser.get('http://www.google.com/search?q=' + j + "&t=h_&ia=web")
links = browser.find_elements_by_xpath("//h3//a[@href]")
for elem in links:
link = elem.get_attribute("href")
links_list.append(link)
info.update({i: links_list})
links_list = []
else:
browser.get('http://www.google.com/search?q=' + dorks[i] + "&t=h_&ia=web")
links = browser.find_elements_by_xpath("//h3//a[@href]")
for elem in links:
link = elem.get_attribute("href")
links_list.append(link)
info.update({i: links_list})
links_list = []
for i in info:
print("-----------------------------")
print(i)
for j in info[i]:
print(j)
print("-----------------------------")
browser.quit()
# Collect samples address:
malc0de(scount)
vxvault(scount)
h3x_clean(scount)
try:
google()
except Exception as e:
print(str(e))
final_list = list(set(final_list))
print("\nUnique addresses: ", len(final_list))
print("\nDownloading...")
# Generate random string
charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
def get_random_word(a):
word = ''
for i in range(a):
word += random.choice(charset)
return word
# MD5 file
def md5Checksum(filePath):
fh = open(filePath, 'rb')
m = hashlib.md5()
while True:
data = fh.read(8192)
if not data:
break
m.update(data)
return m.hexdigest()
def download_file(address, dldagent={'User-Agent': "Chromium"},
destination_folder=os.getcwd() + "\\Samples\\",
logs="error.log"):
if not os.path.exists(destination_folder):
os.makedirs(destination_folder)
# Filename
filename = destination_folder + str(get_random_word(8)) + '.exe'
# Try to download sample
try:
# Check if URL start with "http://
if address[:7] != "http://":
address = "http://" + address
# Construct URL and set timeout
req = urllib.request.Request(address, None, dldagent)
u = urllib.request.urlopen(req, timeout=4).read() # timeout 5 seconds
# Write to file
f = open(filename, 'wb')
f.write(u)
f.close()
# Write information to the log file
with open(destination_folder + logs, "a") as handle:
md5hash = md5Checksum(filename)
handle.write(md5hash + "\t" + filename + "\t" + address + "\n")
handle.close
print("[*] Downloaded: " + filename)
except Exception as e:
with open(destination_folder + logs, "a") as handle:
handle.write("Error: " + address + "\t" + str(e) + "\n")
handle.close()
pass
for mal in final_list:
download_file(mal)