Programming
TCP - Back to school (It should work but it doesnt)
I’ve got some code for "TCP - Back to school" challenge, and it should work because i calculate everything correctly and send the server back the response. But i don’t recieve nothing back from the server.
For example when the server sends me: "Calculate the square root of 761 and multiply by 3920 =", i send the server "108138.02" within 2 seconds, so it should work, but it doesn’t. I tried also sending it as an int 108138, but
it didn’t work. Why i don’t recieve any message from the server after sending the response?
TCP - Back to school (It should work but it doesnt)
You can try to add terminator string characters and send message to server: s.send((password + "\r\n").encode())
After this you can receive new messages from server, for example: s.recv(4096)
TCP - Back to school (It should work but it doesnt)
i dont know how to start. i click the link and the new web does not do not thing . have i to code in some where like visual studio code or something. i just start a first changlle here . i need some help
TCP - Back to school (It should work but it doesnt)
Hello @Tetrospectiva,
As stipulated in the rules of root-me, it is strictly forbidden to divulge the answers of the challenges. As a result, your account will be automatically banned in 7 days (i.e. Saturday, September 2 at 12:00 p.m.). Deleting all solutions interrupts the banishment. Thanks.
TCP - Back to school (It should work but it doesnt)
I built this code but it still does not work I am getting empty final massage , even tho it tells me its wrong answer even tho its not wrong
import socket
import time
def communicate_with_server():
# Define the server’s IP address and port
server_ip = ’challenge01.root-me.org’
server_port = 52002
# Create a socket object
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
# Set a timeout value (e.g., 10 seconds)
client_socket.settimeout(10.0)
# Connect to the server
client_socket.connect((server_ip, server_port))
print(f"Connected to server_ip:server_port")
# Receive the initial message from the server
initial_message = client_socket.recv(1024).decode(’utf-8’)
print(f"Received initial message: initial_message")
# Extract numbers from the initial message
numbers = [float(num) for num in initial_message.split() if num.replace(’.’, ’’, 1).isdigit()]
print(f"Extracted numbers: numbers")
# Record the start time
start_time = time.time()
# Perform the specified calculation
result = round((numbers[1]**0.5 * numbers[2]) / 2, 2)
integer_result = int(result)
print(f"Calculated result: result")
# Send the result to the server immediately
client_socket.sendall(str(integer_result).encode(’utf-8’) b’n’) # Sending integer part as a string
print(f"Sent result to the server: integer_result")
# Wait for the server’s response
response = client_socket.recv(1024).decode(’utf-8’)
print(f"Received response: response")
# Record the end time
end_time = time.time()
# Calculate the elapsed time
elapsed_time = end_time - start_time
print(f"Elapsed time: elapsed_time seconds")
# Adjust the timing threshold based on your observations
timing_threshold = 2.5 # Set a value slightly higher than the expected time
if elapsed_time > timing_threshold:
print("Warning: Elapsed time exceeded the expected threshold.")
# Send the result back to the server
client_socket.sendall(str(integer_result).encode(’utf-8’) b’n’) # Sending integer part as a string
print(f"Sent result back to server: integer_result")
# Wait for the final response from the server
final_response = client_socket.recv(1024).decode(’utf-8’)
print(f"Received final response: repr(final_response)", flush=True)
except socket.timeout:
print("Timeout: No response from the server within the specified time.")
except Exception as e:
print(f"Error: e")
finally:
# Close the socket connection
client_socket.close()
print("Connection closed")
# Call the function to run the communication
communicate_with_server()