1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 05:01:29 +00:00
Commit Graph

63 Commits

Author SHA1 Message Date
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
ron
3ded2339e8 Fixed an issue in script dependencies that caused the later scripts to begin without waiting for the earlier scripts to finish. Patch written by Patrick Donneley. 2010-12-13 16:22:14 +00:00
batrick
4b481939b3 Reverting 21172, it was actually correct. 2010-11-24 21:10:20 +00:00
batrick
ce8c422f7d Fixed debug format. 2010-11-24 21:05:13 +00:00
david
c12e4c93fb Remove the call to sort the runlevel table. Patrick changed this code so
that it is built sorted, and also changed the structure of the table so
that sorting it raises an error. Patrik noticed the error.
2010-11-20 15:35:58 +00:00
batrick
c5cfd3128e Fixed some whitespace|formatting and made a small improvement to the iterator. 2010-11-17 22:12:54 +00:00
batrick
856c6fc3c6 Removed some unnecessary returns. 2010-11-17 21:02:52 +00:00
david
78877af7e8 o [NSE] There is now a limit of 1,000 concurrent running scripts,
instituted to keep memory under control when there are many open
  ports. Nathan reported 3 GB of memory use (with an out-of-memory NSE
  crash) for one host with tens of thousands of open ports. This limit
  can be controlled with the variable CONCURRENCY_LIMIT in
  nse_main.lua. [David]
2010-11-17 19:31:24 +00:00
david
4a4e67bd2c Set the close_handlers member in worker Thread objects. The lack of this caused
them to use the close_handlers table of the parent thread that spawned them
instead. See http://seclists.org/nmap-dev/2010/q3/804 for more details.
2010-09-23 16:32:11 +00:00
batrick
b92ce14522 clearer error message 2010-09-13 23:28:15 +00:00
batrick
45c8180971 Changed some of the formatting. 2010-09-13 06:07:19 +00:00
djalal
81592359e4 Added a new function to save new created NSE threads in the threads table. 2010-08-31 20:25:18 +00:00
batrick
7b40aa34c5 formatting 2010-08-12 18:29:40 +00:00
kirubakaran
68fd970ec1 Adding comments to nmap debug print message 2010-08-12 15:18:58 +00:00
djalal
0ae240c1e8 Reset the script engine verbosity that was boosted when scripts are selected by name. 2010-08-11 22:37:16 +00:00
batrick
f46908f0bd Require each Lua library explicitly (debug in particular). Requiring the "debug"
library is necessary for Lua 5.2.
2010-08-10 16:51:10 +00:00
kirubakaran
b35255c8e9 Adding verbosity to nmap debug option -d2 to print the whole path of scripts specified in rule 2010-08-10 16:20:07 +00:00
djalal
f0c5e154c3 Merge r18689:r19511 from /nmap-exp/djalal/nse-rules.
o Add two new Script scan phases:
  Script Pre-scanning phase: before any Nmap scan operation, activated by the new "prerule".
  Script Post-scanning phase: after all Nmap scan operations, activated by the new "postrule".
o New environment variables:
  SCRIPT_PATH
  SCRIPT_NAME
  SCRIPT_TYPE: the type of the rule that activated the script.
2010-08-06 16:40:03 +00:00
batrick
c08922c411 Reset environment after creating new script thread. (This may fix problems with
some memory not being reclaimed.)
2010-07-10 06:03:15 +00:00
batrick
45a51eff5c Move Script Database Update code from nse_main.cc (Lua code embedded in C
strings) to nse_main.lua.
2010-07-07 16:31:17 +00:00
djalal
24807128d2 Merge r17640:18062 from /nmap-exp/djalal/nmap, this is a port of the LuaFileSystem directory iterator in order to use Lua code to list scripts. 2010-06-12 21:41:09 +00:00
fyodor
3cc34c37ee Removed a line which generated a report like "NSE: Script Scanning
completed." due to two issues.  One is that we already have a
different line printed in verbose mode which looks like "Completed NSE
at 14:31, 0.27s elapsed".  The other problem is that this was being
printed in non-verbose mode when you specified an argument like
"--script ssl-cert".  We intentionally bump the verbose mode of
scripts when they are specified individually like that so they can
report more script results, but I don't think we need the NSE
infrastructure itself to become more verbose.
2010-05-01 21:35:59 +00:00
batrick
0f1b1626c4 whitespace change 2010-04-08 20:27:05 +00:00
batrick
b6d57382e3 Fix bug where Lua will load original, optional Lua libraries when we have
custom libraries that must be used instead. (So, try to load our libaries
first, then look through system paths.) This bug is very rare since these
optional libraries are very rarely installed in most distributions.

Bug found by Onur K. [1].

[1] http://seclists.org/nmap-dev/2010/q1/197
2010-01-21 18:56:30 +00:00
batrick
610bd0a55b Merge from Dependencies branch (nmap-exp/patrick/dependencies)
with modifications from [2].

** Short description from [1] **

I have created a patch to NSE that replaces runlevels with a table of
dependencies that clearly outlines what other scripts the script
depends on. The table is of the form:

