benkow_

Untitled

Jun 12th, 2017
113
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

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×