[Easy] Suma kwadratów
Serwer generuje losową liczbę, która jest sumą kwadratów dwóch liczb naturalnych. Twoim zadaniem jest odnalezienie tych dwóch liczb. Masz na to trzy sekundy.
For this challenge we’re given a remote server address that we have to connect to.
1
2
3
4
5
6
7
8
Hello! Here's a math riddle for you:
a * a + b * b = 246925456164
Tell me the values of a and b given that both are natural numbers.
(pass both numbers in a single line separated by space;
you have only a couple of seconds)
>
The server disconnects us after few seconds but at least we know what to do.
We can utilize sagemath’s two_squares
function to perform the necessary calculations for us and just handle sending the results back.
1
2
3
4
5
6
7
8
9
10
11
from pwn import *
p = remote('192.46.238.236', 1337)
p.recvuntil(b' = ')
num = int(p.recvline().decode().strip())
p.recvuntil(b' > ')
a, b = two_squares(num)
p.sendline(f'{a} {b}')
p.interactive()
And with that, we get the flag
1
Here's your flag: CTF_NumberTheoryIsNeat