RSA Cryptography CTF Challenge Writeup

August 24, 2018 Script hunter

I am surprised this time because no one able to solve this challenge ,i don’t know why.Whatever the reason but i am giving RSA Cryptography CTF Challenge Writeup for same.

Challenge had given a rsa.txt.
Content of rsa.txt

n = 128299637852747781491257187842028484364103855748297296704808405762229741626342194440837748106022068295635777844830831811978557490708404900063082674039252789841829590381008343327258960595508204744589399243877556198799438322881052857422197506822302290812621883700357890208069551876513290323124813780520689585503
e = 65537
c = 6577983744639977747268583950873464157684557975158690248230468870766252734160542486627891038269288790372262383083185011884608411455167106421033456145985517997545390816094264907592946768668644826582496722293814920670946932469787328455630789907527491901920966072612582147908012415645541211086710682267633580111

Name has suggested that this is a CTF challenge based on RSA encryption so for solving this you have to know what is a RSA encryption.A very good article on wikipedia and a awesome video on youtube has given for better understanding.
Try to solve challenge first if you watched video.

RSA Cryptography ctf challenge writeup

Procedure:

  • (n,e) makes a public key and we need a private key to decrypt cipher c so i wrote a python code for do the same.
  • import gmpy
    
    n = 128299637852747781491257187842028484364103855748297296704808405762229741626342194440837748106022068295635777844830831811978557490708404900063082674039252789841829590381008343327258960595508204744589399243877556198799438322881052857422197506822302290812621883700357890208069551876513290323124813780520689585503
    e = 65537
    c = 6577983744639977747268583950873464157684557975158690248230468870766252734160542486627891038269288790372262383083185011884608411455167106421033456145985517997545390816094264907592946768668644826582496722293814920670946932469787328455630789907527491901920966072612582147908012415645541211086710682267633580111
    p = 11326943005628119672694629821649856331564947811949928186125208046290130000912120768861173564277210907403841603312764378561200102283658817695884193223692869
    q = 11326943005628119672694629821649856331564947811949928186125208046290130000912216246378177299696220728414241927034282796937320547048361486068608744598351187 
    phi = (p-1)*(q-1)
    # procedure to follow
    # n = p * q
    # phi = (p-1)*(q-1)
    # e*d = 1 mod phi
    # c^d mod n = message
    
    d = gmpy.invert(e,phi)
    message = pow(c,d,n)
    #message will be in decimal form,lets change in hex then in ascii characters
    message = hex(message)[2:].decode('hex')
    print message
  • Execute this python script and you will get your flag

Flag : CHERRY{RSA_EnCRYption}
Go to challenge page and verify this flag.
You can also use RsaCtfTool from Github.
Wash your hand here also
RSA cryptography ctf challenge
Boring php challenge
Lola ctf challenge