[HNCTF 2022 Week1]baby_rsa

源代码:

复制代码
from Crypto.Util.number import bytes_to_long, getPrime
from gmpy2 import *
from secret import flag
m = bytes_to_long(flag)
p = getPrime(128)
q = getPrime(128)
n = p * q
e = 65537
c = pow(m,e,n)
print(n,c)
# 62193160459999883112594854240161159254035770172137079047232757011759606702281
# 17331436837911040930486942133359735652484926528331507431552667656734821231501

攻击代码:

复制代码
from Crypto.Util.number import *
n=62193160459999883112594854240161159254035770172137079047232757011759606702281
c=17331436837911040930486942133359735652484926528331507431552667656734821231501
p= 234560843346150602519484260867514743467
q=n//p
d=inverse(65537,(p-1)*(q-1))
m=pow(c,d,n)
print(long_to_bytes(m))
# b'NSSCTF{Welc0m3_t0_7h3_RSA_w0r1d}'

得到flag:

NSSCTF{Welc0m3_t0_7h3_RSA_w0r1d}

相关推荐
hengdonghui1 天前
Writeup 4 N1BOOK afr_2
ctf·目录穿越
print_Hyon2 天前
【CTF-CRYPTO-教学-RSA】第十三节:知道e、p和q的变形表达式,解密c
ctf
print_Hyon3 天前
【CTF-CRYPTO-教学-RSA】第七节:低加密指数攻击,已知n和e求c(e很小,m的e次方比n小,c可直接开方得到结果)
ctf
hengdonghui5 天前
Writeup 4 N1BOOK afr_1
ctf·伪协议·任意文件读取
hengdonghui5 天前
Writeup 4 N1BOOK 常见的搜集
ctf·信息搜集
hengdonghui6 天前
Writeup 4 N1BOOK SQL注入-1
ctf·sql注入·union·字符型注入
hengdonghui8 天前
Writeup 4 红帽杯 2021 WebsiteManger
web·ctf·ssrf·sql布尔盲注
hengdonghui9 天前
Writeup 4 2020 - 之江杯 - 异常的流量分析
wireshark·ctf·流量分析
hengdonghui9 天前
Writeup 4 津门杯 2021 Web hate_php
php·web·ctf·通配符
hengdonghui10 天前
Writeup 4 红帽杯 2021 Web Find_It
web·ctf·备份文件泄露