247CTF solution: The flag lottery

We have python code of the server, it will generate a random number.

We will use code like the server to generate a number, I use python code for this challenge.

import socket, random, time

hostname = '612bfbe1b57837f1.247ctf.com' #Change this
port = 50066 #Change this

# Connect to server
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
data = s.recv(1024)
print("Received:", repr(data))
# Can you guess the number to win the flag lottery?

#Submit number
secret = random.Random()
secret.seed(int(time.time())) 
winning_choice = str(round(secret.random(),12))
s.sendall(bytes(winning_choice.encode("utf-8")))
print("Choice: ", winning_choice)

# Response from server    
data = s.recv(1024)
print("Received:", repr(data))
data = s.recv(1024)
print("Received:", repr(data))

# Close connection
print("Connection closed.")
s.close()

Leave a comment

Design a site like this with WordPress.com
Get started