[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}

相关推荐
hengdonghui2 小时前
Writeup 4 津门杯 2021 Web hate_php
php·web·ctf·通配符
hengdonghui6 小时前
Writeup 4 红帽杯 2021 Web Find_It
web·ctf·备份文件泄露
hengdonghui1 天前
Writeup 4 强网杯 2019 强网先锋打野
ctf·misc·zsteg
hengdonghui1 天前
Writeup 4 NUAA 2017 robots
android·ctf·re
hengdonghui2 天前
Writeup 4 CSS CTF Semester 2 2026 - Lamp Drill
ctf·re
hengdonghui2 天前
Writeup 4 CSS CTF Semester 2 2026 Cryptography Chrono I
ctf·维吉尼亚密码·crypto
hengdonghui2 天前
Writeup 4 CSS CTF Semester 2 2026 - Dead Faction Servers
ctf·osint
hengdonghui3 天前
Writeup 4 2020 - 之江杯 - 工控现场的恶意扫描
wireshark·ctf·流量分析
hengdonghui4 天前
Writeup 4 2020 - 之江杯 - 异常的工程文件
ctf·工控
hengdonghui4 天前
Writeup 4 2020 - 之江杯 - 注册表分析
注册表·ctf