PatriotCTF 2024 Crypto Writeup
PatriotCTF 2024 Crypto Writeup
Author: dawn1ight
About: PatriotCTF is a beginner-friendly capture-the-flag competition hosted by GMU’s cybersecurity club, MasonCC. All are welcome to participate, including students and security professionals. Challenges will range from beginner to expert, so there should be something for everyone. This is a jeopardy-style CTF, meaning there will be various challenges from the different categories described below.
Challenges:https://pctf.competitivecyber.club/challenges
References:
- https://blog.csdn.net/weixin_52640415/article/details/142500402
- https://www.ctfiot.com/206569.html
- https://s19ma.github.io/posts/PatriotCTF/
Bigger is Better
N = 0xa0d9f425fe1246c25b8c3708b9f6d7747dd5b5e7f79719831c5cbe19fb7bab66ed62719b3fc6090120d2cfe1410583190cd650c32a4151550732b0fc97130e5f02aa26cb829600b6ab452b5b11373ec69d4eaae6c392d92da8bcbea85344af9d4699e36fdca075d33f58049fd0a9f6919f3003512a261a00985dc3d9843a822974df30b81732a91ce706c44bde5ff48491a45a5fa8d5d73bba5022af803ab7bd85250e71fc0254fcf078d21eaa5d38724014a85f679e8a7a1aad6ed22602465f90e6dd8ef95df287628832850af7e3628ad09ff90a6dbdf7a0e6d74f508d2a6235d4eae5a828ac95558bbdf72f39af5641dfe3edb0cdaab362805d926106e2af |
大加密指数e,经典wiener攻击
from RSAwienerHacker.RSAwienerHacker import hack_RSA |
idk cipher
|
字符串加密,对加密脚本逆向可得解密脚本
import base64 |
High Roller
#! /usr/bin/python3.10 |
-----BEGIN PUBLIC KEY----- |
openssl读取公钥
openssl rsa -pubin -in public.pem
e = 9357885447383373532894895505085381556066479232870333782284357317530689434635519527644215046975239651802146048650000941858355721661518511867620441456288201 |
提取出了n,e,但分解不出来
注意到random.seed(int(time.time()))
The seed was used is
int(time.time())
and converted into .pem file so we can use command to find time给了公钥和p,q的生成方法,是用时间作种子,求利用random来求的。根据题目文件的时间向前可以爆破出来。
stat -c '%n %y' public_key.pem |
看这里复习一下stat命令 https://blog.csdn.net/u012294618/article/details/72630092
from Crypto.Util.number import * |
Textbook Schnorr right??
from sage.all import * |
这个题用了schnorr-digital-signature数字签名算法
它是将经典的schnorr数字签名算法移到secp256k1椭圆曲线上
# 经典Schnorr签名算法 |
可以看出题目给出的Schnorr签名算法问题出在compute_hash
函数上
正常的算法中e = H(M||X)
where H() is the hash function
而题目给出的是e = H(M|X)
所以当输入为全1时得到的hash为固定值
separator = "FF" |
Hard to Implement
#!/usr/bin/python3 |
AES ECB的padding oracle: 块密码 | Lazzaro (lazzzaro.github.io)
1.由于是ECB的模式,所以当我们输入十五个’0’后,服务会将十五个
’0’+flag
加密,而此时第一组就是十五个’0’和flag的第一个字符。即,返回的明文的第一组是’0’*15 + flag[0]
的密文。2.我们遍历0-255,发送
’0’*15+chr(i)
,看返回的密文是不是和最初获得的密文的第一组一致,如果一致,那么此时的chr(i)就是flag的第一位。3.有了第一位我们就可以发送
’0’*14+flag[0]
过去,此时返回的第一组密文就是’0’*14+flag[0]+flag[1]
的密文了,我们继续用第2步的方法就可以恢复flag[1]了。4.如此循环往复,逐位爆破flag。
exp: [Patriot CTF 2024]-CSDN博客
from pwn import * |