Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from scapy.all import *
- from scapy.layers.dns import DNS, DNSRR
- from scapy.layers.inet import IP
- def main():
- KEYS = {"1": dns_selected}
- print_menu()
- KEYS[input("> ")]()
- def dns_selected():
- print("Sniffing: DNS")
- sniff(lfilter=is_dns_answer, prn=print_dns)
- def is_dns_answer(inc_packet):
- my_ip = get_if_addr(conf.iface)
- return DNS in inc_packet and IP in inc_packet and inc_packet[IP].src != my_ip and DNSRR in inc_packet
- def print_dns(inc_packet):
- ip = inc_packet[DNS][DNSRR].rdata
- domain = inc_packet[DNS][DNSRR].rrname
- if isinstance(ip, bytes):
- ip = ip.decode()
- if isinstance(domain, bytes):
- domain = domain.decode()
- print("########\n"
- f"- ip: {ip}\n"
- f"- domain: {domain}")
- def print_menu():
- print("""
- - [MENU] Select by the digit [MENU] -
- 1. Print addresses that returned from DNS server
- 2. Print weather client response
- 3. Print GET link
- - [MENU] Select by the digit [MENU] -
- """)
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement