Skip to content

UofTCTF 2025

n1ght0w1
Published date:
1 min read
UofTCTF 2025
1 challs
Misc1

UofTCTF 2025

Misc

Math Test

題目有 1000 題數學題,寫 script 去解題

import socket
import re
import time

server_ip = "34.66.235.106"
server_port = 5000

sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
    sock.connect((server_ip, server_port))
    print(f"Connected to {server_ip}:{server_port}")

    time.sleep(2)

    while True:
        output = sock.recv(1024).decode()
        if output:
            print(f"Received: {output}")

            match = re.search(r"Question: (.*)", output)
            if match:
                question = match.group(1)
                print(f"Solving: {question}")

                try:
                    res = eval(question)
                    print(f"Answer: {res}")

                    sock.sendall(f"{res}\n".encode())

                    time.sleep(1)
                except Exception as e:
                    print(f"Error calculating answer: {e}")
                    break
            else:
                print("No question found, exiting.")
                break
        else:
            print("No output received.")
            break
except Exception as e:
    print(f"Error connecting to server: {e}")
finally:
    sock.close()

print("Test completed.")

flag

uoftctf{7h15_15_b451c_10_7357_d16u153d_45_4_m47h_7357}
Previous
TSC CTF 2025
Next
IRON CTF 2024