-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupdate_data.py
More file actions
68 lines (56 loc) · 1.86 KB
/
Copy pathupdate_data.py
File metadata and controls
68 lines (56 loc) · 1.86 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
#!/usr/bin/python
# -*- coding: utf-8 -*-
import requests
import os
import sys
import time
import hashlib
import json
import platform
if sys.stdout.isatty() and platform.system() != 'Windows':
colors = {'red': '\033[91m',
'green': '\033[92m',
'yellow': '\033[93m',
'blue': '\033[94m',
'purple': '\033[95m',
'endc': '\033[0m'}
else:
colors = {'red': '',
'green': '',
'yellow': '',
'blue': '',
'purple': '',
'endc': ''}
def color(color, string):
return colors.get(color) + string + colors.get('endc')
def database_update():
print(color('yellow','Updating database - Last update: ')+ database_last_date('database/local_vulnerable_files.xml'))
update_url = "https://data.wpscan.org/"
update_files = [ 'wp_versions.xml', 'wp_versions.xsd',
'wordpresses.json', 'plugins.json', 'themes.json']
for f in update_files:
print("\t"+color('yellow','Downloading ')+ f + " "+ color('green','File updated !'))
download_raw_file(update_url+f, "database/"+f, True)
def database_last_date(filename):
if not os.path.isfile(filename):
return "Never"
(mode, ino, dev, nlink, uid, gid, size, atime, mtime, ctime) = os.stat(filename)
return time.ctime(mtime)
def download_raw_file(url, filename, verbosity):
try:
# Open the request
source = requests.get( url, stream=True).raw
# Write the file
with open( filename, 'wb+' ) as ddl_file:
progress = 0
while True:
length = 16*1024
buf = source.read(length)
if not buf:
break
ddl_file.write(buf)
progress += len(buf)
if verbosity == True:
print('\tDownloaded : %.2f Mo\r' % (float(progress)/(1024*1024))),
except Exception as e:
raise e