def download(self, host='installers.xicp.net', filename='/download/repo.xml'): conn = httpconn(host) conn.request('GET', filename) buff = conn.getresponse().read() localFile = open('/download/repo.xml', 'w') localFile.write(buff) localFile.close()
def main(): from sys import argv from base64 import b64decode from urlparse import urlparse from time import time, strptime, mktime, sleep from httplib import HTTPConnection as httpconn endtime = int(mktime(strptime(b64decode(argv[5]), '%Y-%m-%d %H:%M:%S'))) urls = urlparse(b64decode(argv[1])) data = b64decode(argv[3]) session = b64decode(argv[2]) frequency = b64decode(argv[4]) while time() < endtime: keeping = httpconn(urls.netloc) keeping.request('HEAD', urls.path, data, {'Cookie':session}) keeping.close() sleep(frequency)
def login_rekey(): rekey = None referer = str(request.headers.get('Referer')) if urlparse(referer).path == '/home/rekey': if not validate('login'): rekey = True else: abort(404) filekey = request.files.get('filekey') urlkey = request.forms.get('urlkey') if filekey: key = filekey.file.read() elif urlkey: try: keyurl = urlparse(urlkey) httpkey = httpconn(keyurl.netloc) httpkey.request('GET', keyurl.path) key = httpkey.getresponse().read() except: redirect(referer) else: redirect(referer) ausers.execute("select key from user where id=1") keys = getmd5(b64encode(key) + salt) akeys = ausers.fetchone()[0] if keys != akeys: if rekey: ausers.execute("update user set key=? where id=1", [keys]) else: redirect(referer) else: ausers.execute("select id,salt,key from user where id=1") keyhash = getmd5(b64encode(str(ausers.fetchone()) + ctime())) ausers.execute("update user set cookie=? where id=1", [keyhash]) response.set_cookie('key', keyhash, httponly = True, max_age = 604800, path = '/home') auser.commit() redirect('/home')