---
layout: post
title: "DeconstruCT.F 2021 | CRYPTO | RSA-1"
date: 2021-10-03 13:37:00 +0700
tags: [ctf, writeup]
---
<figure>
<img src="https://cdn.discordapp.com/attachments/874145963407720513/894206917239513118/Group.png">
</figure>
#### CRYPTO | RSA-1 (150 points | 191 solves)
Challenge Description:
```
I have a lot of big numbers. Here, have a few!
```
We're given the following file (`big_numbers.txt`):
```python
Ever used RSA Encryption?
cyphertext = 10400286653072418349777706076384847966640064725838262071
n = 23519325203263800569051788832344215043304346715918641803
e = 71
```
Solution:<br>
There, we can see it uses an encryption system known as RSA. Usually, you will have much larger n, but in this case n is very small thus we can factor it using sage and decrypt the ciphertext
Sage Solver:
```python
from Crypto.Util.number import long_to_bytes as l2b, inverse
c = 10400286653072418349777706076384847966640064725838262071
n = 23519325203263800569051788832344215043304346715918641803
e = 71
(p, _), (q, _) = factor(n)
phi = (p-1)*(q-1)
d = inverse(e, phi)
print(l2b(pow(c, d, n)))
```
FLAG : **dsc{t00_much_m4th_8898}**