【Write Up】RSA5

19011343447 2025-06-06 22:09:19 186 0


from gmpy2 import *
from Crypto.Util.number import *
n = 158307578375429142391814474806884486236362186916188452580137711655290101749246194796158132723192108831610021920979976831387798531310286521988621973910776725756124498277292094830880179737057636826926718870947402385998304759357604096043571760391265436342427330673679572532727716853811470803394787706010603830747
e1 = 65537
e2 = 65521
c1 = 147465654815005020063943150787541676244006907179548061733683379407115931956604160894199596187128857070739585522099795520030109295201146791378167977530770154086872347421667566213107792455663772279848013855378166127142983660396920011133029349489200452580907847840266595584254579298524777000061248118561875608240
c2 = 142713643080475406732653557020038566547302005567266455940547551173573770529850069157484999432568532977025654715928532390305041525635025949965799289602536953914794718670859158768092964083443092374251987427058692219234329521939404919423432910655508395090232621076454399975588453154238832799760275047924852124717
def exgcd(a, b):
    # ax + by = gcd(a, b)
    if b == 0:
        return [1, 0]
    c = exgcd(b, a % b)
    return [c[1], c[0] - a // b * c[1]]
x, y = exgcd(e1, e2)
print(long_to_bytes(powmod(c1, x, n) * powmod(c2, y, n) % n))

共模攻击。

分类:Crypto
image
作者:19011343447

7

提交

0

收入

相关WriteUP

问题反馈