๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๐ŸดCTF/Root Me

Root Me - TCP - Back to school

by Janger 2024. 2. 16.
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