Advertisement
Guest User

Untitled

a guest
May 26th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. from scapy.all import *
  2. import datetime
  3.  
  4. UDP_D_PORT = 53
  5. UDP_S_PORT = 9090
  6. TIME_TO_SEND = 3
  7. TTL_SEND = 100
  8. NUM_TO_DIV = 1000
  9.  
  10. def main():
  11. fullmsg = ""
  12. time1 = 0
  13. time2 = 0
  14. sum = 0
  15.  
  16. domain = input('Please enter a domain: ')
  17. answer = sr1(IP(dst="8.8.8.8") / UDP(sport = UDP_S_PORT, dport = UDP_D_PORT) / DNS(rd = 1, qd=DNSQR(qname = domain)), verbose = 0)
  18.  
  19. ip_to_send = answer.summary()
  20. ip_to_send = ip_to_send[ip_to_send.find("\""):-1]
  21. ip_to_send = ip_to_send.replace("\"", "")
  22.  
  23. print(ip_to_send, '\n')
  24. fullmsg = Ether() / IP(dst = ip_to_send, ttl = TTL_SEND) / ICMP()
  25. for i in range(TIME_TO_SEND):
  26. time1 = int(datetime.datetime.now().strftime('%f')) // NUM_TO_DIV
  27. answer = srp1(fullmsg, verbose=0)
  28. time2 = int(datetime.datetime.now().strftime('%f')) // NUM_TO_DIV
  29. print('Reply from ', ip_to_send, ': time=', time2 - time1, 'ms ', 'TTL=',TTL_SEND)
  30. sum += time2 - time1
  31. print('\nPing statistics for ', ip_to_send,':\nAverage = ', sum // TIME_TO_SEND)
  32.  
  33. if __name__ == '__main__':
  34. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement