import subprocess
import time
import os

# Create DOSBox config for automation
dosbox_conf = """[autoexec]
@echo off
mount c C:\\Users\\Roose\\Downloads
c:
peace.com
exit
"""

conf_path = "C:\\Users\\Roose\\Downloads\\dosbox_auto.conf"
with open(conf_path, 'w') as f:
    f.write(dosbox_conf)

# Test different passwords
passwords = [
    'rust',
    'rustinpeace', 
    'r',
    'u',
    's',
    't',
    'megadeth',
    'peace',
    'hangar18',
    '1990',
    '2087',
    'archivist',
    'admin',
    'password'
]

dosbox_path = r"C:\Program Files (x86)\DOSBox-0.74-3\DOSBox.exe"

print("[*] Testing passwords dynamically with DOSBox...")
print("[*] This will require manual interaction\n")

for i, pwd in enumerate(passwords):
    print(f"\n{'='*60}")
    print(f"[{i+1}/{len(passwords)}] Testing password: '{pwd}'")
    print(f"{'='*60}")
    print(f"Steps:")
    print(f"  1. DOSBox will launch")
    print(f"  2. Press a key at the welcome screen")
    print(f"  3. Enter '4' for ADMIN LOGIN")
    print(f"  4. Enter password: '{pwd}'")
    print(f"  5. Note if you get ACCESS GRANTED or ACCESS DENIED")
    print()
    
    input("Press Enter to test this password...")
    
    # Launch DOSBox
    try:
        subprocess.Popen([dosbox_path, r"C:\Users\Roose\Downloads\peace.com"])
        print("[*] DOSBox launched - test the password manually")
        print("[*] Close DOSBox when done")
        time.sleep(2)
    except Exception as e:
        print(f"[!] Error: {e}")
    
    result = input("\nDid it work? (y/n/q to quit): ").lower()
    if result == 'y':
        print(f"\n[+] SUCCESS! The password is: {pwd}")
        break
    elif result == 'q':
        print("[*] Quitting...")
        break
    else:
        print("[-] Failed, trying next password...")

print("\n[*] Dynamic analysis complete")
