1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-09 14:11:29 +00:00

Allow negative matching in Zenmap filters

nmap-dev thread: http://seclists.org/nmap-dev/2012/q3/788

Host filter and others can now take things like "os:!linux" to match
hosts without Linux OS.
This commit is contained in:
dmiller
2012-09-13 20:24:18 +00:00
parent 2f36d0b968
commit 74a750a855
2 changed files with 10 additions and 2 deletions

View File

@@ -445,7 +445,11 @@ class FilteredNetworkInventory(NetworkInventory):
"""A helper function that calls the matching function for the given
operator and each of its arguments."""
for arg in args:
if not self.__getattribute__("match_%s" % operator)(host, arg):
positive = True
if arg != "" and arg[0] == "!":
arg = arg[1:]
positive = False
if positive != self.__getattribute__("match_%s" % operator)(host, arg):
# No match for this operator
return False
else:

View File

@@ -200,7 +200,11 @@ class SearchResult(object):
"""A helper function that calls the matching function for the given
operator and each of its arguments."""
for arg in args:
if not self.__getattribute__("match_%s" % operator)(arg):
positive = True
if arg != "" and arg[0] == "!":
arg = arg[1:]
positive = False
if positive != self.__getattribute__("match_%s" % operator)(arg):
# No match for this operator
return False
else: