Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python
- import cgitb; cgitb.enable()
- import cgi
- from urllib2 import urlopen
- def tohex(data):
- return "".join(hex(ord(char))[2:].rjust(2,"0") for char in data)
- def fromhex(encoded):
- data = ""
- while encoded:
- data += chr(int(encoded[:2], 16))
- encoded = encoded[2:]
- return data
- if __name__=="__main__":
- print("Content-type: text/plain")
- print("")
- url = fromhex( cgi.FieldStorage()["target"].value )
- contents = urlopen(url).read()
- for i in range(len(contents)/40+1):
- print( tohex(contents[40*i:40*i+40]) )
- #!/usr/bin/env python2.6
- import os
- from sys import argv
- from urllib2 import build_opener, ProxyHandler
- if os.fork():
- exit()
- def tohex(data):
- return "".join(hex(ord(char))[2:].rjust(2,"0") for char in data)
- def fromhex(encoded):
- data = ""
- while encoded:
- data += chr(int(encoded[:2], 16))
- encoded = encoded[2:]
- return data
- if __name__=="__main__":
- if len(argv) < 2:
- print("usage: %s URL [FILENAME]" % argv[0])
- quit()
- os.chdir("/home/courtwright/mp3s")
- url = "http://example.com/cgi-bin/hex.py?target=%s" % tohex(argv[1])
- fname = argv[2] if len(argv)>2 else argv[1].split("/")[-1]
- with open(fname, "wb") as dest:
- for line in build_opener(ProxyHandler({"http":"proxy.example.com:8080"})).open(url):
- dest.write( fromhex(line.strip()) )
- dest.flush()
Add Comment
Please, Sign In to add comment