From a484499bcfb0405b3f9e79e4d9a080fcb11d5597 Mon Sep 17 00:00:00 2001 From: Christopher Yu Date: Sun, 3 Mar 2019 23:08:32 +0800 Subject: [PATCH] added RSA decode script --- TAMUCTF/Crypto/RSAaaay/decodrsa.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 TAMUCTF/Crypto/RSAaaay/decodrsa.py diff --git a/TAMUCTF/Crypto/RSAaaay/decodrsa.py b/TAMUCTF/Crypto/RSAaaay/decodrsa.py new file mode 100644 index 0000000..cc49421 --- /dev/null +++ b/TAMUCTF/Crypto/RSAaaay/decodrsa.py @@ -0,0 +1,22 @@ +from Crypto.Util.number import inverse +from fractions import * + +e = 43 +n = 2531257 +c = "906851 991083 1780304 2380434 438490 356019 921472 822283 817856 556932 2102538 2501908 2211404 991083 1562919 38268" +c = c.split(" ") +c = map(int, c) +p = 509 +q = 4973 +phi = (p - 1) * (q - 1) +d = inverse(e, phi) +m = [] +for i in c: + m.append(pow(i, d, n)) +print m + +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] +flag = "" +for i in plain: + flag += chr(i) +print "Decoded flag : ", flag