Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. from scapy.all import *
  2. import thread
  3. #Raw packet data used to request Monlist from NTP server
  4. rawData = "\x17\x00\x03\x2a" + "\x00" * 61
  5. #File containing all IP addresses with NTP port open.
  6. logfile = open('output.txt', 'r')
  7. #Output file used to store all monlist enabled servers
  8. outputFile = open('monlistServers.txt', 'a')
  9. def sniffer():
  10. #Sniffs incomming network traffic on UDP port 48769, all packets meeting thease requirements run through the analyser function.
  11. sniffedPacket = sniff(filter="udp port 48769 and dst net 99.99.99.99", store=0, prn=analyser)
  12.  
  13. def analyser(packet):
  14. #If the server responds to the GET_MONLIST command.
  15. if len(packet) > 200:
  16. if packet.haslayer(IP):
  17. print packet.getlayer(IP).src
  18. #Outputs the IP address to a log file.
  19. outputFile.write(packet.getlayer(IP).src + '\n')
  20.  
  21. thread.start_new_thread(sniffer, ())
  22.  
  23. for address in logfile:
  24. #Creates a UDP packet with NTP port 123 as the destination and the MON_GETLIST payload.
  25. send(IP(dst=address)/UDP(sport=48769, dport=123)/Raw(load=rawData))
  26. print 'End'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement