hposton / python-for-cybersecurity

This repository holds the Python scripts discussed in the Infosec Institute's Python for Cybersecurity learning Path
GNU General Public License v3.0
308 stars 193 forks source link

"DNS" is not defined and "DNSQR" is not defined #4

Closed Gabriel-la-flamboyance closed 1 year ago

Gabriel-la-flamboyance commented 1 year ago

Hello everyone, I am a beginner in cybersecurity and I am trying to make a port scan but I am getting this errors even if I have dnspython version -2.3.0 ans scapy version -2.5.0 already installed. Can someone help me please. Regards. This is the code;

`from scapy.all import * from scapy.layers.inet import IP from scapy.layers.inet import TCP from scapy.layers.inet import UDP

ports = [25,80,53,443,445,8080,8443]

def SynScan(host): ans,unans = sr(IP(dst=host)/TCP(dport=ports,flags="S"),timeout=2,verbose=0) print("Open ports at %s:" % host) for (s,r,) in ans: if s.haslayer(TCP) and r.haslayer(TCP): if s[TCP].dport == r[TCP].sport: print(s[TCP].dport)

def DNSScan(host): ans,unans = sr(IP(dst=host)/UDP(dport=53)/DNS(rd=1,qd=DNSQR(qname="google.com")),timeout=2,verbose=0) if ans: print("DNS Server at %s"%host)

host = "8.8.8.8"

SynScan(host) DNSScan(host)`

Gabriel-la-flamboyance commented 1 year ago

I just found out the error, I had to add from scapy.layers.dns import DNS, DNSQR :)