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

相关推荐
hengdonghui11 小时前
Writeup 4 0xGame 2021 · command (WEB)
web·ctf·rce(远程代码执行)
0xBADCODE1 天前
2026 强网杯 Web 题 cwp · 全链路复盘
前端·安全·web安全·网络安全·系统安全·ctf
kingx34 天前
Bugku WEB 题解总集:文件包含 / SQLi / 反序列化 / SSTI / 反爬 / 组件漏洞
web安全·网络安全·ctf·bugku
kingx34 天前
Bugku Reverse 与 Android 题解总集:APK / native / PE / IPA
android·逆向·ctf·bugku
hengdonghui9 天前
Writeup 4 NUAACTF 2020 Wireshark 流量分析题
wireshark·ctf·misc·流量分析
hengdonghui10 天前
Writeup 4 0xGame 2021 - robot
web·ctf·信息泄露·robots.txt
hengdonghui13 天前
Writeup 4 Speak Softly Love
ctf·misc·osint(开源情报搜集)
其实防守也摸鱼15 天前
Cylab在线靶场——CTF中的通用技能
linux·数据库·学习·算法·靶场·ctf·学习网络安全
hengdonghui17 天前
Writeup 4 CTFHub injection
web·ctf·sql注入·整数型联合查询注入(有回显)
hengdonghui18 天前
Writeup 4 CTFHub weakphp
ctf·md5 绕过·.git 源码泄露·php 弱类型比较