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 commented Nov 14, 2016 edited

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):

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 closed this in 9f858f6 Dec 5, 2016

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

@bonsaiviking @suraj51k bonsaiviking + suraj51k Fix host sorting in Ndiff. Fixes #591 8fa7794
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment