Nmap Development mailing list archives

[PATCH] Don't require ".nse" be passed to --script


From: Kris Katterjohn <katterjohn () gmail com>
Date: Thu, 15 Nov 2007 20:45:07 -0600

Hey everyone!

I've attached a patch to allow passing only the script name, the filename without the ".nse" extension, to --script.

I've been running multiple scripts, in different categories, and I've had to keep repetitively typing ".nse" on every filename... which I didn't like :)

An example:

--script bruteTelnet.nse,HTTPpasswd.nse,SQLInject.nse,robots.nse

turns into

--script bruteTelnet,HTTPpasswd,SQLInject,robots

Not an *incredibly* dramatic difference, but I much prefer it :)

And sometimes it seems a whole lot better when it's only 1 or 2 scripts.

All it does is try the passed argument (like "bruteTelnet"), and if it doesn't find that file it tries it with ".nse" appended to it, which it will find here.

Please let me know what you think!

Thanks,
Kris Katterjohn
Index: nse_init.cc
===================================================================
--- nse_init.cc (revision 6245)
+++ nse_init.cc (working copy)
@@ -228,12 +228,19 @@
        bool extension_not_matched = false;
        for(iter = unusedTags.begin(); iter != unusedTags.end(); iter++) {
 
+               bool retried = false;
                c_iter = strdup((*iter).c_str());
+               retry:
                type = init_fetchfile(path, sizeof(path), c_iter);
                free(c_iter);
                
                switch(type) {
                        case 0: // no such path
+                               if (!retried) {
+                                       c_iter = strdup((*iter + std::string(SCRIPT_ENGINE_EXTENSION)).c_str());
+                                       retried = true;
+                                       goto retry;
+                               }
                                error("%s: No such category, file or directory: '%s'", SCRIPT_ENGINE, (*iter).c_str());
                                return SCRIPT_ENGINE_ERROR;
                                break;

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

Current thread: