Last active
May 31, 2016 09:57
-
-
Save CreateRemoteThread/b03038f3e199bd85459229a33ff125eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import libnum | |
f = open("in.txt","r") | |
data = f.readlines() | |
data_clustered = [(int(data[x].rstrip().lstrip("n = ")),int(data[x+1].rstrip().lstrip("e = ")),int(data[x+2].rstrip().lstrip("c = "))) for x in range(0,len(data),3)] | |
pubkeys = [] | |
for (n,e,c) in data_clustered: | |
pubkeys.append(n) | |
# x = libnum.factorize(int(n)) | |
# print x | |
out = "" | |
print "starting factorisation with %d keys" % len(pubkeys) | |
for (n,e,c) in data_clustered: | |
for n2 in pubkeys: | |
if n != n2: | |
p = libnum.gcd(n,n2) | |
if p == 0 or p == 1: | |
continue | |
q = n/p | |
thetans = (p-1)*(q-1) | |
d = libnum.invmod(e,thetans) | |
m = pow(c,d,n) | |
out += libnum.n2s(m) | |
break | |
f.close() | |
print out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment