import urllib.parse
import re

with open('readflag_response.html', 'r', encoding='utf-8') as f:
    content = f.read()

# Find the ajax_error_500 line
match = re.search(r'ajax_error_500 = "([^"]*)"', content)
if match:
    error_msg = match.group(1)
    print("Error message:", error_msg)
    
    # Decode HTML entities
    error_msg = error_msg.replace('\\u003ca href=\\"', '<a href="')
    error_msg = error_msg.replace('\\"\\u003e', '">')
    
    # Extract URL
    url_match = re.search(r'href="([^"]+)"', error_msg)
    if url_match:
        url = url_match.group(1)
        print("\nURL (encoded):", url)
        print("\nURL (decoded):", urllib.parse.unquote(url))
    else:
        print("No URL found")
else:
    print("No ajax_error_500 found")

# Also just search for uoftctf directly
if 'uoftctf' in content.lower():
    print("\n[!!!] 'uoftctf' found in response!")
    idx = content.lower().find('uoftctf')
    print("Context:", content[idx:idx+100])
