0%

BUUCTF 每日打卡 2021-4-24

BUUCTF 每日打卡 2021-4-24

引言

今天社团招新 不知道最后会留下几个人 不过好像有各种 dl

你能看出这是什么加密么

附件内容如下: 在这里插入图片描述 这不一看就是 RSA 嘛 复制粘贴之后: 在这里插入图片描述 嗯? 怎么后面还有乱码? 不管,先删了试试看能把也能解密 代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
from Crypto.Util.number import *

p = int('0x928fb6aa9d813b6c3270131818a7c54edb18e3806942b88670106c1821e0326364194a8c49392849432b37632f0abe3f3c52e909b939c91c50e41a7b8cd00c67d6743b4f', 16)
q = int('0xec301417ccdffa679a8dcc4027dd0d75baf9d441625ed8930472165717f4732884c33f25d4ee6a6c9ae6c44aedad039b0b72cf42cab7f80d32b74061', 16)
e = int('0x10001', 16)
c = int('0x70c9133e1647e95c3cb99bd998a9028b5bf492929725a9e8e6d2e277fa0f37205580b196e5f121a2e83bc80a8204c99f5036a07c8cf6f96c420369b4161d2654a7eccbdaf583204b645e137b3bd15c5ce865298416fd5831cba0d947113ed5be5426b708b89451934d11f9aed9085b48b729449e461ff0863552149b965e22b6', 16)

n = p*q
phi = (p-1)*(q-1)
d = inverse(e, phi)
m = pow(c, d, n)
print(long_to_bytes(m))

结果为: 在这里插入图片描述 嗯? 一堆乱码 翻到最后发现: 在这里插入图片描述 啊这 结果就是:afctf{R54_|5_$0_$imp13}

crypto-rsa3

普通的 RSA n 不长,可以直接爆破 结果为: 在这里插入图片描述 然后解密即可 代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
from Crypto.Util.number import *

e = 65537
n = 177606504836499246970959030226871608885969321778211051080524634084516973331441644993898029573612290095853069264036530459253652875586267946877831055147546910227100566496658148381834683037366134553848011903251252726474047661274223137727688689535823533046778793131902143444408735610821167838717488859902242863683
c = 1457390378511382354771000540945361168984775052693073641682375071407490851289703070905749525830483035988737117653971428424612332020925926617395558868160380601912498299922825914229510166957910451841730028919883807634489834128830801407228447221775264711349928156290102782374379406719292116047581560530382210049
p = 13326909050357447643526585836833969378078147057723054701432842192988717649385731430095055622303549577233495793715580004801634268505725255565021519817179231
q = 13326909050357447643526585836833969378078147057723054701432842192988717649385731430095055622303549577233495793715580004801634268505725255565021519817179293

phi = (p-1)*(q-1)
d = inverse(e, phi)
m = pow(c, d, n)
print(long_to_bytes(m))

结果为:actf{p_and_q_should_not_be_so_close_in_value}

结语

下午纳新坐了几个小时 风大天冷又拉肚子 早点休息了 希望继续坚持

欢迎关注我的其它发布渠道

-------- 本文结束 感谢阅读 --------