Skip to content

Instantly share code, notes, and snippets.

@mrtc0
Last active February 27, 2016 18:42
Show Gist options
  • Save mrtc0/ae2f26b408151123fc0f to your computer and use it in GitHub Desktop.
Save mrtc0/ae2f26b408151123fc0f to your computer and use it in GitHub Desktop.
my-webhoneypot
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