-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathmdownloader.py
More file actions
107 lines (91 loc) · 2.85 KB
/
Copy pathmdownloader.py
File metadata and controls
107 lines (91 loc) · 2.85 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
#-------------------------------------------------------------------------------
# Name: massdownloader
# Purpose: mass malware downloader
#
# Author: Giuseppe 'evilcry' Bonfa
#
# Created: 12/08/2012
# Copyright: (c) Giuseppe 2012
# Licence: GPL
#-------------------------------------------------------------------------------
import os
import Queue
import threading
import urllib2
import hashlib
import datetime
try:
import mwclass
except ImportError:
print "missing mwclass module"
# - MultiThreaded Queue based Downloader - START
class Downloader(threading.Thread):
def __init__(self, queue, destdir):
threading.Thread.__init__(self)
self.queue = queue
self.destdir = destdir
def run(self):
while True:
url = self.queue.get()
self.download_file(url, self.destdir)
self.queue.task_done()
def download_file(self, url, destdir):
try:
req = urllib2.urlopen(url)
content = req.read()
req.close()
except urllib2.URLError, e:
print "Skipping: %s Reason: %s" % (url, e.reason)
fname = os.path.basename(url)
try:
f = open(destdir + "\\" + fname,'wb')
if 'content' in locals():
f.write(content)
#f.write(content)
f.close()
except IOError, e:
print "Skipping: %s" % fname
# - MultiThreaded Queue based Downloader - END
def daily_dir():
now = datetime.datetime.now()
actual_date = "%d-%d-%d" % (now.day, now.month, now.year)
if os.path.exists(actual_date) is False:
os.mkdir(actual_date)
return actual_date
def get_daily_list(datelist):
dwn_list = urllib2.urlopen("http://vxvault.siri-urz.net/URL_List.php")
list_path = datelist + ".txt"
f = open(list_path, "w")
f.write(dwn_list.read())
f.close()
return list_path
def parse_list(list_path):
f = open(list_path, "r")
lines = f.readlines()
f.close()
lines[0:4] = []
for i in range(len(lines)):
lines[i] = lines[i].rstrip('\r\n')
return lines
def main():
print("Massive Downloader")
download_dir = daily_dir()
list_path = get_daily_list(download_dir)
mal_url_list = parse_list(list_path)
# Mass Download - START
queue = Queue.Queue()
for i in range(4):
t = Downloader(queue, download_dir)
t.setDaemon(True)
t.start()
for url in mal_url_list:
queue.put(url)
queue.join()
# Mass Download - END
print "\n--------Mass Download Completed with Success---------\n"
print "Building hash list file\n"
mwclassifier = mwclass.mwClassify(download_dir)
mwclassifier.hashlist()
pass
if __name__ == '__main__':
main()