Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ndiff: Bug for one IP that have more than one domain name #591

Closed
beyefendi opened this Issue Nov 14, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@beyefendi
Copy link

beyefendi commented Nov 14, 2016

root@kali:~/Desktop/ndiff-bug# cat base.xml
<nmaprun>
<host>
        <status reason="echo-reply" reason_ttl="127" state="up" />
        <address addr="8.8.8.8" addrtype="ipv4" />
        <hostnames>
                <hostname name="ns1.google.com" type="PTR" />
        </hostnames>
        <times rttvar="5000" srtt="1610" to="50000" />
</host>
<host>
        <status state="up" reason="echo-reply" reason_ttl="127"/>
        <address addr="8.8.8.8" addrtype="ipv4"/>
        <hostnames>
                <hostname name="ns2.google.com" type="PTR"/>
        </hostnames>
        <times srtt="2510" rttvar="5000" to="50000"/>
</host>
</nmaprun>
root@kali:~/Desktop/ndiff-bug# cat scan.xml
<nmaprun>
<host>
        <status state="up" reason="echo-reply" reason_ttl="127"/>
        <address addr="8.8.8.8" addrtype="ipv4"/>
        <hostnames>
                <hostname name="ns2.google.com" type="PTR"/>
        </hostnames>
        <times srtt="2510" rttvar="5000" to="50000"/>
</host>
</nmaprun>
root@kali:~/Desktop/ndiff-bug# ndiff base.xml scan.xml

-ns1.google.com (8.8.8.8):
+ns2.google.com (8.8.8.8):

-ns2.google.com (8.8.8.8):
-Host is up.

It will be better to see only
-ns1.google.com (8.8.8.8):

@dmiller-nmap

This comment has been minimized.

Copy link

dmiller-nmap commented Nov 30, 2016

Good catch! The simplest way to do this would be to fix the check for equality and sort order for hosts. Add a __cmp__ rich comparison operator for the Host class that will only consider hosts equal if:

  1. they have the same IP address (IPv4 or IPv6) AND
  2. they have the same hostname or one of them does not have a hostname.

Then the host_pairs function could just compare hosts directly instead of calling get_id on each before comparing.

@nmap-bot nmap-bot closed this in 9f858f6 Dec 5, 2016

suraj51k added a commit to suraj51k/nmap that referenced this issue Jan 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.