Skip to content

Fails with IPv6 DNS server #2

@bramp

Description

@bramp

My default DNS server is a IPv6 address, and when the tool receives a DNS request it fails with a error

$ ./dns-mitm.py
DNS MitM by Adrian Vollmer, SySS GmbH
Warning: Failed to drop privileges
Warning: No hosts specified. Operating in passive mode.
127.0.0.1:60629 is requesting the A record of google.com
Forwarding DNS request to 2601:646:ca00:43c::1
Traceback (most recent call last):
  File "./dns-mitm.py", line 167, in <module>
    main()
  File "./dns-mitm.py", line 161, in main
    main_loop(udps)
  File "./dns-mitm.py", line 129, in main_loop
    answer = forwarded_dns_request(data)
  File "./dns-mitm.py", line 104, in forwarded_dns_request
    udps.sendto(data, (DNS_IP, 53))
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

The fix is simple change line 103 from

udps = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

to

udps = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)

However, I suspect you'd want to check if DNS_IP is v4 or v6 and select AF_INET[6] appropriately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions