Commit 6c0ce514 by fwkz

Threaded scanner

parent 6a60de9d
import threading
from routersploit import ( from routersploit import (
exploits, exploits,
print_error, print_error,
...@@ -5,6 +6,7 @@ from routersploit import ( ...@@ -5,6 +6,7 @@ from routersploit import (
print_status, print_status,
print_info, print_info,
utils, utils,
LockedIterator
) )
...@@ -28,32 +30,35 @@ class Exploit(exploits.Exploit): ...@@ -28,32 +30,35 @@ class Exploit(exploits.Exploit):
target = exploits.Option('', 'Target IP address e.g. 192.168.1.1') # target address target = exploits.Option('', 'Target IP address e.g. 192.168.1.1') # target address
port = exploits.Option(80, 'Target port') # default port port = exploits.Option(80, 'Target port') # default port
threads = exploits.Option(8, "Number of threads")
def run(self): def run(self):
vulnerabilities = [] data = LockedIterator(utils.iter_modules(utils.EXPLOITS_DIR))
self.run_threads(self.threads, self.target_function, data)
for exploit in utils.iter_modules(utils.EXPLOITS_DIR): def check(self):
exploit = exploit() raise NotImplementedError("Check method is not available")
exploit.target = self.target
exploit.port = self.port
response = exploit.check() def target_function(self, running, data):
name = threading.current_thread().name
print_status(name, 'process is starting...')
if response is True: while running.is_set():
print_success("{} is vulnerable".format(exploit)) try:
vulnerabilities.append(exploit) exploit = data.next()
elif response is False: except StopIteration:
print_error("{} is not vulnerable".format(exploit)) break
else: else:
print_status("{} could not be verified".format(exploit)) exploit = exploit()
exploit.target = self.target
exploit.port = self.port
if vulnerabilities: response = exploit.check()
print_info()
print_success("Device is vulnerable!") if response is True:
for v in vulnerabilities: print_success("{} {} is vulnerable".format(name, exploit))
print_info(" - {}".format(v)) elif response is False:
else: print_error("{} {} is not vulnerable".format(name, exploit))
print_error("Device is not vulnerable to any exploits!\n") else:
print_status("{} {} could not be verified".format(name, exploit))
def check(self):
raise NotImplementedError("Check method is not available")
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