QIWI CTF 2016 - PPC 100_2
Category: writeupsTags: ppc qiwictf-2016
PPC 100_2
PPC - 100 Points
Those spies learned in university that prime numbers are essential for cryptography. Unfortunately, they got in wrong.
A tar.gz file is given.
ls -al
# [...]
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37862856821
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37866013807
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37867037921
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37867265659
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37867333033
#-rw-rw-r-- 1 thezero thezero 2 nov 12 07:50 37867839719
# [...]
ls -1 | wc -l
# 23125
Writeup
We started this challenge after the PPC 100_1 so we knew how to proceeds.
cat ./17355543683
# c
Every filename was an integer and the content a single hexadecimal character
If the description tell us that they got prime numbers in wrong, maybe we should concat the content of prime filename.
#!/usr/bin/env sage -python
from sage.all import *
primes = []
flag = ""
for m in os.listdir("./encrypted"):
if is_prime(m):
primes.append(m)
primes = sorted(primes)
#print primes
for p in primes:
with open(os.path.join("./encrypted",p),"r") as fp:
flag += fp.read().rstrip()
print flag
# c93c0f30299130cde942fce8ec5dd0b3012dcfa478a4ab2314ee525098fb779e2812d6731d372bae6d71e220a6
After some fight with the CTF’s website (it was reporting wrong flag :( ) we finally got our points!