Unverified Commit 2ee21d01 by Marcin Bury Committed by GitHub

Fixing undefined names (#434)

parent 5ea63d0e
...@@ -39,7 +39,6 @@ def __cprint(*args, **kwargs): ...@@ -39,7 +39,6 @@ def __cprint(*args, **kwargs):
if not kwargs.pop("verbose", True): if not kwargs.pop("verbose", True):
return return
color = kwargs.get("color", None)
sep = kwargs.get("sep", " ") sep = kwargs.get("sep", " ")
end = kwargs.get("end", "\n") end = kwargs.get("end", "\n")
thread = threading.current_thread() thread = threading.current_thread()
...@@ -48,12 +47,7 @@ def __cprint(*args, **kwargs): ...@@ -48,12 +47,7 @@ def __cprint(*args, **kwargs):
except IndexError: except IndexError:
file_ = kwargs.get("file", sys.stdout) file_ = kwargs.get("file", sys.stdout)
if color: printer_queue.put(PrintResource(content=args, sep=sep, end=end, file=file_, thread=thread))
printer_queue.put(PrintResource(content="\033[{}m".format(colors[color]), end="", file=file_, sep=sep, thread=thread))
printer_queue.put(PrintResource(content=args, end="", file=file_, sep=sep, thread=thread)) # TODO printing text that starts from newline
printer_queue.put(PrintResource(content="\033[0m", sep=sep, end=end, file=file_, thread=thread))
else:
printer_queue.put(PrintResource(content=args, sep=sep, end=end, file=file_, thread=thread))
def print_error(*args, **kwargs): def print_error(*args, **kwargs):
......
...@@ -8,7 +8,7 @@ from functools import wraps ...@@ -8,7 +8,7 @@ from functools import wraps
import routersploit.modules as rsf_modules import routersploit.modules as rsf_modules
import routersploit.resources.wordlists as wordlists import routersploit.resources.wordlists as wordlists
from routersploit.core.exploit.printer import print_error from routersploit.core.exploit.printer import print_error, print_info
from routersploit.core.exploit.exceptions import RoutersploitException from routersploit.core.exploit.exceptions import RoutersploitException
MODULES_DIR = rsf_modules.__path__[0] MODULES_DIR = rsf_modules.__path__[0]
......
...@@ -95,7 +95,7 @@ class TelnetClient(Exploit): ...@@ -95,7 +95,7 @@ class TelnetClient(Exploit):
return None return None
def telnet_close(self, telnete_client): def telnet_close(self, telnet_client):
if telnet_client: if telnet_client:
telnet_client.close() telnet_client.close()
......
from unittest import mock
from flask import request
#from routersploit.modules.exploits.routers.belkin.n750_twonky_rce import Exploit
def apply_response(*args, **kwargs):
return (
"""
TEST
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
sys:x:3:3:sys:/dev:/usr/sbin/nologin
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/usr/sbin/nologin
man:x:6:12:man:/var/cache/man:/usr/sbin/nologin
lp:x:7:7:lp:/var/spool/lpd:/usr/sbin/nologin
mail:x:8:8:mail:/var/mail:/usr/sbin/nologin
news:x:9:9:news:/var/spool/news:/usr/sbin/nologin
uucp:x:10:10:uucp:/var/spool/uucp:/usr/sbin/nologin
proxy:x:13:13:proxy:/bin:/usr/sbin/nologin
www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin
backup:x:34:34:backup:/var/backups:/usr/sbin/nologin
list:x:38:38:Mailing List Manager:/var/list:/usr/sbin/nologin
irc:x:39:39:ircd:/var/run/ircd:/usr/sbin/nologin
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/usr/sbin/nologin
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
systemd-timesync:x:100:102:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
systemd-network:x:101:103:systemd Network Management,,,:/run/systemd/netif:/usr/sbin/nologin
systemd-resolve:x:102:104:systemd Resolver,,,:/run/systemd/resolve:/usr/sbin/nologin
systemd-bus-proxy:x:103:105:systemd Bus Proxy,,,:/run/systemd:/usr/sbin/nologin
_apt:x:104:65534::/nonexistent:/usr/sbin/nologin
mysql:x:105:109:MySQL Server,,,:/nonexistent:/bin/false
epmd:x:106:110::/var/run/epmd:/usr/sbin/nologin
Debian-exim:x:107:111::/var/spool/exim4:/usr/sbin/nologin
uuidd:x:108:113::/run/uuidd:/usr/sbin/nologin
rwhod:x:109:65534::/var/spool/rwho:/usr/sbin/nologin
redsocks:x:110:114::/var/run/redsocks:/usr/sbin/nologin
usbmux:x:111:46:usbmux daemon,,,:/var/lib/usbmux:/usr/sbin/nologin
miredo:x:112:65534::/var/run/miredo:/usr/sbin/nologin
Debian-snmp:x:113:115::/var/lib/snmp:/bin/false
ntp:x:114:116::/nonexistent:/usr/sbin/nologin
stunnel4:x:115:118::/var/run/stunnel4:/usr/sbin/nologin
rtkit:x:116:119:RealtimeKit,,,:/proc:/usr/sbin/nologin
postgres:x:117:120:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash
dnsmasq:x:118:65534:dnsmasq,,,:/var/lib/misc:/usr/sbin/nologin
messagebus:x:119:121::/var/run/dbus:/usr/sbin/nologin
iodine:x:120:65534::/var/run/iodine:/usr/sbin/nologin
arpwatch:x:121:123:ARP Watcher,,,:/var/lib/arpwatch:/bin/sh
sslh:x:122:127::/nonexistent:/usr/sbin/nologin
gluster:x:123:129::/var/lib/glusterd:/usr/sbin/nologin
couchdb:x:124:130:CouchDB Administrator,,,:/var/lib/couchdb:/bin/bash
avahi:x:125:133:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/usr/sbin/nologin
sshd:x:126:65534::/run/sshd:/usr/sbin/nologin
colord:x:127:134:colord colour management daemon,,,:/var/lib/colord:/usr/sbin/nologin
saned:x:128:136::/var/lib/saned:/usr/sbin/nologin
speech-dispatcher:x:129:29:Speech Dispatcher,,,:/var/run/speech-dispatcher:/bin/false
pulse:x:130:137:PulseAudio daemon,,,:/var/run/pulse:/usr/sbin/nologin
Debian-gdm:x:131:139:Gnome Display Manager:/var/lib/gdm3:/bin/false
king-phisher:x:132:140::/var/lib/king-phisher:/usr/sbin/nologin
dradis:x:133:141::/var/lib/dradis:/usr/sbin/nologin
beef-xss:x:134:142::/var/lib/beef-xss:/usr/sbin/nologin
TEST
"""
), 200
#@mock.patch("routersploit.modules.exploits.routers.belkin.n750_twonky_rce.shell")
#def test_check_success(mocked_shell, target)
def test_check_success(target):
""" Test scenario - successful check """
route_mock = target.get_route_mock("/twonky_cmd.cgi", methods=["GET"])
route_mock.side_effect = apply_response
return
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None
#from routersploit.modules.exploits.routers.billion.7700nr4_password_disclosure import Exploit from routersploit.modules.exploits.routers.billion.billion_7700nr4_password_disclosure import Exploit
def test_check_success(target): def test_check_success(target):
""" Test scenario - successful check """ """ Test scenario - successful check """
return
route_mock = target.get_route_mock("/backupsettings.conf", methods=["GET"]) route_mock = target.get_route_mock("/backupsettings.conf", methods=["GET"])
route_mock.return_value = ( route_mock.return_value = (
"test" "test"
......
#from routersploit.modules.exploits.routers.dlink.dlink_auth_bypass import Exploit
def test_check_success(target):
return
""" Test scenario - successful check """
cgi_mock = target.get_route_mock("/", methods=["GET"])
cgi_mock.return_value = (
"test"
"Home/bsc_internet.htm"
"test"
"/public/logout.htm"
"test"
)
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None
from flask import request
#from routersploit.modules.exploits.routers.dlink.multi_hnap_rce_exploit import Exploit
payload = None
def apply_response(*args, **kwargs):
global payload
payload = request.headers['SOAPAction']
return "TEST", 200
def response_func(*args, **kwargs):
global payload
return payload, 200
def test_check_success(target):
return
""" Test scenario - successful check """
global payload
cgi_mock1 = target.get_route_mock("/HNAP1/", methods=["POST"])
cgi_mock1.side_effect = apply_response
cgi_mock2 = target.get_route_mock("/HNAP1/<path:dummy>", methods=["GET"])
cgi_mock2.side_effect = response_func
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None
from flask import request
#from routersploit.modules.exploits.routers.netgear.dgn1000_dgn2200_rce import Exploit
def apply_response(*args, **kwargs):
res = request.args['cmd']
data = "TEST" + res + "TEST"
return data, 200
def test_check_success(target):
return
""" Test scenario - successful check """
route_mock = target.get_route_mock("/setup.cgi", methods=["GET"])
route_mock.side_effect = apply_response
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
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