Nmap Development mailing list archives

Re: Feature request


From: David Fifield <david () bamsoftware com>
Date: Mon, 10 Sep 2012 15:29:09 -0700

On Mon, Sep 10, 2012 at 05:26:35PM -0500, Daniel Miller wrote:
On 09/10/2012 09:15 AM, Terry Freestone wrote:
Hi.
I love the product, but I would like to request a feature. When using the host filter in the Zenmap GUI, would it be 
possible to add a host "not equal to" option?

In the filter host field, just give the ability to put != in front of the filter term.

Example:
os:!=linux

Could you re-send this message to the mailing list, so that others can see it any perhaps discuss it?

David Fifield

Terry
                                    
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Terry,

Does this patch do what you like?

diff --git a/zenmap/zenmapCore/SearchResult.py
b/zenmap/zenmapCore/SearchResult.py
index 75c023f..c679489 100644
--- a/zenmap/zenmapCore/SearchResult.py
+++ b/zenmap/zenmapCore/SearchResult.py
@@ -146,6 +146,10 @@ class HostSearch(object):
     @staticmethod
     def match_os(host, os):
         os = os.lower()
+        found = True
+        if os[0] == "!":
+            os = os[1:]
+            found = False
         os_str = ""

         osmatches = host.get_osmatches()
@@ -158,8 +162,8 @@ class HostSearch(object):
                           osclass['type'].lower()

         if os in os_str:
-            return True
-        return False
+            return found
+        return not found
     @staticmethod
     def match_port(host_ports, port, port_state):
         # Check if the port is parsable, if not return False silently

The syntax would be "os:!windows" to match non-windows hosts, for
example. (There is no problem using exclamation points, since this
is not related to command shell use).

I think it would be better if this applied to all possible matches, not
just os:.

David Fifield
_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/


Current thread: