BUUCTF RSA2&RSA3 解题思路及公式推导

这篇博客介绍了如何解决BUUCTF中的RSA2和RSA3挑战。对于RSA2,通过分析给定的dp、e、n和c,推导出求解p的公式,并利用迭代找到正确解。对于RSA3,利用共模攻击原理,结合e1、e2、c1、c2和n来解密。解题过程中涉及扩展欧几里得算法和指数运算。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

RSA2

题目

e = 65537

n=248254007851526241177721526698901802985832766176221609612258877371620580060433101538328030305219918697643619814200930679612109885533801335348445023751670478437073055544724280684733298051599167660303645183146161497485358633681492129668802402065797789905550489547645118787266601929429724133167768465309665906113

dp=905074498052346904643025132879518330691925174573054004621877253318682675055421970943552016695528560364834446303196939207056642927148093290374440210503657

c=140423670976252696807533673586209400575664282100684119784203527124521188996403826597436883766041879067494280957410201958935737360380801845453829293997433414188838725751796261702622028587211560353362847191060306578510511380965162133472698713063592621028959167072781482562673683090590521214218071160287665180751

解题思路

题目给出了e,n,dp,c,求解明文

常规的思路是将n分解为p和q,但是这里给的n有309位之长,直接爆破求解显然难度很大

可以关注到题目所给的dp,看一下这个dp怎么用

进行一下公式推导:

dp = d % (p-1) ①

d = dp + k1 * (p-1) ②

d * e = 1 + k2(p-1)(q-1) ③

把②代入③,得到

e * (dp + k1(p-1)) = 1 + k2(p-1)(q-1)

为把系数k消掉,两边同时对(p-1)取模

e * dp % (p - 1) = 1

e * dp = 1 + k(p - 1)

由③就可以导出p与e、dp的关系

p - 1 = (e * dp - 1) / k

但是这里引入了一个系数k,这个k该怎么处理呢

④变形一下有

k = (e * dp - 1) / (p-1)

又由①,可以判断出dp < (p-1)

所以可以得到k = (e * dp - 1) / (p-1) < e

e = 65537,因此k的范围有了约束

至此,根据④式可以求解p

具体思路如下:

  • 1.遍历k,k的范围是(1-6

### BUUCTF RSA3 Challenge Solution Overview For tackling the BUUCTF RSA3 challenge, understanding both theoretical foundations and practical approaches is essential. The recommended RSA key sizes depend on the confidentiality period of the data being protected[^1]. However, this information alone does not directly apply to solving CTF challenges but provides context regarding RSA security. In practice, increasing RSA key length enhances encryption security but significantly impacts performance since each doubling of the key length makes decryption 6-7 times slower[^2]. To solve an RSA-based CTF challenge like RSA3 from BUUCTF: #### Analyzing Common Vulnerabilities CTFs often exploit specific vulnerabilities within implementations rather than brute-forcing keys due to computational impracticality. Common issues include poor random number generation leading to weak primes during modulus creation or side-channel attacks exploiting implementation flaws. #### Exploiting Implementation Flaws One approach involves identifying weaknesses in how RSA was implemented for the challenge. For instance, if non-standard padding schemes were used, these might introduce exploitable patterns into ciphertexts which could be decrypted without knowing private exponents through chosen-ciphertext attacks. #### Utilizing Known Attacks Several well-documented attacks against RSA exist when certain conditions are met by flawed implementations: - **Common Modulus Attack**: If multiple users share a common modulus with different public/private exponent pairs. - **Small Exponent Attack**: When small values such as e=3 are employed alongside improperly padded messages allowing cube root extraction. - **Wiener’s Attack**: Targets cases where d (private exponent) is too short relative to n (modulus). Given that direct solutions cannot be provided here, exploring resources related to these topics would prove beneficial. Additionally, reviewing past write-ups about similar challenges can offer valuable insights into methodologies applied successfully before. ```python from Crypto.Util.number import inverse, long_to_bytes import gmpy2 def attack_rsa(e, N, c): # Placeholder function demonstrating structure; actual logic depends heavily upon specifics found via analysis phi_approximation = ... # Calculate based on any discovered weakness d = inverse(e, phi_approximation) m = pow(c, d, N) plaintext = long_to_bytes(m).decode() return plaintext ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值