当前位置:网站首页>[NPUCTF2020]EzRSA
[NPUCTF2020]EzRSA
2022-07-27 23:54:00 【[email protected]】
1. subject
# from gmpy2 import lcm , powmod , invert , gcd , mpz
# from Crypto.Util.number import getPrime
# from sympy import nextprime
# from random import randint
# p = getPrime(1024)
# q = getPrime(1024)
# n = p * q
# gift = lcm(p - 1 , q - 1)
# e = 54722
# flag = b'NPUCTF{******************}'
# m = int.from_bytes(flag , 'big')
# c = powmod(m , e , n)
# print('n: ' , n)
# print('gift: ' , gift)
# print('c: ' , c)
#n: 17083941230213489700426636484487738282426471494607098847295335339638177583685457921198569105417734668692072727759139358207667248703952436680183153327606147421932365889983347282046439156176685765143620637107347870401946946501620531665573668068349080410807996582297505889946205052879002028936125315312256470583622913646319779125559691270916064588684997382451412747432722966919513413709987353038375477178385125453567111965259721484997156799355617642131569095810304077131053588483057244340742751804935494087687363416921314041547093118565767609667033859583125275322077617576783247853718516166743858265291135353895239981121
#gift: 2135492653776686212553329560560967285303308936825887355911916917454772197960682240149821138177216833586509090969892419775958406087994054585022894165950768427741545736247918410255804894522085720642952579638418483800243368312702566458196708508543635051350999572787188236243275631609875253617015664414032058822919469443284453403064076232765024248435543326597418851751586308514540124571309152787559712950209357825576896132278045112177910266019741013995106579484868768251084453338417115483515132869594712162052362083414163954681306259137057581036657441897428432575924018950961141822554251369262248368899977337886190114104
#c: 3738960639194737957667684143565005503596276451617922474669745529299929395507971435311181578387223323429323286927370576955078618335757508161263585164126047545413028829873269342924092339298957635079736446851837414357757312525158356579607212496060244403765822636515347192211817658170822313646743520831977673861869637519843133863288550058359429455052676323196728280408508614527953057214779165450356577820378810467527006377296194102671360302059901897977339728292345132827184227155061326328585640019916328847372295754472832318258636054663091475801235050657401857262960415898483713074139212596685365780269667500271108538319
2. Reappear
Direct decomposition n,p,q It's coming out. , But found e, and phi Immutability , The largest common denominator is 2.
So deform :
c=m^e mod n
c=(m^2)^e/2 mod n
hold m^2 Treat as ciphertext
hold e//2 Just like phi Mutual prime , You can decrypt m^2
Then just open the root .
import gmpy2
import libnum
import sympy
e = 54722
n=17083941230213489700426636484487738282426471494607098847295335339638177583685457921198569105417734668692072727759139358207667248703952436680183153327606147421932365889983347282046439156176685765143620637107347870401946946501620531665573668068349080410807996582297505889946205052879002028936125315312256470583622913646319779125559691270916064588684997382451412747432722966919513413709987353038375477178385125453567111965259721484997156799355617642131569095810304077131053588483057244340742751804935494087687363416921314041547093118565767609667033859583125275322077617576783247853718516166743858265291135353895239981121
gift=2135492653776686212553329560560967285303308936825887355911916917454772197960682240149821138177216833586509090969892419775958406087994054585022894165950768427741545736247918410255804894522085720642952579638418483800243368312702566458196708508543635051350999572787188236243275631609875253617015664414032058822919469443284453403064076232765024248435543326597418851751586308514540124571309152787559712950209357825576896132278045112177910266019741013995106579484868768251084453338417115483515132869594712162052362083414163954681306259137057581036657441897428432575924018950961141822554251369262248368899977337886190114104
c=3738960639194737957667684143565005503596276451617922474669745529299929395507971435311181578387223323429323286927370576955078618335757508161263585164126047545413028829873269342924092339298957635079736446851837414357757312525158356579607212496060244403765822636515347192211817658170822313646743520831977673861869637519843133863288550058359429455052676323196728280408508614527953057214779165450356577820378810467527006377296194102671360302059901897977339728292345132827184227155061326328585640019916328847372295754472832318258636054663091475801235050657401857262960415898483713074139212596685365780269667500271108538319
# gift = lcm(p - 1 , q - 1) Minimum common multiple
p=106021448991021391444550749375115277080844281746248845802565680557785009341952320484175568763707424932172033597514861602114171459176440279045761846695231788376075050452154924141266290931413542110639081792550648106240966552406813059396358355737185354885474455248579946190266152416149137616855791805617206153497
q=161136651053130509602530659420755324119806487925813087617466818245407407797561810253722204813002837916779909309520498985459703212021249251124954613236122142746302911323565396331355397916764254680629384957057354297855676493062493901977415968666512459829211010720514167083018352796496733697235524845188512914793
phi=(p-1)*(q-1)
print(gmpy2.gcd(e,phi))#2
e=e//2
d=gmpy2.invert(e,phi)
m=gmpy2.iroot(pow(c,d,n),2)[0]
flag=libnum.n2s(int(m))
print(flag)
# b'NPUCTF{[email protected]}'
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/208/202207272106550118.html
边栏推荐
- Posture recognition and simple behavior recognition based on mediapipe
- BUUCTF-RSA
- The first activity of togaf10 standard reading club was successfully held, and the wonderful moments were reviewed!
- The 4-hour order exceeds 20000+, claiming to be "the most luxurious in a million". Is the domestic brand floating?
- In 2019, the world's top ten semiconductor manufacturers: Intel returned to the first place, and apple rose sharply against the trend
- (十二)51单片机----用DS18B20浅测一下工(江)西的室外温度
- [GWCTF 2019]BabyRSA1
- 测试类中的断言机制
- [NCTF2019]babyRSA1
- 【12月海口】2022年第六届船舶,海洋与海事工程国际会议(NAOME 2022)
猜你喜欢
![[JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters](/img/05/7029eb1fe36d7ddab2640f07247c81.png)
[JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters

Xss.haozi.me practice customs clearance

MapReduce (III)

29. Learn the stacked column chart of highcharts using percentage

2022年土木,建筑与环境工程国际会议(ICCAEE 2022)

NDK series (6): let's talk about the way and time to register JNI functions

Ideas, methods and steps of making folding fans with 3DMAX

File & recursion 14.1

Starfish OS X metabell strategic cooperation, metauniverse business ecosystem further

Lua基础语法学习
随机推荐
Notes on Shangpin project in shangsilicon Valley (I)
Error:svn: E155010: ‘/Users/.../Desktop/wrokspace/xxx‘ is scheduled for addition, but is missing
C # delegate usage -- console project, which implements events through delegation
【12月海口】2022年第六届船舶,海洋与海事工程国际会议(NAOME 2022)
Arm32 for remote debugging
[roarctf2019] babyrsa Wilson theorem
数据中台的那些“经验与陷阱”
15million per day! BYD masks won a US $1billion order in California
[JS reverse hundred examples] a public resource trading network, reverse analysis of announcement URL parameters
J9数字科普:Sui网络的双共识是如何工作的?
Realization of gobang man-machine combat
[MRCTF2020]babyRSA
Binary conversion method
字符流学习14.3
解密 OOM 崩溃下降 90% 的秘密~
Is it really hard to understand? What level of cache is the recyclerview caching mechanism?
TFRecord的Shuffle、划分和读取
UE4 official AEC blueprint case course learning notes
【zer0pts CTF 2022】 Anti-Fermat
(十二)51单片机----用DS18B20浅测一下工(江)西的室外温度