A Python tool to exploit the weak RSA case where N is even (p = 2, q = N/2).
It works with local files or directly with remote CTF challenge servers (netcat-style).
- Python 3.8+
- No external libraries (only Python standard library).
python3 rsa_evenN_cracker_tool.py input.txtThe file may contain:
N=12345678901234567890
e=65537
c=98765432109876543210
or Python-style:
N = 12345678901234567890
e = 65537
c = 98765432109876543210or with colons:
N: 12345678901234567890
e: 65537
cyphertext: 98765432109876543210
Connect to a remote challenge server like with nc host port:
python3 rsa_evenN_cracker_tool.py -n verbal-sleep.picoctf.net 53671The tool will capture the output (e.g. N: ..., e: ..., cyphertext: ...), factor N, compute d, and print the plaintext.
-
Pretty output (default):
== Case #1 == N (even) = ... e = 65537 q = N//2 = ... phi = ... m (int) = ... plaintext (utf-8): picoCTF{flag_here} -
Raw plaintext only (good for piping):
python3 rsa_evenN_cracker_tool.py input.txt -r
-
Escape non-UTF8 bytes:
python3 rsa_evenN_cracker_tool.py input.txt -r -x
-
Verbose (debug) mode — show the raw captured server/file text before parsing:
python3 rsa_evenN_cracker_tool.py -n verbal-sleep.picoctf.net 53671 -v
python3 rsa_evenN_cracker_tool.py encrypt.txtOutput:
== Case #1 ==
N (even) = 188548530
e = 65537
q = N//2 = 94274265
phi = 94274264
m (int) = 1122334455
plaintext (utf-8): picoCTF{tw0_1$_pr!m378257f39}
python3 rsa_evenN_cracker_tool.py -n verbal-sleep.picoctf.net 53671 -rOutput:
picoCTF{flag_here}
- Only solves RSA when
Nis even (p=2). - If
Nis odd (normal RSA), the script will refuse to solve. - In netcat mode, the tool only receives data — it does not automatically send the cracked flag back to the server (you copy-paste manually).
| Option | Description |
|---|---|
file |
Input file containing N/e/c values |
-n host port |
Connect to a challenge server (netcat mode) |
-r |
Print only plaintext (raw mode) |
-x |
Escape invalid UTF-8 characters |
-v |
Show raw captured text (useful for debugging parsing) |