Commit 78c76930 by fwkz

Module cosmetics and PEP8 fixes.

parent 5b698f59
from routersploit import *
from os import listdir from os import listdir
from os.path import isfile, join
import imp import imp
from routersploit import (
exploits,
print_error,
print_success,
print_status,
print_info,
)
class Exploit(exploits.Exploit): class Exploit(exploits.Exploit):
""" """
...@@ -20,20 +26,19 @@ class Exploit(exploits.Exploit): ...@@ -20,20 +26,19 @@ class Exploit(exploits.Exploit):
port = exploits.Option(80, 'Target port') # default port port = exploits.Option(80, 'Target port') # default port
def run(self): def run(self):
exploits = []
rootpath = 'routersploit/modules/' rootpath = 'routersploit/modules/'
path = 'exploits' path = 'exploits'
modules = [] modules = []
for device in listdir(rootpath+path): for device in listdir(rootpath+path): # TODO refactor this, using load_modules() from core
if not device.endswith(".py") and not device.endswith(".pyc"): if not device.endswith(".py") and not device.endswith(".pyc"):
for f in listdir(rootpath+path + "/" + device): for f in listdir(rootpath+path + "/" + device):
if f.endswith(".py") and f != "__init__.py": if f.endswith(".py") and f != "__init__.py":
modules.append(device + "/" + f[:-3]) modules.append(device + "/" + f[:-3])
vulns = [] vulnerabilities = []
for module_name in modules: for module_name in modules:
f = path + "/"+ module_name f = "".join((path, "/", module_name))
module = imp.load_source('module', rootpath + f + '.py') module = imp.load_source('module', rootpath + f + '.py')
exploit = module.Exploit() exploit = module.Exploit()
...@@ -41,25 +46,22 @@ class Exploit(exploits.Exploit): ...@@ -41,25 +46,22 @@ class Exploit(exploits.Exploit):
exploit.target = self.target exploit.target = self.target
exploit.port = self.port exploit.port = self.port
res = exploit.check() response = exploit.check()
if res is True: if response is True:
print_success("{} is vulnerable".format(f)) print_success("{} is vulnerable".format(f))
vulns.append(f) vulnerabilities.append(f)
elif res is False: elif response is False:
print_error("{} is not vulnerable".format(f)) print_error("{} is not vulnerable".format(f))
else: else:
print_status("{} could not be verified".format(f)) print_status("{} could not be verified".format(f))
print if vulnerabilities:
if len(vulns): print_success("\nDevice is vulnerable!")
print_success("Device is vulnerable!") for v in vulnerabilities:
for v in vulns: print_info(" - {}".format(v))
print " - {}".format(v)
else: else:
print_error("Device is not vulnerable to any exploits!") print_error("Device is not vulnerable to any exploits!\n")
print
def check(self): def check(self):
print_error("Check method is not available") print_error("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