The force is with those who read the source.

Internetwache CTF 2016: It's Prime Time! (code 60)

2016-03-03

Description

We all know that prime numbers are quite important in cryptography. Can you help me to find some?

Exploit

In this challenge, we have to find the next prime to a given number 100 times to get the flag. The questions are in the following format.

Level 1.: Find the next prime number after 8:

There is a nextprime function in SymPy, so we can solve this problem easily.

solve.pydownload
1
2
3
4
5
6
7
8
9
10
11
from sympy import nextprime
from pwnlib.tubes.remote import remote

r = remote('188.166.133.53', 11059)

while True:
lines = r.recvlines(2)
print '\n'.join(lines)
p = nextprime(lines[1].split()[8][:-1])
print p
r.send(str(p))

Flag: IW{Pr1m3s_4r3_!mp0rt4nt}


Blog comments powered by Disqus