Tags: crypto 

Rating:

From the description

![](https://i.imgur.com/vuFoM3X.png)

we have a flag.png , open it and get a QR code

![](https://i.imgur.com/wC6gKsM.png)

scan the code and will return a string.
```
aHR0cHM6Ly9kcml2ZS5nb29nbGUuY29tL2ZpbGUvZC8xRDBtTkp0YThkRFRDY2VCREkycG9YS3AyYlJhMEcya0Ivdmlldz91c3A9c2hhcmluZw==
```

it looks like base64, decode it using [cyberchef](https://gchq.github.io/CyberChef/#input=YUhSMGNITTZMeTlrY21sMlpTNW5iMjluYkdVdVkyOXRMMlpwYkdVdlpDOHhSREJ0VGtwMFlUaGtSRlJEWTJWQ1JFa3ljRzlZUzNBeVlsSmhNRWN5YTBJdmRtbGxkejkxYzNBOWMyaGhjbWx1Wnc9PQ), it returns a link.

![](https://i.imgur.com/Qw6rUBU.png)

Open the link, and download the file.

![](https://i.imgur.com/M1poG8N.png)

it's a stream of binary data.

Also, we use [cyberchef](https://gchq.github.io/CyberChef/#recipe=From_Binary('Space',8)&input=MDExMDAwMTEgMDAxMDAwMDAgMDAxMTExMDEgMDAxMDAwMDAgMDAxMTAxMTEgMDAxMTAxMDAgMDAxMTAwMTAgMDAxMTAxMDAgMDAxMTAxMTAgMDAxMTEwMDEgMDAxMTEwMDEgMDAxMTAwMTAgMDAxMTAwMTEgMDAxMTEwMDAgMDAxMTAxMTAgMDAxMTAxMDAgMDAxMTAxMTAgMDAxMTEwMDEgMDAxMTAxMDEgMDAxMTAxMDEgMDAxMTAwMTAgMDAxMTAwMDAgMDAxMTAwMDEgMDAxMTAwMTEgMDAxMTAxMTEgMDAxMTAwMDAgMDAxMTAxMTAgMDAxMTEwMDEgMDAxMTAxMDEgMDAxMTAwMTAgMDAxMTAwMDEgMDAxMTAwMTEgMDAxMTAxMDAgMDAxMTAwMTEgMDAxMTAwMDEgMDAxMTEwMDEgMDAxMTEwMDAgMDAxMTAxMTEgMDAxMTAxMTAgMDAxMTAxMTEgMDAxMTAwMDEgMDAxMTAwMDEgMDAxMTAxMDA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AxMTAwMTAgMDAxMTEwMDEgMDAxMTAwMTEgMDAxMTAwMTEgMDAxMTAwMTAgMDAxMTAxMDEgMDAxMTAxMDAgMDAxMTEwMDEgMDAxMTAxMDAgMDAxMTAwMDEgMDAxMTAxMDEgMDAxMTAxMTAgMDAxMTEwMDAgMDAxMTAwMDAgMDAxMTAxMDEgMDAxMTAxMTAgMDAxMTEwMDAgMDAxMTEwMDEgMDAxMTEwMDEgMDAwMDEwMTAgMDExMDAxMDEgMDAxMDAwMDAgMDAxMTExMDEgMDAxMDAwMDAgMDAxMTAwMDAgMDExMTEwMDAgMDAxMTAwMDEgMDAxMTAwMDAgMDAxMTAwMDAgMDAxMTAwMDAgMDAxMTAwMDE) to decode it . And it outputs

![](https://i.imgur.com/Iw54sTj.png)

So, apparantly it is a RSA cipher. And we have a Modulo N which is not so big. So we could factor it directly using [this](https://www.alpertron.com.ar/ECM.HTM).

Now we have p and q
```
p="121588 253559 534573 498320 028934 517990 374721 243335 397811 413129 137253 981502 291629 "
q="121588 253559 534573 498320 028934 517990 374721 243335 397811 413129 137253 981502 291631 "

p = int(p.replace(" ",""))
q = int(q.replace(" ",""))
print(p)
print(q)

```

So we could calculate Euler phi(n) and compute the inverse of e modulo phi(n)

```
phin = (p-1) * (q -1)
print(phin)

'''
14783703403657671882600600446061886156235531325852194800287001788765221084107387976823539256683446492107102048156712604120787224153025694658746978563473640
'''

import gmpy2
e = 65537
d = gmpy2.invert(e, phin)
print(d)
'''
3299077807627652338114863077706564002547334263707346215942099900219591350764767217923375522666515173826485305312906020038550943028182565335370471054378473
'''
```

Now we can do the decryption

```
c = 7424699238646955201370695213431987671142812230143306867560482933056266299380926684689129315498363439046922143979269386180477235672715428337919573885741855
n = 14783703403657671882600600446061886156235531325852194800287001788765221084107631153330658325830443132164971084137462046607458019775851952933254941568056899

m = pow(c,d,n)
print(m)

'''
384381784108403635336803492209858541007704056957
'''

from Crypto.Util.number import *
mbytes = long_to_bytes(m)
print(mbytes)

'''
b'CTF{r0n_4D1_130N4rd}'
'''
```

Got it!