import asyncio, re
import aiohttp

HOSTS = [("104.156.60.235", 8880, "http"), ("216.70.69.240", 8880, "http"), ("70.32.79.121", 8880, "http")]


async def main():
    tout = aiohttp.ClientTimeout(total=25)
    async with aiohttp.ClientSession(timeout=tout, headers={"User-Agent": "Mozilla/5.0"}) as s:
        for ip, port, sc in HOSTS:
            base = f"{sc}://{ip}:{port}"
            async with s.get(base + "/login_up.php", ssl=False) as r:
                html = await r.text()
            fields = dict(re.findall(r'<input[^>]*name="([^"]+)"[^>]*value="([^"]*)"', html))
            fields.pop("login_name", None)
            fields.pop("passwd", None)
            fields["login_name"] = "admin"
            fields["passwd"] = "definitely-wrong-xyz"
            fields.setdefault("locale_id", "en-US")
            async with s.post(base + "/login_up.php", data=fields, ssl=False, allow_redirects=False) as r2:
                body = await r2.text()
            low = body.lower()
            print(f"== {ip} st={r2.status} len={len(body)} loc={r2.headers.get('Location','')}")
            for kw in ("too many", "captcha", "locked", "incorrect"):
                idx = low.find(kw)
                if idx >= 0:
                    print(f"   {kw!r}: ...{body[max(0,idx-60):idx+80]}...".replace("\n", " "))
            print("   first100:", re.sub(r"\s+", " ", body)[:100])

asyncio.run(main())
