BUUCTF Crypto SameMod wp
2020-04-22 00:15
1051 查看
这道题一看题目SameMod就可以猜到是RSA中的共模攻击
关于共模攻击的原理这里就不多赘述了,可以参考ctfwiki
https://wiki.x10sec.org/crypto/asymmetric/rsa/rsa_module_attack
下面直接给出本题脚本
// python2 from gmpy2 import invert def gongmogongji(n, c1, c2, e1, e2): def egcd(a, b): if b == 0: return a, 0 else: x, y = egcd(b, a % b) return y, x - (a // b) * y s = egcd(e1, e2) s1 = s[0] s2 = s[1] if s1 < 0: s1 = - s1 c1 = invert(c1, n) elif s2 < 0: s2 = - s2 c2 = invert(c2, n) m = pow(c1, s1, n) * pow(c2, s2, n) % n return m n= 6266565720726907265997241358331585417095726146341989755538017122981360742813498401533594757088796536341941659691259323065631249 e1= 773 e2= 839 c1= 3453520592723443935451151545245025864232388871721682326408915024349804062041976702364728660682912396903968193981131553111537349 c2= 5672818026816293344070119332536629619457163570036305296869053532293105379690793386019065754465292867769521736414170803238309535 result = gongmogongji(n, c1, c2, e1, e2) print(result) #1021089710312311910410111011910111610410511010710511610511511211111511510598108101125 #flag=hex(result)[2:].decode('hex') result=str(result) flag="" i=0 while i < len(result): if result[i]=='1': c=chr(int(result[i:i+3])) i+=3 else: c=chr(int(result[i:i+2])) i+=2 flag+=c print(flag) #flag{whenwethinkitispossible}
做这题的时候一开始想到是将明文进行hex的,试了一下发现不对,才通过ascii的方式解得,flag需要是可见字符,所以不存在1开头的十位数,所以1开头的肯定是100以上的三位数,由此可解得flag
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- BUUCTF Crypto [BJDCTF2020]easyrsa wp
- BUUCTF Crypto [WUSTCTF2020]B@se wp
- BUUCTF Crypto [BJDCTF2020]rsa_output wp
- BUUCTF crypto 还原大师
- BugKuCTF(CTF-练习平台)——Crypto-+[]-
- SUSCTF re方向部分wp
- 深信服杯ctf部分wp
- bugkuCTF之easy_crypto截图思路
- HITCTF 2018 wp [我真是菜鸟]
- BugKuCTF(CTF-练习平台)——Crypto-奇怪的密码
- SUSCTF|WP:CrakeMe 一道android逆向
- CTF之Crypto新手入门
- BugKuCTF(CTF-练习平台)——Crypto-托马斯.杰斐逊
- CTF实验吧 这就是一个坑wp (明文攻击)
- 寒假第二周CTFwp——合天CTF
- ctf-crypto
- BugKuCTF(CTF-练习平台)——Crypto-来自宇宙的信号
- CG-CTF Crypto WriteUp
- 【LinkCTF-29】Crypto--密码本
- 【CTF】攻防世界——easy_RSA(Crypto)