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

相关推荐
hengdonghui13 小时前
Writeup 4 Speak Softly Love
ctf·misc·osint(开源情报搜集)
其实防守也摸鱼2 天前
Cylab在线靶场——CTF中的通用技能
linux·数据库·学习·算法·靶场·ctf·学习网络安全
hengdonghui5 天前
Writeup 4 CTFHub injection
web·ctf·sql注入·整数型联合查询注入(有回显)
hengdonghui6 天前
Writeup 4 CTFHub weakphp
ctf·md5 绕过·.git 源码泄露·php 弱类型比较
hengdonghui7 天前
Writeup 4 ByteMe CTF 2026 The Vormir Ledger
ctf·osint
文章永久免费只为良心9 天前
Ctfshow_Web应用安全与防护_第二章_无字母数字命令执行
前端·python·安全·网络安全·渗透测试·ctf·红队渗透测试
hengdonghui9 天前
Writeup 4 ByteMe CTF 2026 Sacrifice
ctf·forensics
print_Hyon10 天前
【CTF-CRYPTO-教学-RSA】第八节:超大模数n反噬攻击,已知n、e、c求m(n超大,m的e次方仍小于n,c可直接开e次方得到结果)
ctf
其实防守也摸鱼11 天前
CTF Web 6 题全解 Writeup
linux·sql·学习·算法·安全·ctf·xss
hengdonghui12 天前
Writeup 4 N1BOOK 第一章 Web 入门 · 粗心的小李
ctf·.git泄露