2020西湖论剑线上赛-密码学-BrokenSystems

题目附件:

     链接:https://pan.baidu.com/s/18R-ZAeKXScPThuH_6BXwvw 
     提取码:ybu9 
 

从公钥中提取出n、e后,发现e非常大,可以用wiener-attack求出私钥d来解密。然后用PKCS1_OAEP的方式进行解密

#coding=utf8
#python3
#Author=BlusKing

from Crypto.PublicKey import RSA
from Crypto.Cipher import PKCS1_OAEP
from Crypto.Util.number import *

rsakey=RSA.importKey(open("public.key","r").read())

#从公钥中提取n,e
n = rsakey.n
e = rsakey.e

#n = 24493816160588971749455534346389861269947121809901305744877671102517333076424951483888863597563544011725032585417200878377314372325231470164799594965293350352923195632229495874587039720317200655351788887974047948082357232348155828924230567816817425104960545706688263839042183224681231800805037117758927837949941052360649778743187012198508745207332696876463490071925421229447425456903529626946628855874075846839745388326224970202749994059533831664092151570836853681204646481502222112116971464211748086292930029540995987019610460396057955900244074999111267618452967579699626655472948383601391620012180211885979095636919
#e = 3683191938452247871641914583009119792552938079110383367782698429399084083048335018186915282465581498846777124014232879019914546010406868697694661244001972931366227108140590201194336470785929194895915077935083045957890179080332615291089360169761324533970721460473221959270664692795701362942487885620152952927112838769014944652059440137350285198702402612151501564899791870051001152984815689187374906618917967106000628810361686645504356294175173529719443860140795170776862320812544438211122891112138748710073230404456268507750721647637959502454394140328030018450883598342764577147457231373121223878829298942493059211583
#私钥d需要利用wiener-attack求得
d =  1779217788383673416690068487595062922771414230914791138743960472798057054853883175313487137767631446949382388070798609545617543049566741624609996040273727
private_key = RSA.construct((n,e,d)).exportKey()


crypto = open("message","rb").read()
rsakey = RSA.importKey(private_key)
cipher = PKCS1_OAEP.new(rsakey)

text = cipher.decrypt(crypto)
print(text)

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值