SHARE
TWEET

Untitled

benkow_ Jun 12th, 2017 (edited) 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python
  2. # coding: utf-8
  3.  
  4. import socket
  5. from socket import error as SocketError
  6. import threading
  7. import errno
  8. import binascii
  9. import datetime
  10.  
  11. honeypot_port = 9000
  12. class ClientThread(threading.Thread):
  13.  
  14.     def __init__(self, ip, port, clientsocket):
  15.         threading.Thread.__init__(self)
  16.         self.ip = ip
  17.         self.port = port
  18.         self.clientsocket = clientsocket
  19.  
  20.     def run(self):
  21.         try:
  22.                 r = self.clientsocket.recv(65535)
  23.         except SocketError as e:
  24.                 if e.errno != errno.ECONNRESET:
  25.                         raise
  26.                 pass
  27.         if r != "":
  28.                 dump = binascii.hexlify(r)
  29.                 date = datetime.datetime.now().isoformat()
  30.                 logfile = open("dump.log","a")
  31.                 logfile.write("["+date+"]["+self.ip+"][Unknow TCP probe]["+dump+"]\n")
  32.                 logfile.close()
  33.  
  34.  
  35. tcpsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  36. tcpsock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  37. tcpsock.bind(("",honeypot_port))
  38.  
  39. while True:
  40.     tcpsock.listen(10)
  41.     (clientsocket, (ip, port)) = tcpsock.accept()
  42.     newthread = ClientThread(ip, port, clientsocket)
  43.     newthread.start()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top