Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

why do with this code : ## ! / usr / bin / env python 3 import sys from scapy.all import * def get _

why do with this code : ##!/usr/bin/env python3
import sys
from scapy.all import *
def get_soa_record(domain):
# Create a DNS query packet for SOA record
dns_request = IP(dst="8.8.8.8")/ UDP(dport=53)/ DNS(rd=1, qd=DNSQR(qname=domain, qtype='SOA'))
dns_response = sr1(dns_request, verbose=0, timeout=2)
if dns_response and dns_response.haslayer(DNSRR):
for answer in dns_response[DNS].an:
if answer.type ==6: # SOA type
return answer.mname.decode() # Primary DNS server
return None
domain ="jct.ac.il"
primary_dns_server = get_soa_record(domain)
print(f"Primary DNS Server for {domain}: {primary_dns_server}")
def query_dns_server(dns_server, domain):
# Create a DNS query packet for A records
dns_request = IP(dst=dns_server)/ UDP(dport=53)/ DNS(rd=1, qd=DNSQR(qname=domain, qtype='A'))
dns_response = sr1(dns_request, verbose=0, timeout=2)
ip_addresses =[]
if dns_response and dns_response.haslayer(DNSRR):
for answer in dns_response[DNS].an:
if answer.type ==1: # A type
ip_addresses.append(answer.rdata)
return ip_addresses
ip_addresses = query_dns_server(primary_dns_server, domain)
print(f"IP Addresses for {domain}: {ip_addresses}")
if __name__=="__main__":
if len(sys.argv)!=2:
print("Usage: dnsenum.py ")
sys.exit(1)
domain = sys.argv[1]
primary_dns_server = get_soa_record(domain)
if not primary_dns_server:
print(f"Could not find the primary DNS server for {domain}")
sys.exit(1)
print(f"Primary DNS Server for {domain}: {primary_dns_server}")
ip_addresses = query_dns_server(primary_dns_server, domain)
if not ip_addresses:
print(f"No IP addresses found for {domain}")
else:
print(f"IP Addresses for {domain}:")
for ip in ip_addresses:
print(ip),i get those error WARNING: No IPv4 address found on anpi0!
WARNING: No IPv4 address found on anpi1!
WARNING: more No IPv4 address found on en6!
Primary DNS Server for jct.ac.il: None
IP Addresses for jct.ac.il: []
Usage: dnsenum.py
Could not find the primary DNS server for jct.ac.il
Process finished with exit code 1

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

How is workforce planning linked to strategic planning?

Answered: 1 week ago