Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from scapy.all import *
- import datetime
- UDP_D_PORT = 53
- UDP_S_PORT = 9090
- TIME_TO_SEND = 3
- TTL_SEND = 100
- NUM_TO_DIV = 1000
- def main():
- fullmsg = ""
- time1 = 0
- time2 = 0
- sum = 0
- domain = input('Please enter a domain: ')
- 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)
- ip_to_send = answer.summary()
- ip_to_send = ip_to_send[ip_to_send.find("\""):-1]
- ip_to_send = ip_to_send.replace("\"", "")
- print(ip_to_send, '\n')
- fullmsg = Ether() / IP(dst = ip_to_send, ttl = TTL_SEND) / ICMP()
- for i in range(TIME_TO_SEND):
- time1 = int(datetime.datetime.now().strftime('%f')) // NUM_TO_DIV
- answer = srp1(fullmsg, verbose=0)
- time2 = int(datetime.datetime.now().strftime('%f')) // NUM_TO_DIV
- print('Reply from ', ip_to_send, ': time=', time2 - time1, 'ms ', 'TTL=',TTL_SEND)
- sum += time2 - time1
- print('\nPing statistics for ', ip_to_send,':\nAverage = ', sum // TIME_TO_SEND)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement