test_asuswrt_lan_rce.py 644 Bytes
from unittest import mock
from routersploit.modules.exploits.routers.asus.asuswrt_lan_rce import Exploit


@mock.patch("routersploit.modules.exploits.routers.asus.asuswrt_lan_rce.shell")
def test_check_success(mocked_shell, target):
    """ Test scenario - successful check """

    route_mock = target.get_route_mock("/vpnupload.cgi", methods=["POST"])
    route_mock.return_value = (
        "<HTML><HEAD><script>top.location.href='/Main_Login.asp';</script>\n</HEAD></HTML>\n"
    )

    exploit = Exploit()
    exploit.target = target.host
    exploit.port = target.port

    assert exploit.check() is None
    assert exploit.run() is None