dependences = {"script1", script2", ...}

Runlevels become an internal representation of the order of scripts
that are generated by the dependencies. Dependencies only enforce
an execution order and not a requirement for execution.

[1] http://seclists.org/nmap-dev/2009/q4/295
[2] http://seclists.org/nmap-dev/2009/q4/446
2009-12-30 02:34:05 +00:00
batrick
5e9c3dea5a Remove dead threads from the all table as they are no longer valid. 2009-11-25 00:59:46 +00:00
david
fd7ab53772 Put the target IP address in NSE host timeout messages. 2009-11-21 00:46:03 +00:00
batrick
2b3df5882f [NSE] Patch to add worker threads to NSE for scripts to use. Right
now a script is limited in parallelism to working on one socket at any
time. A script can now create a worker thread that will be capable of
doing work on sockets in parallel with the parent script. See [1] for
more information.

This patch also comes with condition variables that are similar to
POSIX condition variables. They are used in the same fashion as
NSE's mutexes (nmap.mutex).

[1] http://seclists.org/nmap-dev/2009/q4/294
2009-11-12 01:33:52 +00:00
batrick
34b30d9b7f [NSE] Patch to nse_main.lua to print out all active scripts (running & waiting)
at debugging level 2 or higher and when a key is pressed. This is especially
useful when we have a rare deadlock and we want to know which scripts are
involved and where (a traceback is also printed).
2009-08-20 00:36:49 +00:00
batrick
cf9ed0d411 [NSE] --script-args may now have whitespace in unquoted strings (but
surrounding whitespace is ignored). Here is a simple example for clarity:
  --script-args 'greeting = This is a greeting'
  Becomes: { ["greeting"] = "This is a greeting" }
2009-07-25 19:45:05 +00:00
batrick
cadc08047f [NSE] Add the filename and runlevel globals to scripts when loaded via
Script.new. Because of the new strict.lua library being added, scripts
would look for the absent filename global at load-time and fail due to an
error (ssh-hostkey.nse).
2009-07-21 22:21:48 +00:00
batrick
9d5de2a9d1 Added strict library for libraries (and scripts). The module function is
replaced so that all NSE modules will have strict declared global checking at
runtime. This should catch most developer errors early. Please see [1] for
further reference into the problem.

[1] http://seclists.org/nmap-dev/2009/q3/0070.html
2009-07-15 15:14:00 +00:00
david
276a2f195c [NSE] Scripts that are listed by name with the --script option now
have their verbosity level automatically increased by one. Many
will print negative results ("no infection found") at a higher
verbosity level. The idea is that if you ask for a script
specifically, you are more interested in such results.
2009-07-12 19:35:56 +00:00
david
47e79670b6 Add a comment explaining how the NSE_YIELD, NSE_DESTRUCTOR et al.
registry keys are used.
2009-07-09 22:56:04 +00:00
david
cd820ba39b Show the host and port when a script throws an error. 2009-07-08 19:32:40 +00:00
fyodor
9ca4041ec1 Merged -r13793:HEAD from nmap-exp/dev/nmap branch now that we're opening up trunk development
again.  Here are the items which were merged:

------------------------------------------------------------------------
r13971 | jah | 2009-06-29 14:30:27 -0700 (Mon, 29 Jun 2009) | 2 lines

Improved a pattern for matching HTTP status-line, tidy away some variables and
fix a typo.
------------------------------------------------------------------------
r13967 | daniel | 2009-06-29 13:47:04 -0700 (Mon, 29 Jun 2009) | 5 lines

o Added a convenience top-level BSD makefile redirecting BSD make
  to GNU make on BSD systems.  This should help prevent bogus
  error reports when users run "make" instead of "gmake" on BSD
  systems. [Daniel Roethlisberger]

------------------------------------------------------------------------
r13965 | batrick | 2009-06-29 06:50:11 -0700 (Mon, 29 Jun 2009) | 14 lines

[NSE] The NSE Nsock Library binding no longer relies on garbage collection to
monitor the use of socket "slots". A thread (script) attempting to connect must
first obtain one of a limited number of available socket locks (usually 10 or
--max-parallelism). The binding would use garbage collection of sockets to
determine when a thread has finished using its allocated sockets. This is
unfortunately slow and requires us to constantly run the garbage collector to
cause timely reallocation. I have changed the binding to now regularly inspect
allocated sockets in the nsock_loop function. Available sockets slots are now
immediately reallocated and done with far less execution time.

See [1] for benchmarks and further explanation.

[1] http://seclists.org/nmap-dev/2009/q2/0624.html

------------------------------------------------------------------------
r13964 | batrick | 2009-06-29 06:37:49 -0700 (Mon, 29 Jun 2009) | 10 lines

[NSE] Fixed a rare (and usually undetectable) bug that can cause a SEGFAULT.
The NSE nsock library binding may attempt to push values on the stack of
a thread that ended due to an error. It is possible that the internal
Lua stack was completely full and any further pushed values would result
in a segmentation memory violation.

This bug is very hard to reproduce with a SEGFAULT but is usually visible
when Lua assertion checks are turned on. A socket handler routine must be
called AFTER a thread has ended in error.

------------------------------------------------------------------------
r13963 | batrick | 2009-06-29 05:51:20 -0700 (Mon, 29 Jun 2009) | 3 lines

Fixed some global scoped variables to be local. This caused a many scripts to
overwrite each others' sockets, options, etc.

------------------------------------------------------------------------
r13939 | joao | 2009-06-27 16:07:35 -0700 (Sat, 27 Jun 2009) | 2 lines

Fixed port rule to include ssl pop3 port, now that pop3.lua supports SSL connections in function capabilities

------------------------------------------------------------------------
r13938 | joao | 2009-06-27 16:06:28 -0700 (Sat, 27 Jun 2009) | 2 lines

Added transparent SSL support using comm.tryssl

------------------------------------------------------------------------
r13937 | joao | 2009-06-27 16:05:19 -0700 (Sat, 27 Jun 2009) | 2 lines

Added transparent SSL support using comm.tryssl

------------------------------------------------------------------------
r13936 | joao | 2009-06-27 16:03:50 -0700 (Sat, 27 Jun 2009) | 2 lines

Added SSL transparent support using comm.tryssl

------------------------------------------------------------------------
r13935 | joao | 2009-06-27 16:02:39 -0700 (Sat, 27 Jun 2009) | 2 lines

Added SSL transparent support using comm.tryssl

------------------------------------------------------------------------
r13934 | joao | 2009-06-27 16:01:38 -0700 (Sat, 27 Jun 2009) | 2 lines

Added SSL transparent support using comm.tryssl

------------------------------------------------------------------------
r13933 | joao | 2009-06-27 16:00:27 -0700 (Sat, 27 Jun 2009) | 2 lines

SSL transparent support using comm.tryssl

------------------------------------------------------------------------
r13932 | joao | 2009-06-27 15:19:58 -0700 (Sat, 27 Jun 2009) | 2 lines

Included transparent ssl support to function pop3.capabilities using comm.tryssl

------------------------------------------------------------------------
r13931 | joao | 2009-06-27 15:19:06 -0700 (Sat, 27 Jun 2009) | 3 lines

New version of comm.lua with function tryssl, that transparently adds support to ssl connections


------------------------------------------------------------------------
r13930 | joao | 2009-06-27 14:50:38 -0700 (Sat, 27 Jun 2009) | 6 lines

Fixed buffering problem exposed by david on nmap-dev list.
The problem was solved using a buffer to receive the data, making the script work fine in cases where the ssh packets are fragmented.

A very similar solution was applied to ssh1.lua.


------------------------------------------------------------------------
r13928 | batrick | 2009-06-27 04:43:12 -0700 (Sat, 27 Jun 2009) | 18 lines

[NSE] We now propogate a NSE initiated yield on a script through all user
coroutines so that NSE may resume control. Previously, scripts that would yield
in a child coroutine (e.g. a script's child coroutine generated by Lua's
coroutine.create function) would give control back to the script. A script
would yield in this way by making a blocking socket operation. NSE would be
unable to correctly resume child coroutine when the socket operation is
finished processing.

By yielding the chain of coroutines a script has operating, we allow to NSE to
handle the socket operation properly. NSE would then resume the entire chain so
execution may correctly resume at the coroutine which initiated the socket
operation. This restores the "illusion" that a script executes without
interruption.

See [1] for more information, further explanation, and some use cases.

[1] http://seclists.org/nmap-dev/2009/q2/0586.html

------------------------------------------------------------------------
r13817 | david | 2009-06-18 15:57:29 -0700 (Thu, 18 Jun 2009) | 3 lines

Improve an OS fingerprint with a model number and broader matching.
Based on a follow-up report from a submitter.

------------------------------------------------------------------------
r13814 | josh | 2009-06-17 21:34:15 -0700 (Wed, 17 Jun 2009) | 3 lines

[zenmap] Added support to zenmap for the new SCTP options: -PY, -sY and -sZ


------------------------------------------------------------------------
r13797 | ron | 2009-06-17 11:02:18 -0700 (Wed, 17 Jun 2009) | 1 line

Applied a patch from Mak Kolibabi that enhances the output of smb-enum-processes. The output is now modeled after the output of the 'ps' tool for higher verbosity levels.
------------------------------------------------------------------------
r13795 | david | 2009-06-17 09:05:21 -0700 (Wed, 17 Jun 2009) | 6 lines

The configure script now allows cross-compiling by assuming that
libpcap is recent enough. Previously it would quit because a test
program could not be run. libpcap will always be recent enough when
the included copy is used. The patch was contributed by Mike
Frysinger.
2009-06-29 23:48:19 +00:00
batrick
105e9365b8 Added note on convention for localizing all globals needed at the beginning
of the script.
2009-06-03 05:45:19 +00:00
batrick
d569d5b75e Removed a debug statement that was left in. 2009-06-03 05:40:30 +00:00
batrick
e31c5973b1 Corrected a comment. 2009-06-03 05:38:44 +00:00
batrick
93c4f35f2e [NSE] When a script ends for any reason, all mutexes are now unlocked.
Some scripts would fail due to an error (whois.nse) causing other
scripts to become deadlocked on a mutex that would never unlock. This
patch fixes this problem. See [1] for more information.

[1] http://seclists.org/nmap-dev/2009/q2/0533.html
2009-06-03 03:40:13 +00:00