import asyncio
import aiohttp

def load_err():
    out = []
    for line in open("/root/recon/plesk_login_sizes.tsv"):
        p = line.rstrip("\n").split("\t")
        if len(p) >= 5 and p[4] == "0":
            out.append((p[0], int(p[1]), p[2]))
    return out

async def main():
    err = load_err()
    print("err hosts", len(err))
    sample = err[:12]
    tout = aiohttp.ClientTimeout(total=20, connect=8, sock_read=12)
    async with aiohttp.ClientSession(timeout=tout, headers={"User-Agent": "Mozilla/5.0"}) as s:
        for ip, port, base in sample:
            for b in ([base] if base else []) + [f"http://{ip}:{port}", f"https://{ip}:{port}"]:
                try:
                    async with s.get(b + "/login_up.php", ssl=False) as r:
                        t = await r.text()
                    print(f"{ip:16s} {b:24s} -> {r.status} len={len(t)}")
                    break
                except Exception as e:
                    print(f"{ip:16s} {b:24s} -> ERR {type(e).__name__}")

asyncio.run(main())
