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
Closed

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

beyefendi opened this issue Nov 14, 2016 · 1 comment

Comments

@beyefendi
Copy link

@beyefendi 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
Copy link

@dmiller-nmap 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants