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

82 Commits

Author SHA1 Message Date
djalal
e91c3505be o [NSE] Removed the nmap.get_interface_link function, which was
deprecated by the new nmap.get_interface_info function.
2011-04-22 22:47:28 +00:00
david
c36cf833e6 Add the nmap.get_interface and nmap.get_interface_info functions by
Djalal Harouni.
2011-04-05 06:11:58 +00:00
david
a362d4c48f Fix condvar("signal") when there is nothing waiting on the condvar. The
logic was
  while (unsigned >= 0)
which is an infinite loop.
2011-03-05 21:16:09 +00:00
david
bf99fb231b Check that the argument to freeaddrinfo is not NULL. The behavior may be
unspecified and causes a segmentation fault on Android Bionic libc.
Vlatko fixed the bug in his Android binaries and it was first reported
by @alexismm2.
2011-02-15 08:19:58 +00:00
batrick
8c898d3938 Simplified some code. 2010-09-23 20:13:47 +00:00
batrick
de4ba536de Merge from /nmap-exp/patrick/nse-nsock-maintenance.
This is a maintenance fix for the NSE Nsock library binding. The patch focuses
on code correctness and simplicity. The patch also brings some initial updates
with an eye towards the upcoming Lua 5.2 release. See [1] for a post concerning
this branch.

[1] http://seclists.org/nmap-dev/2010/q3/710
2010-09-18 20:35:09 +00:00
kris
10d23e924f trivial: move a statement back closer to its context 2010-09-17 20:30:27 +00:00
djalal
c9a756bc12 Clean debug messages and make debug level 3 the default debug level for the 'adding new targets' code. 2010-09-03 17:53:34 +00:00
djalal
c7c502b227 Merge r19520:r20039 from nmap-exp/djalal/nmap-add-targets. This will let NSE scripts to add new discovered targets to future Nmap scans. 2010-09-01 01:50:34 +00:00
david
b2350aa947 o [NSE] Host tables now have a host.traceroute member when --traceroute
is used. This array contains the IP address, reverse DNS name, and RTT
  for each traceroute hop. [Henri Doreau]
2010-08-28 15:50:10 +00:00
kris
8729f667fe Some new NSE functions:
o [NSE] Added the nmap.resolve() function which takes a host name and
  optionally an address family (such as "inet") and returns a table
  containing all of its matching addresses.  If no address family is
  specified, then all of the addresses are returned for the name. [Kris]

o [NSE] Added the nmap.address_family() function which returns the address
  family Nmap is using as a string (e.g., "inet6" is returned if Nmap is
  called with the -6 option). [Kris]
2010-08-27 04:17:51 +00:00
david
11e70075fa Revert r19975, wrong external. 2010-08-26 19:51:22 +00:00
david
611cc22676 Fix a copy-paste error. 2010-08-26 19:50:45 +00:00
kris
57664a51cf Committing MTU-related changes:
* Adding path-mtu.nse for Path MTU Discovery
* Nmap now stores the MTU for interfaces (from SIOCGIFMTU or libdnet)
* Scripts can access the MTU for host.interface via host.interface_mtu
* Nmap prints the MTU for interfaces in --iflist
2010-08-24 01:47:12 +00:00
kris
412fcbcca0 o [NSE] Added a "times" table to the host table passed to scripts.
This table contains Nmap's timing data (srtt, the smoothed round
  trip time; rttvar, the rtt variance; and timeout), all represented
  as floating-point seconds.  The ipidseq and qscan scripts were
  updated to utilize the host's timeout value instead of the very
  conservative guess of 3 seconds for read timeouts. [Kris]
2010-08-05 01:55:05 +00:00
kris
cc33a59ca4 Add nmap.clock() for providing scripts with the current time in floating
point seconds since the epoch, and add clock_ms() and clock_us() to stdnse
for convenience (millisecond and microsecond).

qscan.nse now provides microsecond resolution.
2010-07-23 19:49:42 +00:00
batrick
b70fe49adf Compact/share some code. 2010-07-19 12:25:24 +00:00
batrick
204c2ba4b0 Clean up code. Fix port.version.service_fp not getting set properly.
Added field service_dtype (which was replacing service_fp) to version table.
2010-07-17 11:59:04 +00:00
batrick
305faeff21 Remove old #include. 2010-07-17 10:55:38 +00:00
djalal
72a06a3b5c Merge r18160:18278 from nmap-exp/djalal/nmap-nse/ to fix NSE not honoring the exclude directive bug. 2010-06-29 21:56:59 +00:00
kris
a42ea72a97 Merge through r16884 from /nmap-exp/kris/nse-rawip plus the following changelog
entries:

o [NSE] Raw packet sending at the IP layer is now supported, in addition to
  the Ethernet sending functionality.  Packets to send start with an IPv4
  header and can be sent to arbitrary hosts. [Kris]

o [NSE] Added the ipidseq script to classify a host's IP ID sequence numbers
  in the same way Nmap does.  This can be used to test hosts' suitability for
  Nmap's Idle Scan (-sI), i.e. check if a host is an idle zombie.  This is
  the first script to use the new raw IP sending functionality in NSE. [Kris]

o [NSE] Added the function nmap.is_privileged() to tell a script if, as far
  as Nmap's concerned, it can do privileged operations.  For instance, this
  can be used to see if a script should be able to open a raw socket or
  Ethernet interface. [Kris]

o [NSE] Added the function nmap.get_ports() to allow a script to iterate
  over a host's port tables matching a certain protocol and state. [Kris,
  Patrick]
2010-02-26 20:42:10 +00:00
david
3a11dafeaa o Added a mac_addr_next_hop member to the host tables used in NSE.
[Michael Pattrick, kx].
2010-02-13 01:48:59 +00:00
david
7db7da0007 Merge again from /nmap-exp/david/nmap-mem; this fixes a couple of bugs. 2009-12-20 03:22:19 +00:00
david
1c6030709b Revert r16307:16309, the merge from nmap-mem. I just found a
segmentation fault which I am investigating.
2009-12-19 22:49:16 +00:00
david
b838242e01 Merge from /nmap-exp/david/nmap-mem. This brings in two memory-reducing
changes. The first is that Port objects don't allocate memory for
service and RPC results unless that information is set. This reduces the
size of a bare Port from 92 to 40 bytes on my machine. The second change
is that PortList now has the notion of a "default port state," which is
the state of any ports that didn't receive a response. These ports don't
need an allocated Port object, which saves a lot of memory in scans
where most ports didn't get a response.
2009-12-19 21:26:14 +00:00
david
e2315ae075 Remove the unused Port::owner member. 2009-11-20 20:17:33 +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
68a9147b69 [NSE] Fixed some bugs in the vhosts patch applied in 15342:
o Stack indices for the 'ip' and 'targetname' strings were wrong.
  o Moved the lightuserdatum check right before done so a nil can't slip
    through.
2009-08-29 20:21:58 +00:00
batrick
3c14c0d7b1 [NSE] Added
nse_gettarget (lua_State *L, int index);
to replace the current_hosts static variable shared between nse_main.cc
and nse_nmaplib.cc. This improves locality and offers a clearer interface.
2009-08-29 01:24:29 +00:00
batrick
b61ed83e14 [NSE] Patch to allow virtual hosts (specified by name on the command line)
which resolve to the same IP to have script output placed under the correct
(virtual) host.  Previously, all script output would be "randomly but
deterministically" placed under one of these hosts.  Other problems include
having port information changed for only one of the virtual hosts.
2009-08-28 02:48:56 +00:00
batrick
6bbfb06704 Check the stack size before moving elements to the thread.
Some threads have truncated stacks after finishing with an error causing
a Lua assertion failure when we put elements on the stack without first
checking whether space is available.
2009-08-11 05:56:10 +00:00
batrick
4ec75b15b7 Removed an unnecessary intermediary buffer for string copying. 2009-08-09 02:55:29 +00:00
batrick
01c25ab29e [NSE] Patch to move the call NSE_SELECTED_BY_NAME to nse_main.cc for
improved locality. Other Lua Registry functions called by C were wrapped in
a C API inside nse_main.cc.
2009-07-14 22:41:25 +00:00
batrick
490c0c3b57 Add destructor for mutex "trylock" case (was forgotten in mutex destructor
patch).
2009-07-14 11:36:39 +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
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
68bf664db6 [NSE] Applied change to remove the old nse_macros.h header file.
Here is a mostly exhaustive list of the changes:

o Removes the SCRIPT_ENGINE_* status defines and replaces the
  instances with regular boolean integer returns or changes the
  procedure to return void. The latter case is better generally because
  the caller ignores any status return (e.g. nmap.cc calling open_nse)
  and/or the procedure raises a fatal error when unsuccessful.

o Moves the SCRIPT_ENGINE_LUA_DIR and the like to the nse_main.h header file.

o Removes the use of the SCRIPT_ENGINE_TRY (there was only one left)
  and thus changes the call to l_dnet_open to a void function called
  directly by luaopen_nsock (in nse_nsock.cc) instead of luaopen_nmap
  (in nse_nmaplib.cc). I felt moving the function was also an
  appropriate (but somewhat unrelated to the intent of the patch) change
  as opening the dnet metatable is very related to opening up the
  nsock library. This confines errors in opening the nsock library, including
  opening the dnet metatable, to the call to luaopen_nsock.

o The FILES and DIRS defines are moved in to nse_fs.h where they are
  more appropriate and localalized.
2009-06-07 01:25:53 +00:00
daniel
50830f7488 o Added initial SCTP port scanning support to Nmap. SCTP is
a layer 4 protocol used mostly for telephony related applications.
  This brings the following new features:
  o SCTP INIT chunk port scan (-sY): open ports return an INIT-ACK
    chunk, closed ones an ABORT chunk.  This is the SCTP equivalent
    of a TCP SYN stealth scan.
  o SCTP COOKIE-ECHO chunk port scan (-sZ): open ports are silent,
    closed ports return an ABORT chunk.
  o SCTP INIT chunk ping probes (-PY): host discovery using SCTP
    INIT chunk packets.
  o SCTP-specific IP protocol scan (-sO -p sctp).
  o SCTP-specific traceroute support (--traceroute).
  o The ability to use the deprecated Adler32 algorithm as specified
    in RFC 2960 instead of CRC32C from RFC 4960 (--adler32).
  o 42 well-known SCTP ports were added to the nmap-services file.
  Part of the work on SCTP support was kindly sponsored by
  Compass Security AG, Switzerland.  [Daniel Roethlisberger]
2009-06-03 23:15:45 +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
batrick
3e4950eec2 Minor patch to change error messages to be lowercase as is common.
Also moved to an enumeration of mutex operations rather than hard coded
constants inside the switch.
2009-06-02 05:27:48 +00:00
batrick
fc6d15eb4f Removed some extraneous whitespace. 2009-05-17 19:43:21 +00:00
batrick
37bbb40520 Merge of nse-lua (nse-lua-merge) minus most enchancements that were
not directly related to the change from C++ to Lua for the NSE main
procedures.

The changes are discussed in the nse-lua thread here:
http://seclists.org/nmap-dev/2009/q1/0047.html
2009-04-05 06:01:27 +00:00
batrick
07cfc5aee4 Corrected many #includes for header files (where they are included).
Moved the includes for Lua headers to the .cc files so they are
not needlessly, repeatedly included.

Similarly, moved some standard headers to the .cc files and reorganized
includes to be uniform for all nse_* source files.

Fixed whitespace (removed tabs).
2009-03-10 05:56:10 +00:00
batrick
9a81f00641 Removed INITIAL from port version enum (it was accidently left in). 2009-03-09 10:56:45 +00:00
david
a173fe6ce1 Add the stdnse.sleep function. 2009-02-23 23:57:39 +00:00
batrick
1a22089dd0 Changed nil or none to be acceptable for the first value of the try function. 2008-12-30 06:56:44 +00:00
batrick
3016193c11 Improvements to the nmap library. See [1] for discussion and a full listing of
the changes.

[1] http://seclists.org/nmap-dev/2008/q4/0663.html
2008-12-29 21:59:08 +00:00
batrick
e6505d9954 Corrected nmap.print_debug_unformatted to print if the verbosity is greater
than or _equal_ to the specified verbosity.
See http://nmap.org/nsedoc/modules/stdnse.html#print_debug
2008-12-07 09:22:29 +00:00
batrick
c361d17734 Cleaned up some code for mutexes. 2008-12-07 01:25:14 +00:00
batrick
0f28f2818b Fixed host.os table to be a 1 based array rather than 0 based. 2008-11-20 20:30:43 +00:00