1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 21:51:28 +00:00
Commit Graph

102 Commits

Author SHA1 Message Date
batrick
bd387f6826 With debugging, NSE prints out the script-args string and the pretty printed
final script-args table. The rationale is, unfortunately shells interpret
quotes differently and so it can be hard to tell exactly what NSE ends up
seeing/producing. [Some discussion in #nmap on Freenode resulted in this
addition.]
2013-06-23 02:40:28 +00:00
batrick
48b604bcd2 The directory path was being passed to Script.new rather than the file in the
directory. This bug was reported by Robin Wood [1].

[1] http://seclists.org/nmap-dev/2013/q2/282
2013-05-12 21:24:16 +00:00
david
a1cc3690cc Include the targetname if possible in NSE diagnostic messages. 2013-02-07 23:26:18 +00:00
batrick
e8caacae85 Read large chunks instead of lines. 2012-12-16 00:24:37 +00:00
batrick
76239f73b9 Escape backslashes which may appear in Windows filenames. 2012-12-16 00:02:08 +00:00
david
ad65ddb777 Simplify a boolean condition. 2012-10-18 03:18:07 +00:00
batrick
164fbe284b o Added a "Worker" class which helps encapsulate behavior better.
o Moved some specific behavior for resuming a thread to Thread:resume().
o Cleaned up the inheritance mechanism to use a static metatable (the Class
  table itself).
o Worker main functions are no longer wrapped with a function to truncate to 0
  results. Instead, we just check if a thread is a worker in Thread:set_output()
  to prevent adding output by worker threads.
2012-10-09 07:16:01 +00:00
batrick
4fe62b040c Better response to misuse of stdnse.base|new_thread when not executing an
action function (current == nil).
2012-09-23 21:31:02 +00:00
david
676de05f7f Provide a default {} value for script categories.
This is so I don't have to write
  categories = {}
when writing test scripts.
2012-08-28 12:17:36 +00:00
david
fdac9750a1 No longer require the "description" field in scripts.
This is so I don't have to do
  description = ""
when writing test scripts.
2012-08-28 12:17:27 +00:00
dmiller
c3f88169a4 Fix NSE error: attempt to get length of a number
NSE: Script Engine Scan Aborted.
An error was thrown by the engine: attempt to get length of a number
value
stack traceback:
        [C]: in function 'port_set_output'
        /home/rt/builds/nmap/nse_main.lua:314: in function 'set_output'
        /home/rt/builds/nmap/nse_main.lua:947: in function 'run'
        /home/rt/builds/nmap/nse_main.lua:1330: in function
</home/rt/builds/nmap/nse_main.lua:1237>
        [C]: in ?

This now allows return of anything stringifiable as second return value
without crashing (though this may not be what the script author intends,
better to not crash)
2012-08-23 18:45:42 +00:00
batrick
24e38466f5 Do version checking for Lua 5.2. 2012-08-14 22:19:09 +00:00
dmiller
c5d642a340 Check for nil return from scripts to avoid empty <script> elements 2012-08-14 17:25:43 +00:00
david
0c3e0fcc4d Structured script output.
Scripts may now return a key–value table, or such a table in addition to
a string. The table will be automatically formatted for normal output
and will appear as a hierarchy of elements in XML output.

Some history and discussion of this development can be found at
https://secwiki.org/w/Nmap/Structured_Script_Output.

This is a merge of r29484:29569 from /nmap-exp/david/xml-output.
2012-08-14 16:36:25 +00:00
patrik
6f43ac38b2 SSL overhaul fixing OpenSSL related problems when SSL has not been compiled in
* replace require function calls with stndse.silent_require
* fixed a bug in nse_main that would fail creating scripts.db when a script
  fails to load
* reworked some code to provide limited functionality even though SSL is not
  present
2012-08-05 12:05:07 +00:00
batrick
715525f31b Throw an actual error. Do not yield. 2012-08-05 09:16:04 +00:00
perdo
6e5b999c99 Add parts of LuaFileSystem to NSE (support for mkdir, rmdir, link). 2012-07-17 18:07:28 +00:00
batrick
bbea3dc088 "Start" the worker thread so the host timeout accounting is correct.
Also add to num_threads for accounting.
2012-07-14 22:32:37 +00:00
batrick
000f6dc4d9 Lua 5.2 upgrade [1] for NSE.
[1] http://seclists.org/nmap-dev/2012/q2/34
2012-05-27 08:53:32 +00:00
patrik
59b30bacf8 o [NSE] Added an error message indicating script failure, when Nmap is being
run in non verbose/debug mode. [Patrik Karlsson]
2012-04-04 21:11:20 +00:00
patrik
72af4637b0 o [NSE] Added host based registry, which allows scripts to share data between
scripts scanning a specific host. [Patrik]
2012-02-22 20:03:15 +00:00
david
be73a3e9e9 Put the nselib/* loader at the front, not the end, of the loaders list.
The loaders list determines the order in which places are checked for
Lua modules. I had a problem on Windows when the nmap.exe directory
contained WinPcap's packet.dll. There was a runtime error when liblua
tried to open packet.dll instead of our packet.lua. This way we check
for our own files first.
2012-02-08 22:28:06 +00:00
fyodor
bb62bab448 o Added the new --script-args-file option which allows you to specify
the name of a file containing all of your desired NSE script
  arguments.  The arguments may be separated with commas or newlines
  and may be overridden by arguments specified on the command-line
  with --script-args. [Daniel Miller]
2012-01-03 07:14:20 +00:00
batrick
165b58f3d3 minor improvements 2011-12-16 21:01:09 +00:00
patrik
2197116d18 o [NSE] Added support for forcing scripts to run agains certain ports by adding
a plus in front of the script name. [Martin Swende]
2011-12-16 20:37:46 +00:00
batrick
110b0d35b0 Fixed a bug I introduced in r23911 that caused some "rules" to not
mark a script as selected by name.
Removed some dead code.
2011-09-30 06:54:53 +00:00
batrick
8628520123 Change module separator to directory separator as is done in
Lua's ?.lua loader. This is necessary when requiring submodules
e.g. require "foo.bar"
2011-09-20 18:24:09 +00:00
batrick
6069b50ce3 Add loader for searching nselib/ for ?.lua files. nselib/ can be in multiple
directories that nmap will search, e.g. ~/.nmap/nselib $NMAPDIR/nselib
/usr/share/nmap/nselib etc.

Resolves Daniel Miller's request [1].

[1] http://seclists.org/nmap-dev/2011/q3/817
2011-09-20 16:18:35 +00:00
djalal
7d0df638ab o [NSE] When the rule function failes include its type in the error message. 2011-08-16 01:24:46 +00:00
djalal
39be3a4621 o [NSE] Use the correct variable 'value' instead of 'rule_return' to
show the error message of the rule function and why it has failed.
2011-08-16 01:22:01 +00:00
batrick
4d27d83f62 Fix to make SCRIPT_NAME not have a filename extension in certain situations.
See [1].

[1] http://seclists.org/nmap-dev/2011/q3/304
2011-07-21 18:26:11 +00:00
batrick
9d7ce06a96 better error message when script fails to load (now includes traceback of the script) 2011-07-21 17:46:16 +00:00
batrick
dc9a35bc9d New system for silent require errors. Use the new function
stdnse.silent_require. The Lua require function is back in its usual spot
(_G.require).
2011-06-13 23:38:35 +00:00
batrick
e37cfc5d0e moved some debug output where it made more sense
fixed some formatting
2011-06-13 22:59:30 +00:00
batrick
aa2f54ffa3 Originally, adding the script to the array of scripts would handle the case
where the Script.new failed:

    chosen_scripts[#chosen_scripts+1] = Script.new(path);

if Script.new returns nil, then the operation is a no-op (as intended). So,
just add the script to the array. Script.new now accepts a selected_by_name
argument so we don't set it manually.
2011-06-12 01:47:36 +00:00
batrick
a26f606ecd Just use srand on NSE startup in nse_main.cc. This removes the need
for a binding which will probably not be useful for script writers
when they have OpenSSL's PRNG already available.
2011-05-24 02:48:39 +00:00
batrick
3b83666a9c use a random number from /dev/urandom (nbase.get_random_uint wrapper) 2011-05-24 00:09:42 +00:00
batrick
5a68e5f04a Set the math.randomseed value in nse_main.lua on behalf of scripts.
Since Lua uses the C rand and srand functions, which have a static
seed for the entire program, we don't want scripts doing this themselves.
2011-05-23 21:43:46 +00:00
batrick
7f66646636 Patch to make require errors silent and removed evil workarounds.
Added new stdnse function stdnse.print_verbose (similar to print_debug).
2011-05-04 21:06:53 +00:00
david
a9a84873f9 Add a new cnse.fetchscript, which first checks for an absolute path,
then looks in the scripts subdirectory, then in the current directory.
cnse.fetchfile_absolute now checks for an absolute path, then calls
nmap_fetchfile if that fails (and no longer looks in scripts/). Use
cnse.fetchscript when accessing files that should be in the scripts
subdirectory.
2011-03-26 06:48:29 +00:00
david
b1e3114eca Move the "Script Pre-scanning", "Script scanning", and "Script
Post-scanning" messages to inside the run function, so they can be
printed only after we're sure we have at least one thread to run.
2011-02-01 18:16:27 +00:00
david
c0f8979b01 Require a verbosity of 2 or higher for "NSE: Starting runlevel 1 (of 2)
scan." messages. (Was 1 or higher.)
2011-02-01 17:18:12 +00:00
djalal
d1b34654b8 Fix a bug which caused some NSE scripts to fail, due to the absence of
the NSE SCRIPT_NAME environment variable when the scripts are loaded.
Reported by Michael Pattrick.
2011-01-30 23:31:57 +00:00
batrick
9b135b281f localize some function calls 2011-01-28 13:54:05 +00:00
david
5fa2e66900 Include the "scripts" and "nselib" directory paths in XML --script-help
output.
2011-01-28 04:15:21 +00:00
david
8553cb3157 Merge r22026 through r22063 from /nmap-exp/david/nmap-script-help (new
--script-help option).
2011-01-27 21:44:54 +00:00
batrick
52a0bf19b8 Relocate a local among other constants/configurations. 2011-01-14 15:44:33 +00:00
david
acffcdfc82 Move banners announcing the start of a script scan phase out of the
threads_iter function.
2011-01-08 07:20:42 +00:00
david
9857411032 Pre-prime the first list of CONCURRENCY_LIMIT threads, and bail out
early if there are none to be run. This avoids printing
ScanProgressMeter messages.
2011-01-08 07:20:40 +00:00
david
1392faf5d4 Remove runlevel_scripts, which had become just a wrapper around ipairs. 2011-01-08 07:20:39 +00:00