-
Notifications
You must be signed in to change notification settings - Fork 14
/
check_CVE-2020-35489.py
92 lines (76 loc) · 2.72 KB
/
check_CVE-2020-35489.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
#!/usr/bin/python3.8
from factory import Factory
import requests
import sys, getopt
from packaging import version
in_file = ''
out_file = ''
domain = ''
Help = """
python3.8 check_CVE-2020-35489.py -i <inputfile> -o <outputfile>
python3.8 check_CVE-2020-35489.py -d <domain>
"""
def find_plugin_version(str_response):
ver_lo = str_response.find("Stable tag:")
return(str_response[ver_lo+12:ver_lo+32].split()[0])
def check(domain):
try:
c_domain = 'http://' + domain + '/wp-content/plugins/contact-form-7/readme.txt'
r = requests.get(c_domain, timeout = 3.0)
if r.status_code == 200:
version_ = find_plugin_version(r.text)
if in_file == '':
print("Contact Form 7 version: " + str(version_))
if version.parse(version_) < version.parse("5.3.2"):
print(domain + " is vulnerable!")
else:
print(domain + " is not vulnerable!")
else:
if version.parse(version_) < version.parse("5.3.2"):
open(out_file,"a").write(domain + '\n')
return
except:
pass
try:
c_domain = 'https://' + domain + '/wp-content/plugins/contact-form-7/readme.txt'
r = requests.get(c_domain, timeout = 3.0)
if r.status_code == 200:
version_ = find_plugin_version(r.text)
if in_file == '':
print("Contact Form 7 version: " + str(version_))
if version.parse(version_) < version.parse("5.3.2"):
print(domain + "is vulnerable!")
else:
print(domain + "is not vulnerable!")
else:
if version.parse(version_) < version.parse("5.3.2"):
open(out_file,"a").write(domain + '\n')
except:
pass
def main(argv):
global in_file, out_file, domain
try:
opts, args = getopt.getopt(argv,"hi:o:d:",["ifile=","ofile=","domain="])
for opt, arg in opts:
if opt == '-h':
print(Help)
sys.exit()
elif opt in ("-i", "--infile"):
in_file = arg
elif opt in ("-o", "--outfile"):
out_file = arg
elif opt in ("-d", "--domain"):
domain = arg
if len(in_file) > 0:
tasks = [tuple(line.strip().split(":")) for line in open(in_file,'r') if line.strip() != ""]
factory = Factory(check, tasks, workers=512)
factory.start(wait=True)
exit()
else:
check(domain)
exit()
except getopt.GetoptError:
print(Help)
sys.exit(2)
if __name__ == "__main__":
main(sys.argv[1:])