Browse Source

added RSA decode script

master
Christopher Yu 1 year ago
parent
commit
a484499bcf
1 changed files with 22 additions and 0 deletions
  1. 22
    0
      TAMUCTF/Crypto/RSAaaay/decodrsa.py

+ 22
- 0
TAMUCTF/Crypto/RSAaaay/decodrsa.py View File

@@ -0,0 +1,22 @@
1
+from Crypto.Util.number import inverse
2
+from fractions import *
3
+
4
+e = 43
5
+n = 2531257
6
+c = "906851 991083 1780304 2380434 438490 356019 921472 822283 817856 556932 2102538 2501908 2211404 991083 1562919 38268"
7
+c = c.split(" ")
8
+c = map(int, c)
9
+p = 509
10
+q = 4973
11
+phi = (p - 1) * (q - 1)
12
+d = inverse(e, phi)
13
+m = []
14
+for i in c:
15
+	m.append(pow(i, d, n))
16
+print  m
17
+
18
+plain = [103, 105, 103, 101, 109, 123, 83, 97, 118, 97, 103, 101, 95, 83, 105, 120, 95, 70, 108, 121, 105, 110, 103, 95, 84, 105, 103, 101, 114, 115, 125]
19
+flag = ""
20
+for i in plain:
21
+	flag += chr(i)
22
+print "Decoded flag : ", flag

Loading…
Cancel
Save