Created
January 16, 2018 20:44
-
-
Save minhtt159/80833fe36c1fb1a356cfbc67d740e914 to your computer and use it in GitHub Desktop.
BKU-CTF
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
e = 0x10001 | |
n = 55089599753625499150129246679078411260946554356961748980861372828434789664694269460953507615455541204658984798121874916511031276020889949113155608279765385693784204971246654484161179832345357692487854383961212865469152326807704510472371156179457167612793412416133943976901478047318514990960333355366785001217 | |
q = 7422236843002619998657542152935407597465626963556444983366482781089760759017266051147512413638949173306397011800331344424158682304439958652982994939276427 | |
c = 33062272351573218250384115704487361063970465004033740168733959927707721053321054975845636421337650298670338055101957913137486876401007806540788449215177115739842456860057795240129932234489439409388612936981938930876353938688227847808194010536300529961489751250254640618262254364661940751727869020817391566773 | |
p = n/q | |
phi = (p-1)*(q-1) | |
def egcd(a, b): | |
if a == 0: | |
return (b, 0, 1) | |
g, y, x = egcd(b%a,a) | |
return (g, x - (b//a) * y, y) | |
def modinv(a, m): | |
g, x, y = egcd(a, m) | |
if g != 1: | |
raise Exception('No modular inverse') | |
return x%m | |
d = modinv(e,phi) | |
m = pow(c,d,n) | |
print hex(m)[2:-1].decode('hex') | |
# WELCOME_TO_THE_KINGDOM_OF_CRYPTOGRAPHY!!! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment