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
61
62
63
64
from flask import request
from routersploit.modules.exploits.routers.dlink.dir_8xx_password_disclosure import Exploit
def apply_response():
if "A" not in request.args.keys():
response = """
<?xml version="1.0" encoding="utf-8"?>
<postxml>
<result>FAILED</result>
<message>Not authorized</message>
</postxml>
"""
else:
response = """
<?xml version="1.0" encoding="utf-8"?>
<postxml>
<module>
<service>DEVICE.ACCOUNT</service>
<device>
<account>
<seqno></seqno>
<max>2</max>
<count>1</count>
<entry>
<uid></uid>
<name>Admin</name>
<usrid></usrid>
<password>RRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR</password>
<group>0</group>
<description></description>
</entry>
</account>
<group>
<seqno></seqno>
<max></max>
<count>0</count>
</group>
<session>
<captcha>0</captcha>
<dummy></dummy>
<timeout>300</timeout>
<maxsession>128</maxsession>
<maxauthorized>16</maxauthorized>
</session>
</device>
</module>
</postxml>
"""
return response, 200
def test_exploit_success(target):
""" Test scenario - successful exploitation """
cgi_mock = target.get_route_mock("/getcfg.php", methods=["GET", "POST"])
cgi_mock.side_effect = apply_response
exploit = Exploit()
exploit.target = target.host
exploit.port = target.port
assert exploit.check()
assert exploit.run() is None