> For the complete documentation index, see [llms.txt](https://giongfnef.gitbook.io/ctf-2021/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://giongfnef.gitbook.io/ctf-2021/ctf2021-8/grabcon-ctf-2021-notrsa.md).

# GrabCon CTF 2021 - NotRSA

```python
from math import sqrt
import random
from Crypto.Util.number import bytes_to_long


N = 2433984714450860961589027518159810370561856716063956157321856705975948489337570445957833120668443867975490363019335530343179129689501017626817947777263721
c = 1378297008929492435762470180953416238081302819750327089183697281160938504327642742017058360280755400054663296904328307673692314945545918393502459480987913
a = int(sqrt(N) + 1)
b = random.randint(0,9999999999)

flag = b"REDACTED"
m = bytes_to_long(flag)

c = ((a**m)*(b**(a-1)))%((a-1)*(a-1))

```

It's not RSA , of course broooooooooooooooooo. Try [Paillier cryptosystem](https://en.wikipedia.org/wiki/Paillier_cryptosystem) for instead :<

```python
from math import sqrt
import random
from Crypto.Util.number import *

phi = 49335430619898930416886440294125273227060654497185988935450212291095389910400 
n = 49335430619898930416886440294125273227508793331445421957576671205000501326189
u = pow(phi,-1, n) 
c = 1378297008929492435762470180953416238081302819750327089183697281160938504327642742017058360280755400054663296904328307673692314945545918393502459480987913
N = 2433984714450860961589027518159810370561856716063956157321856705975948489337570445957833120668443867975490363019335530343179129689501017626817947777263721
print(long_to_bytes((((pow(c,phi,N)-1)//n) * u % n)))

#b'GrabCON{i75_p4ill13r_f0lks}'
```

[Writeup](https://hackmd.io/@Electro/GrabCon21)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://giongfnef.gitbook.io/ctf-2021/ctf2021-8/grabcon-ctf-2021-notrsa.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
