#!/usr/bin/env python3
import subprocess
import sys

# Common flag formats to try
flags = [
    "BABY",
    "Baby",
    "baby",
    "flag{baby}",
    "FLAG{BABY}",
    "FLAG{BABY_REV}",
    "CTF{BABY}",
    "rev{baby}",
    "REV{BABY}",
    "bab y",
    "B.A.B.Y",
    "0x62616279",  # BABY in hex
]

for flag in flags:
    print(f"Testing: {flag}")
    try:
        result = subprocess.run(
            ["python", "baby.py"],
            input=flag,
            capture_output=True,
            text=True,
            timeout=2
        )
        output = result.stdout + result.stderr
        
        if "not the flag" in output:
            print(f"  ❌ Not the flag")
        elif "that's it" in output.lower() or "correct" in output.lower():
            print(f"  ✅ FOUND IT!")
            print(output)
            sys.exit(0)
        else:
            # No error message means maybe it was correct?
            if result.returncode == 0:
                print(f"  ? No error message (might be correct)")
                print(f"    Output: {output[:200]}")
    except Exception as e:
        print(f"  Error: {e}")

print("\nTrying more variations...")
# Try different lengths and patterns
for length in [4, 5, 6, 7, 8]:
    # Try all uppercase
    test = "A" * length
    print(f"Testing: {test}")
    try:
        result = subprocess.run(
            ["python", "baby.py"],
            input=test,
            capture_output=True,
            text=True,
            timeout=2
        )
        if "not the flag" not in result.stdout and "not the flag" not in result.stderr:
            if result.returncode == 0:
                print(f"  ✅ Possible match!")
                print(result.stdout)
    except:
        pass
