Greenest-Guy/RSA-CTF-Writeups
GitHub: Greenest-Guy/RSA-CTF-Writeups
收录来自 PicoCTF 和 CyLab Security Academy 的 RSA 密码学挑战详细解题解析,涵盖数学漏洞分析与难度排名。
Stars: 3 | Forks: 0
# 🔐 RSA CTF Writeups
*来自 PicoCTF/CyLab Security Academy 的 RSA 密码学挑战解析合集*
## 📖 关于
本仓库包含了针对 CyLab Security Academy 中各种以 RSA 为重点的密码学挑战的详细解析。每篇解析都会介绍挑战的设置、解题步骤,以及对所利用的数学漏洞的技术说明。
## 🚩 挑战 (我的难度排名)
| 排名 | 挑战 | 难度评分 (0-100) | 等级 |
|------|-----------|-------|------|
| 1 | [```Sum-O-Primes```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/Sum-O-Primes.md) | 72 | 困难 |
| 2 | [```b00tl3gRSA3```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/b00tl3gRSA3.md) | 68 | 困难 |
| 3 | [```rsa-pop-quiz```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/rsa-pop-quiz.md) | 65 | 困难 |
| 4 | [```ClusterRSA```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/ClusterRSA.md) | 60 | 困难 |
| 5 | [```college-rowing-team```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/college-rowing-team.md) | 50 | 中等 |
| 6 | [```miniRSA```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/miniRSA.md) | 46 | 中等 |
| 7 | [```Crack the Power```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/Crack_the_Power.md) | 46 | 中等 |
| 8 | [```b00tl3gRSA2```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/b00tl3gRSA2.md) | 40 | 中等 |
| 9 | [```StegoRSA```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/StegoRSA.md) | 30 | 简单 |
| 10 | [```EVEN RSA CAN BE BROKEN???```](https://github.com/Greenest-Guy/RSA-CTF-Writeups/blob/main/challenges/EVEN_RSA_CAN_BE_BROKEN%3F%3F%3F.md) | 28 | 简单 |
## 🧮 RSA 数学基础
RSA 密码体制的安全性在于将大模数分解为其原始素数因子的难度。RSA 密钥是使用大素数因子生成的,并利用模运算来加密和解密消息。
### 密钥生成
首先,必须选择两个不同的大素数 $p$ 和 $q$
然后可以构造模数 $n$:
$$n = p \cdot q$$
接着使用快捷公式计算 [欧拉函数](https://en.wikipedia.org/wiki/Euler%27s_totient_function) $\phi (n)$:
$$\phi (n) = (p - 1)(q - 1)$$
接下来,必须选择公开指数 $e$,使得:
$$1 < e < \phi (n) \land \gcd(e, \phi (n)) = 1$$
最后,用于解密的私有指数 $d$ 计算如下:
$$d = e^{-1} \mod \phi (n) $$
### 加密与解密
使用公开指数 $e$ 和模数 $n$,将明文消息 $m$ 加密为密文 $c$:
$$c = m^e \mod n$$
相反,使用私有指数 $d$ 和模数 $n$ 来解密密文:
$$m = c^d \mod n$$
### 原理解析
由于私有指数 $d$ 是公开指数 $e \mod \phi(n)$ 的模逆元,我们有:
$$e \cdot d \equiv 1 \pmod{\phi(n)}$$
根据 [欧拉定理](https://en.wikipedia.org/wiki/Euler%27s_theorem):
$$m^{\phi(n)} \equiv 1 \pmod{n}$$
对于任意与 $n$ 互质的 $m$,这给出:
$$c^d = (m^e)^d = m^{e \cdot d} = m^{k \cdot \phi(n) + 1} \equiv m \pmod{n}$$标签:RSA算法, Writeup, 安全竞赛, 密码学, 手动系统调用, 数学漏洞, 防御加固