1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from unittest import mock
from routersploit.modules.exploits.routers.netsys.multi_rce import Exploit
etc_passwd = (
"#root:$1$BOYmzSKq$ePjEPSpkQGeBcZjlEeLqI.:13796:0:99999:7:::"
"root:$1$BOYmzSKq$ePjEPSpkQGeBcZjlEeLqI.:13796:0:99999:7:::"
"#tw:$1$zxEm2v6Q$qEbPfojsrrE/YkzqRm7qV/:13796:0:99999:7:::"
)
@mock.patch("routersploit.modules.exploits.routers.netsys.multi_rce.shell")
def test_check_v1_success(mocked_shell, target):
""" Test scenario - successful check via method 1 """
route_mock = target.get_route_mock("/view/IPV6/ipv6networktool/traceroute/ping.php", methods=["GET"])
route_mock.return_value = etc_passwd
exploit = Exploit()
assert exploit.target == ""
assert exploit.port == 9090
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None
@mock.patch("routersploit.modules.exploits.routers.netsys.multi_rce.shell")
def test_check_v2_success(mocked_shell, target):
""" Test scenario - successful check via method 2 """
route_mock = target.get_route_mock("/view/systemConfig/systemTool/ping/ping.php", methods=["GET"])
route_mock.return_value = etc_passwd
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None
@mock.patch("routersploit.modules.exploits.routers.netsys.multi_rce.shell")
def test_check_v3_success(mocked_shell, target):
""" Test scenario - successful check via method 3 """
route_mock = target.get_route_mock("/view/systemConfig/systemTool/traceRoute/traceroute.php", methods=["GET"])
route_mock.return_value = etc_passwd
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None