I am reading the book "Python for Pentesters" by Daniel Echeverri Montoya. Being on page 17 I tried to test the code, however when trying to execute the function dns.resolver.query
with the parameter MX and NS I get an error of NoAnswer
.
Here I leave the code:
import dns
import dns.resolver
pagina_web = "www.google.com"
ansMX = dns.resolver.query(pagina_web, 'MX')
ansNS = dns.resolver.query(pagina_web, 'NS')
print("\nImprimiendo ansMX:")
print("--------------------------------")
print(ansMX.response.to_text())
print("\nImprimiendo ansNS:")
print("--------------------------------")
print(ansNS.response.to_text())
The two errors are the following:
-
MX:
Traceback (most recent call last): File "C:/Users/zorro/Desktop/Programas/Python/Pentester/Ejemplo 1/Ejemplo1.py", line 10, in <module> ansMX = dns.resolver.query(pagina_web, 'MX') File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 1132, in query File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 1053, in query File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 234, in __init__ dns.resolver.NoAnswer: The DNS response does not contain an answer to the question: www.google.com. IN MX
-
NS:
Traceback (most recent call last): File "C:/Users/zorro/Desktop/Programas/Python/Pentester/Ejemplo 1/Ejemplo1.py", line 11, in <module> ansNS = dns.resolver.query(pagina_web, 'NS') File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 1132, in query File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 1053, in query File "C:\Users\zorro\AppData\Local\Programs\Python\Python36-32\lib\site-packages\dnspython-1.15.0-py3.6.egg\dns\resolver.py", line 234, in __init__ dns.resolver.NoAnswer: The DNS response does not contain an answer to the question: www.google.com. IN NS
Versions of the programs that intervene in the code:
- Windows 10 Pro
- Python 3.6
- DNSPython
- PyCharm Community 2017.2.4