Last active
February 27, 2016 18:42
-
-
Save mrtc0/ae2f26b408151123fc0f to your computer and use it in GitHub Desktop.
my-webhoneypot
This file contains 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
import sys | |
import SimpleHTTPServer | |
import SocketServer | |
import cgi | |
import logging | |
class Honey(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
logging.error(self.headers) | |
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | |
def do_POST(self): | |
logging.error(self.headers) | |
form = cgi.FieldStorage( | |
fp = self.rfile, | |
headers = self.headers, | |
environ = {'REQUEST_METHOD':'POST', 'CONTENT_TYPE':self.headers['Content-Type']}) | |
for i in form.list: | |
logging.error(i) | |
SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) | |
def main(cmd): | |
if len(cmd) < 2: | |
print "Usage: python %s <port>" % (sys.argv[0]) | |
else: | |
port = int(sys.argv[1]) | |
handler = Honey | |
httpd = SocketServer.TCPServer(("", port), handler) | |
print "[*] Honeypot is running at port %d \n" % (port) | |
httpd.serve_forever() | |
if __name__ == "__main__": | |
try: | |
main(sys.argv) | |
except KeyboardInterrupt: | |
print "[-] Stopped" | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment