728x90
๋ฐ์ํ
๋ฌธ์ ๋ด์ฉ
์ซ์ 1์ ์ ๊ณฑ๊ทผ์ ๊ณ์ฐํ๊ณ ์ซ์ 2๋ฅผ ๊ณฑํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ ๊ฒฐ๊ณผ๋ฅผ ์์์ ์ดํ ๋ ์๋ฆฌ๋ก ๋ฐ์ฌ๋ฆผํฉ๋๋ค.
ํ๋ก๊ทธ๋จ์ด ๊ณ์ฐ์ ๋ณด๋ธ ์๊ฐ๋ถํฐ 2์ด ์ด๋ด์ ์ ๋ต์ ๋ณด๋ด์ผ ํฉ๋๋ค.
๋ต์ ๋ค์๊ณผ ๊ฐ์ ํ์์ผ๋ก ๋ณด๋ด์ผ ํฉ๋๋ค.
์ ๋ต ์ฝ๋
"""
To start this test using the TCP protocol, you need to connect to a program on a network socket.
Calculate the square root of number 1 and multiply by number 2.
Then round the result to two decimal places.
You have 2 seconds to send the correct answer from the moment the program sends you the calculation.
The answer must be sent in the form of int
Challenge connection informations
Host challenge01.root-me.org
Protocol TCP
Port 52002
"""
import socket
import math
def main():
host = "challenge01.root-me.org"
port = 52002
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((host, port))
data = s.recv(1024)
print(data.decode())
number1 = data.decode().split('Calculate the square root of ')[1][:3]
print(number1)
number2 = data.decode().split('and multiply by ')[1][:4]
print(number2)
result = round(math.sqrt(int(number1)) * int(number2), 2)
print(result)
result = str(result)+'\n'
s.sendall(result.encode())
print("Sent", result)
data = s.recv(1024)
print(data.decode())
if __name__ == "__main__":
main()
728x90
๋ฐ์ํ
'๐ดCTF > Root Me' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Root Me - TCP - Encoded string (1) | 2024.02.16 |
---|---|
Root Me - Encoding - ASCII (0) | 2024.02.16 |
Root Me - CSP Bypass - Inline code (0) | 2024.02.15 |