Created
November 16, 2017 19:39
-
-
Save ninj4c0d3r/7dec7d8b89c917c1c5fecddc945770fa 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 | |
# Hackaflag 2017 Etapa NATAL Crypto100 [Write-Up] | |
# Jonatas Fil - Dark00x1n [RATF] | |
# RSA-768 | |
# https://en.wikipedia.org/wiki/RSA_Factoring_Challenge | |
# https://en.wikipedia.org/wiki/RSA_numbers#RSA-768 | |
import gmpy | |
# Modulo | |
N = 1062298437646102178982125849777616556940568446813929092985586137589152470725381990531187697078820602673983926292915001934764080223025406544777312096563547373014612492919701398580259368151634974370089837459356819607567494260480572449 | |
# Expoente | |
e = 65537 | |
# mensagem cifrada | |
c = 121560831698874219453267613174219141247779625979263684086055365282206190849386529369540754333346196170380400323865047328204751135058776179967797282368990382515924294891518016686180279409054094397243792496242298466435824664626111902 | |
# p compativel | |
p = 33478071698956898786044169848212690817704794983713768568912431388982883793878002287614711652531743087737814467999489 | |
q = N/p | |
inverte = gmpy.invert(e, (p-1)*(q-1)) | |
print "\nDecipher value: " + str(inverte) | |
d = inverte | |
flag = pow(c,d,N) | |
print "\nFlag in decimal: " + str(flag) | |
FLAG = format(602873438782344394527399921786992769594048657669223244253021239583680398258312466721767404089469, 'x') # in hexadecimal | |
print "\nFlag in Hexadecimal: " + str(FLAG) | |
final = str(FLAG).decode("hex") | |
print "\nFlag: " + str(final) | |
# FLAG = HACKAFLAG{S0lv3d RSA-768, G1MM3 $50.000} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment