当前位置:网站首页>Ctf-rsa decryption script
Ctf-rsa decryption script
2022-04-21 07:41:00 【1stPeak】
cipher.txt Content :
0x1055f45639da0fe7ebb355a6f140425fb2d10b74a61860e60cdadc0d205d4905833a20dac9c2e2a873872f1b5d6ac045c996b9136414b8648b6fc821aea718fd4175324fc254bcaeb2cb2065bcf76d1351b483c2caf87a89ed3a3b0933d82466f6d022b728b85db547596509fb8a2d46ee920d306f5d591f50a6ad2c505c9c32e30dcd18faf1500cc1d79b1505dab7ab05943ff9bb4a0de531e9c609a4f5cdb850c611e673f18d89557e46a48bb35e09e10a521c7b45eb3aac85ddb4684b7695815c79b8300f991582b99299a5c28361247e4902da13f267ec7a925de0cd4d2d0ba2a2f47914d8c3b10a1dbc045f74a4d8617dfe0657aec8045deafbe60dd6d7aL
Pubkey.txt Content :
65537
33774167600199691072470424898842928168570559940362770786060699320989546851695106466924163816843729828399984649770900793014896037884774039660562546937090412844276185560384964983508291174867808082182386566813393157054259464108858158903739578119760394228341564696225513954400995543629624209942565369972555679980359992955514826589781286738100616149226885302403505062415492679633217275379153421830105021673417544608398249866398042786421630495968810854036782025120509999022773806069591080190166920079688217334968528641747739241234353918892029263544388161160427668518991666960251381106788899451912317001247537576428186291689
When doing a question , I didn't use the topic encrypt, The script of a big man
The process of solving the problem is as follows :
(1) Script decomposition n obtain p,q, The script is as follows
def gcd(a, b):
while b:
a, b = b, a%b
return a
def mapx(x):
x=(pow(x,n-1,n)+3)%n
return x
n=33774167600199691072470424898842928168570559940362770786060699320989546851695106466924163816843729828399984649770900793014896037884774039660562546937090412844276185560384964983508291174867808082182386566813393157054259464108858158903739578119760394228341564696225513954400995543629624209942565369972555679980359992955514826589781286738100616149226885302403505062415492679633217275379153421830105021673417544608398249866398042786421630495968810854036782025120509999022773806069591080190166920079688217334968528641747739241234353918892029263544388161160427668518991666960251381106788899451912317001247537576428186291689
x1=x2=1
while True:
x1=mapx(x1)
x2=mapx(mapx(x2))
p=gcd(x1-x2,n)
if (p!=1):
print(p)
print(n/p)
break
obtain p、q
p:177993461816075408240866752227210319316825574291000376727523991315086097605063837563342286560819823849610146713383370383386260295565108973920944593141677024612114517119831676665456754235233172344362610684938542774386956894066675103840244633202469661725050948177995671009070311486253646420435061175078660441183
q(n/p):189749484366449861630736482622030204229600074936733397229668738586605895979811823994029500725448581332746860468289540041125768726148614579255062994177531727784605194094836998282676712435286273497842956368997116036170165393912022560935791934662695453870846024312915604049805219410140420469163797779129644454583
(2) Use the script to find d
# coding = utf-8
def computeD(fn, e):
(x, y, r) = extendedGCD(fn, e)
#y maybe < 0, so convert it
if y < 0:
return fn + y
return y
def extendedGCD(a, b):
#a*xi + b*yi = ri
if b == 0:
return (1, 0, a)
#a*x1 + b*y1 = a
x1 = 1
y1 = 0
#a*x2 + b*y2 = b
x2 = 0
y2 = 1
while b != 0:
q = a / b
#ri = r(i-2) % r(i-1)
r = a % b
a = b
b = r
#xi = x(i-2) - q*x(i-1)
x = x1 - q*x2
x1 = x2
x2 = x
#yi = y(i-2) - q*y(i-1)
y = y1 - q*y2
y1 = y2
y2 = y
return(x1, y1, a)
p = 177993461816075408240866752227210319316825574291000376727523991315086097605063837563342286560819823849610146713383370383386260295565108973920944593141677024612114517119831676665456754235233172344362610684938542774386956894066675103840244633202469661725050948177995671009070311486253646420435061175078660441183
q = 189749484366449861630736482622030204229600074936733397229668738586605895979811823994029500725448581332746860468289540041125768726148614579255062994177531727784605194094836998282676712435286273497842956368997116036170165393912022560935791934662695453870846024312915604049805219410140420469163797779129644454583
e = 65537
n = p * q
fn = (p - 1) * (q - 1)
d = computeD(fn, e)
print d
obtain d:
11264411788839355592444856301614488363956471904061056255881635805090094375457400203763192894221130759558216953395674955120307575813439598378024263407707436165069943146297428393266768825247731038349979486052262807679509336199267919454932934045527300563698215071335234814155316242621058729891886931914187742084664702392602429806835617468209844338711315548455315452692700616464465563108767921693721150452939650725153874644898636543732854250641129411206109642819488878782249575130672657182665780011560050159281212359222980210472602178746411982328739935093883590670811966243661382699777078747677158108250557964576989602089
(3) Calculate plaintext with script
n = 33774167600199691072470424898842928168570559940362770786060699320989546851695106466924163816843729828399984649770900793014896037884774039660562546937090412844276185560384964983508291174867808082182386566813393157054259464108858158903739578119760394228341564696225513954400995543629624209942565369972555679980359992955514826589781286738100616149226885302403505062415492679633217275379153421830105021673417544608398249866398042786421630495968810854036782025120509999022773806069591080190166920079688217334968528641747739241234353918892029263544388161160427668518991666960251381106788899451912317001247537576428186291689
c = eval('0x1055f45639da0fe7ebb355a6f140425fb2d10b74a61860e60cdadc0d205d4905833a20dac9c2e2a873872f1b5d6ac045c996b9136414b8648b6fc821aea718fd4175324fc254bcaeb2cb2065bcf76d1351b483c2caf87a89ed3a3b0933d82466f6d022b728b85db547596509fb8a2d46ee920d306f5d591f50a6ad2c505c9c32e30dcd18faf1500cc1d79b1505dab7ab05943ff9bb4a0de531e9c609a4f5cdb850c611e673f18d89557e46a48bb35e09e10a521c7b45eb3aac85ddb4684b7695815c79b8300f991582b99299a5c28361247e4902da13f267ec7a925de0cd4d2d0ba2a2f47914d8c3b10a1dbc045f74a4d8617dfe0657aec8045deafbe60dd6d7aL')
d = 11264411788839355592444856301614488363956471904061056255881635805090094375457400203763192894221130759558216953395674955120307575813439598378024263407707436165069943146297428393266768825247731038349979486052262807679509336199267919454932934045527300563698215071335234814155316242621058729891886931914187742084664702392602429806835617468209844338711315548455315452692700616464465563108767921693721150452939650725153874644898636543732854250641129411206109642819488878782249575130672657182665780011560050159281212359222980210472602178746411982328739935093883590670811966243661382699777078747677158108250557964576989602089
m = pow(c, d, n)
print hex(m)
notes : Environment use python2
You can refer to examples :RSABD
版权声明
本文为[1stPeak]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210623242210.html
边栏推荐
- [untitled] Guoteng GM series, gm8284dd (gm8284dr, lt8218a), gm8285c, gm7123c, lvdsttl to TTL, TTL to single LVDS, TTL digital signal to VGA
- NP、OSPF虚链路
- Sorting method (3) = > quick sort and merge sort
- Blue Bridge Cup - hex to octal
- OSPF多区域
- Solve the problem of Chinese garbled code
- Jfinal framework easyexcel plug-in export with pictures
- NP, OSPF Stub Area
- 【网络协议】为什么要学习网络协议
- NP, OSPF route aggregation
猜你喜欢

