Cover Image

pico CTF Web Cryptography

 November 30, 2021    CTF

Mod 26

The flag picoCTF{next_time_I'll_try_2_rounds_of_rot13_wqWOSBKW} was ROT 13 encoded and can be solved with CyberChef.


13

The flag picoCTF{not_too_bad_of_a_problem} was ROT 13 encoded and can be solved with CyberChef.


The Numbers

We get the flag picoCTF{thenumbersmason} by writing down the letters corresponding to the nth place in the alphabet.

corresp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
cipher =['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26']
enflag = '16 9 3 15 3 20 6 { 20 8 5 14 21 13 2 5 18 19 13 1 19 15 14 }'
deflag = ''

for i in range(len(enflag)):
    if enflag[i] == '{':
            deflag += '{'
            continue
    elif enflag[i] == '}':
            deflag += '}'
            continue
    elif enflag[i] == ' ':
            deflag += ' '
            continue
    for j in range(len(cipher)):
        if enflag[i] == cipher[j]:
            deflag += corresp[j]

print(deflag)


Mind your Ps and Qs

We need the factors P and Q of N to crack the encryption. Since N is relatively small, this can be calculated. Fortunately, someone has already done this and published the result on FactorDB. Using the factors, we can decode the flag using the following python script.

from Crypto.Util.number import *

n = 1584586296183412107468474423529992275940096154074798537916936609523894209759157543
q = 2434792384523484381583634042478415057961
p = 650809615742055581459820253356987396346063
c = 964354128913912393938480857590969826308054462950561875638492039363373779803642185
e = 65537

# decrypt
d = inverse(e,(p-1)*(q-1))
m = pow(c,d,p*q)
print("Message: ", long_to_bytes(m))

\\ picoCTF{sma11_N_n0_g0od_73918962}