“Winning Factors” by syyntax is a speed scripting task. Connect to a remote server, parse a factorial prompt, compute the answer, and reply within 3 seconds — repeatedly — until the flag appears.
WINNING FACTORS
No files provided. Interact directly with the remote service and solve on the fly.
import socket
import re
from math import factorial
def calculate_factorial(n):
try:
return factorial(n)
except ValueError as e:
print(f"Error calculating factorial: {e}")
return None
def connect_and_solve():
host = "147.182.245.126"
port = 33001
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(5)
s.connect((host, port))
try:
while True:
data = s.recv(1024).decode().strip()
if not data:
continue
print(f"Received: '{data}'")
if "flag{" in data:
print("Found flag:", data)
break
number_match = re.search(r'factorial of (\d+)\.?', data)
if number_match:
number = int(number_match.group(1))
answer = calculate_factorial(number)
if answer is not None:
response = str(answer)
print(f"Sending answer: {response}")
s.send(response.encode())
feedback = s.recv(1024).decode().strip()
print(f"Server response: '{feedback}'")
except socket.timeout:
print("Socket timeout occurred")
except Exception as e:
print(f"Error occurred: {e}")
finally:
s.close()
if __name__ == "__main__":
connect_and_solve()
flag{1ntr0_f4ct0r14l_5t3p}