Nmap Development mailing list archives

Re: [NSE] Dropbox LanSync host collection


From: Patrick Donnelly <batrick () batbytes com>
Date: Wed, 15 Dec 2010 05:58:53 -0500

On Wed, Dec 15, 2010 at 5:31 AM, Patrick Donnelly <batrick () batbytes com> wrote:
We have a pretty flexible script "choosing" mechanism now that we have
the boolean operators for categories. Shouldn't we be adding more
categories? I mean, similar to how the "all" category is a
pseudo-category, we could add others such as "quick" which would
translate to: "safe and not broadcast and not newtarget" or something
like that. Or maybe make a legitimate "quick" category?

Seems there are mechanisms in place to make this easy but we are
forgetting about them...

Here's a patch that implements what I'm talking about:

batrick@batbytes:~/nmap/svn/nmap$ svn diff
Index: nse_main.lua
===================================================================
--- nse_main.lua        (revision 21422)
+++ nse_main.lua        (working copy)
@@ -464,11 +464,17 @@
     ["or"] = true,
     ["not"] = true,
   };
+  local pseudocategories = {
+    ["all"] = [[true]], -- everything matches "all"
+    ["quick"] = [[m("safe") and not m("broadcast") and not m("newtarget")]],
+  };
   -- Globalize all names in str that are not protected_lua_tokens
   local function globalize (str)
     local lstr = lower(str);
     if protected_lua_tokens[lstr] then
       return lstr;
+    elseif pseudocategories[lstr] then
+      return pseudocategories[lstr];
     else
       return 'm("'..str..'")';
     end
@@ -501,7 +507,7 @@
     local escaped_basename = match(filename, "([^/\\]-)%.nse$") or
                              match(filename, "([^/\\]-)$");

-    local r_categories = {all = true}; -- A reverse table of categories
+    local r_categories = {}; -- A reverse table of categories
     for i, category in ipairs(categories) do
       assert(type(category) == "string", "bad entry in script database");
       r_categories[lower(category)] = true; -- Lowercase the entry


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


Current thread: