当前位置:网站首页>BUUCTF-[BJDCTF2020]RSA1
BUUCTF-[BJDCTF2020]RSA1
2022-07-27 21:07:00 【[email protected]】
1.题目代码:
# from Crypto.Util.number import getPrime,bytes_to_long
#
# flag=open("flag","rb").read()
#
# p=getPrime(1024)
# q=getPrime(1024)
# assert(e<100000)
# n=p*q
# m=bytes_to_long(flag)
# c=pow(m,e,n)
# print c,n
# print pow(294,e,n)
#
# p=getPrime(1024)
# n=p*q
# m=bytes_to_long("BJD"*32)
# c=pow(m,e,n)
# print c,n
#
# '''
# output:
# 12641635617803746150332232646354596292707861480200207537199141183624438303757120570096741248020236666965755798009656547738616399025300123043766255518596149348930444599820675230046423373053051631932557230849083426859490183732303751744004874183062594856870318614289991675980063548316499486908923209627563871554875612702079100567018698992935818206109087568166097392314105717555482926141030505639571708876213167112187962584484065321545727594135175369233925922507794999607323536976824183162923385005669930403448853465141405846835919842908469787547341752365471892495204307644586161393228776042015534147913888338316244169120
# 13508774104460209743306714034546704137247627344981133461801953479736017021401725818808462898375994767375627749494839671944543822403059978073813122441407612530658168942987820256786583006947001711749230193542370570950705530167921702835627122401475251039000775017381633900222474727396823708695063136246115652622259769634591309421761269548260984426148824641285010730983215377509255011298737827621611158032976420011662547854515610597955628898073569684158225678333474543920326532893446849808112837476684390030976472053905069855522297850688026960701186543428139843783907624317274796926248829543413464754127208843070331063037
# 381631268825806469518166370387352035475775677163615730759454343913563615970881967332407709901235637718936184198930226303761876517101208677107311006065728014220477966000620964056616058676999878976943319063836649085085377577273214792371548775204594097887078898598463892440141577974544939268247818937936607013100808169758675042264568547764031628431414727922168580998494695800403043312406643527637667466318473669542326169218665366423043579003388486634167642663495896607282155808331902351188500197960905672207046579647052764579411814305689137519860880916467272056778641442758940135016400808740387144508156358067955215018
# 979153370552535153498477459720877329811204688208387543826122582132404214848454954722487086658061408795223805022202997613522014736983452121073860054851302343517756732701026667062765906277626879215457936330799698812755973057557620930172778859116538571207100424990838508255127616637334499680058645411786925302368790414768248611809358160197554369255458675450109457987698749584630551177577492043403656419968285163536823819817573531356497236154342689914525321673807925458651854768512396355389740863270148775362744448115581639629326362342160548500035000156097215446881251055505465713854173913142040976382500435185442521721
# 12806210903061368369054309575159360374022344774547459345216907128193957592938071815865954073287532545947370671838372144806539753829484356064919357285623305209600680570975224639214396805124350862772159272362778768036844634760917612708721787320159318432456050806227784435091161119982613987303255995543165395426658059462110056431392517548717447898084915167661172362984251201688639469652283452307712821398857016487590794996544468826705600332208535201443322267298747117528882985955375246424812616478327182399461709978893464093245135530135430007842223389360212803439850867615121148050034887767584693608776323252233254261047
# '''2.复现
首先用n1和n2求出公因数q,然后再爆破e。
import gmpy2
import libnum
c1=12641635617803746150332232646354596292707861480200207537199141183624438303757120570096741248020236666965755798009656547738616399025300123043766255518596149348930444599820675230046423373053051631932557230849083426859490183732303751744004874183062594856870318614289991675980063548316499486908923209627563871554875612702079100567018698992935818206109087568166097392314105717555482926141030505639571708876213167112187962584484065321545727594135175369233925922507794999607323536976824183162923385005669930403448853465141405846835919842908469787547341752365471892495204307644586161393228776042015534147913888338316244169120
n1=13508774104460209743306714034546704137247627344981133461801953479736017021401725818808462898375994767375627749494839671944543822403059978073813122441407612530658168942987820256786583006947001711749230193542370570950705530167921702835627122401475251039000775017381633900222474727396823708695063136246115652622259769634591309421761269548260984426148824641285010730983215377509255011298737827621611158032976420011662547854515610597955628898073569684158225678333474543920326532893446849808112837476684390030976472053905069855522297850688026960701186543428139843783907624317274796926248829543413464754127208843070331063037
c2=979153370552535153498477459720877329811204688208387543826122582132404214848454954722487086658061408795223805022202997613522014736983452121073860054851302343517756732701026667062765906277626879215457936330799698812755973057557620930172778859116538571207100424990838508255127616637334499680058645411786925302368790414768248611809358160197554369255458675450109457987698749584630551177577492043403656419968285163536823819817573531356497236154342689914525321673807925458651854768512396355389740863270148775362744448115581639629326362342160548500035000156097215446881251055505465713854173913142040976382500435185442521721
n2=12806210903061368369054309575159360374022344774547459345216907128193957592938071815865954073287532545947370671838372144806539753829484356064919357285623305209600680570975224639214396805124350862772159272362778768036844634760917612708721787320159318432456050806227784435091161119982613987303255995543165395426658059462110056431392517548717447898084915167661172362984251201688639469652283452307712821398857016487590794996544468826705600332208535201443322267298747117528882985955375246424812616478327182399461709978893464093245135530135430007842223389360212803439850867615121148050034887767584693608776323252233254261047
q=gmpy2.gcd(n1,n2)
p=n1//q
#pow(294,e,n)
x=381631268825806469518166370387352035475775677163615730759454343913563615970881967332407709901235637718936184198930226303761876517101208677107311006065728014220477966000620964056616058676999878976943319063836649085085377577273214792371548775204594097887078898598463892440141577974544939268247818937936607013100808169758675042264568547764031628431414727922168580998494695800403043312406643527637667466318473669542326169218665366423043579003388486634167642663495896607282155808331902351188500197960905672207046579647052764579411814305689137519860880916467272056778641442758940135016400808740387144508156358067955215018
e=0
for i in range(100000):
if(pow(294,i,n1)==x):
e=i#52361
print(e)
phi=(p-1)*(q-1)
d=gmpy2.invert(e,phi)
m=pow(c1,d,n1)
print(libnum.n2s(int(m)))
# 52361
# b'BJD{p_is_common_divisor}'版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_61774705/article/details/124696288
边栏推荐
- Master data management theory and Practice
- 股价暴涨180.46%!国产大硅片龙头沪硅产业上市:近4年净利累计不足6000万
- 用3dmax做折扇的思路方法与步骤
- What are the advantages of Tita's OKR system over other similar products or shared documents?
- 15million per day! BYD masks won a US $1billion order in California
- C#委托用法--控制台项目,通过委托实现事件
- Yijia will release ODM orders in 2020 and make efforts in the middle and low-end market
- NDK series (6): let's talk about the way and time to register JNI functions
- Bank Marketing预测一个客户购买理财产品的成功率
- 【12月海口】2022年第六届船舶,海洋与海事工程国际会议(NAOME 2022)
猜你喜欢

【C语言】通讯录(动态版本)
![[C language] address book (dynamic version)](/img/29/3df19c187bee31ee4671e12d7cc7ff.jpg)
[C language] address book (dynamic version)

字符流学习14.3

Normality of confidence interval

JUC toolkit learning

Calling dht11/22 temperature and humidity sensor in Proteus simulation Arduino

J9数字科普:Sui网络的双共识是如何工作的?

Key points of data management

File&递归14.1

Introduction to several common usage scenarios of message queue
随机推荐
The first activity of togaf10 standard reading club was successfully held, and the wonderful moments were reviewed!
Calling dht11/22 temperature and humidity sensor in Proteus simulation Arduino
如果我们是那晚负责修复 B 站崩了的开发人员
reduce错误示范
五子棋人机对战实现
[JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters
sort排序
The print version of imeta | international standard ISSN is officially confirmed, and the application for dual ISSN is completed
一加将在2020年释放ODM订单,发力中低端市场
2022/7/24-7/25
尚硅谷尚品项目汇笔记(一)
MySQL data query (where)
2022年土木,建筑与环境工程国际会议(ICCAEE 2022)
Redis的分布式锁
Design and implementation of spark offline development framework
Elk log analysis system installation and deployment
重新定义分析 - EventBridge 实时事件分析平台发布
Remotely debug idea, configure remote debug, and add JVM startup parameter -xdebug in the program of remote server
请求合并哪家强——接口请求合并的3种技巧,性能直接爆表
Smartrefresh nested multiple recycleview sliding conflicts and incomplete layout display