Configure MySQL remote access

交换技术....

Cs5518, Mipi to dual LVDS, replacement: gm8775 of Guoteng, tc358775 of Toshiba, dual LVDS, domestic perfect replacement, DSI to dual channel LVDS, LVDS clock frequency up to 154mhz, 1920 x1200

Guanghuaxin audio codec Daquan cjc4344, cjc8988, cjc5340, cjc6811 guanghuaxin audio codec, cjc4344, cjc8988, cs5340

NP, NSSA area

空对象模式(3.14-3.20)

IP组播基本概念

Use Baidu map POI to crawl the required data

BGP neighbor

解释器模式(3.7-3.13)
随机推荐
【C#】LINQ
动态规划解决0/1背包问题
MySQL common table structure
2020-12-24
使用百度地图POI爬取需要的数据
空对象模式(3.14-3.20)
Use the security vulnerability detection tool Metasploit to lift the telnet login right of the target metasploitabile2
命令模式(3.21-3.27)
排序方式(1)==>冒泡排序,简单的选择排序
Sort method (2) = > insert sort
排序方式------>希尔排序,堆排序
利用安全漏洞检测工具Metasploit对靶机Metasploitable2的Telnet登录提权
2020-12-24
BGP 自动路由聚合
Ruiyuan power chip, ry3715, ry3750 replacement: silijie sy7208, sy7152, Xinpeng micro ap2008 Core source mp1542, mp3213. Input voltage from 2.5V to 5.5V
Longxun series: lt8912b, lt6911c, HDMI to Mipi (CSI \ DSI), single channel mipi2 DSi bridge to LVDS / HDM, hdmi1 4 to dual port mipidsi/csi and audio data sheet
Domestic Poe, rpc304, replace ip802, ip804 and ip808, replace tps23861, ltc4292, pd69204 and si3459, start domestic Poe power supply and PSE, and ruipukang domestic Ethernet power supply and interface
Export excel custom style with hutool tool ----- excel compression jar
BGP 鄰居
NP、OSPF邻居邻接关系