Skip to content

Instantly share code, notes, and snippets.

@chitoge
Created June 27, 2016 16:49
Show Gist options
  • Save chitoge/e79031df237bab1d36cbda66d547a588 to your computer and use it in GitHub Desktop.
Save chitoge/e79031df237bab1d36cbda66d547a588 to your computer and use it in GitHub Desktop.
Whitehat 11 For200
import re, base64
split_string = "#$%&'()*+,-./:;<=>?@\x0f\x15"
def getModule():
nn = 'MTA1NjM1NzA'
nn += '3OTk0MjE1Nzg1MDY0NTkyNjg4ODI5NDMxNjAzMjk1MDkyM'
nn += 'D'
Dantonz = 'ZnV6dQ=='
nn += 'E5MzMyOTQxMzQwMjE4MDYzMDI0MD'
nn += 'MwMjE0MTEyNDM1NDc3Mzg4OTU1NDcyMDc4MDYxOTY3MzY2NTkxMjc0NDM5NzE'
nn += chr(ord('z')) + chr(ord('N'))
jtyiel = 'Z2tkb318zz=='
nn += 'zc2NTYzMjUxODI0MDA5NDI5'
nn += 'OTEwNzk2OTI2MDA5OTQ1NjM5MzUzMDA3MzcxODU1NDEzOTkzOTg0Mzc5NTk4ODY4Njk2MTk1MTY0MDk5ODc5Mzk0MzQ2Nzg4MDY5OTQxNTQ1NzMxODEzMDk3MzMxMDE1MDU4Nzg2MjAxNjk3OTU4ODIyMzUzNTM4NDkwNzQ3NDI1NTI0NjE3NDM3MzU0MjY5NjY0NzY2OTA5NzYzNjc5Njg0MDQ3NDU0Njg4Mjc4MDExMDMx'
n = base64.b64decode(nn)
return long(n)
modulo = getModule()
d_exp = 88564621686225804143599949348031629074448419889036649215278253785863628513354908121326408001477927349804924920474953757949280896835049634504821293313553289355709328104008395204711274370387211439046775523078243154006826451358656526662979651456823488028759120748152472580144809988367304986290600684644152983809
def decrypt(data_string):
#enc = re.findall('(.+)' + split_string.encode('hex'), data_string.encode('hex'))
#print enc
#encrypted = [e.decode('hex') for e in enc]
encrypted = data_string.split(split_string)
f = open('decrypted', 'wb')
print encrypted
for d in encrypted:
if (d == ''): continue
l = int(d.encode('hex'), 16)
# add padding here... or not?
plain = pow(l, d_exp, modulo)
plain = hex(plain).lstrip('0x').rstrip('L')
if ((len(plain) & 1) == 1): plain = '0' + plain
while (len(plain) < 200): plain = '00' + plain
f.write(plain.decode('hex'))
f.close()
fl = open('file', 'rb')
decrypt(fl.read())
fl.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment