easyRSA

  • 打开发现有多个N

  • 判断是否是使用了公有的素数,尝试使用欧几里得辗转相除分解出公有的素数

  • 确实是使用了公有的素数,直接用n整除common(共同素数)得到另一个素数。

  • 根据公式phi = (q -1)*(p - 1),求出phi

  • 使用gmpy2求出模逆元d

  • 最后循环解密即可

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# from flag import flag

import gmpy2

from Crypto.Util.number import *

import binascii



# m = bytes_to_long(flag)

e = 65537




def gcd(a, b):  # 求最大公约数

    if a < b:

        a, b = b, a

    while b != 0:

        temp = a % b

        a = b

        b = temp

    return a




f = open("output.txt", "r")

a = f.readlines()

ds = []



n1 = int(a[0])

n2 = int(a[1])

common = gcd(n1, n2)

print(common)



c = 38127524839835864306737280818907796566475979451567460500065967565655632622992572530918601432256137666695102199970580936307755091109351218835095309766358063857260088937006810056236871014903809290530667071255731805071115169201705265663551734892827553733293929057918850738362888383312352624299108382366714432727



for i in range(0, len(a)):

    n = int(a[len(a) - 1 - i])

    q = n // common

    phi = (common-1)*(q-1)

    d = gmpy2.invert(e, phi)

    # ds.append((d, n))

    c = pow(c, d, n)



print(hex(c))

print(binascii.unhexlify(hex(c)[2:]).decode(errors='ignore'))