1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 04:31:29 +00:00
Commit Graph

129 Commits

Author SHA1 Message Date
dmiller
7d57e7d6b1 Update Lua to 5.4.4 2023-05-01 17:44:45 +00:00
dmiller
f59d546c8f Use existing Lua strings for script output; avoid creating copies. 2022-11-16 15:55:54 +00:00
dmiller
d81ead72dc New C backend for datafiles.lua; avoid copies of large data sets 2022-09-29 22:19:28 +00:00
dmiller
f17fa67008 Avoid copying script results; store pointers instead. 2021-04-29 17:52:24 +00:00
dmiller
bf9d60734d Use std::multiset to keep script outputs in order instead of sorting. 2021-04-27 19:22:09 +00:00
dmiller
3ecec3f4dc Correct to DTD, explicitly show empty output. See #2216
This shouldn't happen, so we'll print a "bug" error message so users
notify us.
2021-01-01 19:25:56 +00:00
dmiller
a0b05c0f4f Require trailing '/' to match a directory name with --script. See #2051 2020-08-28 15:06:10 +00:00
dmiller
28f3b4910a Don't script-scan targets that are already timed out 2018-08-13 19:24:05 +00:00
dmiller
e4f65348cb Use lua_createtable to prealloc some tables, saving time & memory 2018-06-28 03:43:25 +00:00
dmiller
2a1f81d42d Use bool not int for boolean options 2017-12-07 18:20:07 +00:00
dmiller
b57d23f005 Add zlib binding for NSE. Fixes #532 2017-09-13 01:54:19 +00:00
dmiller
e0dcb3b8a9 Track NSE targets by IP first, then by targetname. 2017-08-07 14:25:14 +00:00
evangel
0c142333bb Merged gsoc-ssh branch. Closes #910 2017-06-29 21:27:35 +00:00
abhishek
cd0b373130 Add --script-timeout option to limit the script's runtime. Closes #330 and Fixes #234. 2016-08-20 18:57:47 +00:00
tudor
6c8a753013 CONCURRENCY_LIMIT in NSE can be increased above 1000 with a higher --min-parallelism value 2016-07-22 05:18:32 +00:00
batrick
7f5ec526fe Merge branch 'nse-lua53'
Lua 5.3 adds several awesome features of particular interest to nmap including
bitwise operators and integers, a utf8 library, and standard binary pack/unpack
functions.

In addition to adding Lua 5.3, this branch changes:

o Complete removal of the NSE bit library (in C), It has been replaced with
  a new Lua library wrapping Lua 5.3's bit-wise operators.

o Complete removal of the NSE bin library (in C). It has been replaced with a
  new Lua library wrapping Lua 5.3's string.pack|unpack functions.

o The bin.pack "B" format specifier (which has never worked correctly) is
  unimplemented.  All scripts/libraries which use it have been updated. Most
  usage of this option was to allow string based bit-wise operations which are no
  longer necessary now that Lua 5.3 provides integers and bit-wise operators.

o The base32/base64 libraries have been reimplemented using Lua 5.3's new
  bitwise operators. (This library was the main user of the bin.pack "B" format
  specifier.)

o A new "bits" library has been added for common bit hacks. Currently only has
  a reverse function.

Thanks to David Fifield, Daniel Miller, Jacek Wielemborek, and  Paulino
Calderon for testing this branch.
2016-07-02 17:02:27 +00:00
dmiller
cfe8893304 Move math.h includes into .cc files 2015-06-23 00:09:01 +00:00
batrick
de27812fe4 Revert libssh2 branch, for now.
$ svn merge -r r33518:r33513 .

and removed added scripts to the script.db.

The branch needs further refinement/testing for Windows and Mac before merging
into the trunk. There is also the latent EOF bug which is giving performance
issues.

Further work on the branch will continue in Devin's latest branch:

/nmap-exp/devin/nmap-libssh2
2014-08-18 03:12:00 +00:00
devin
63f997ed28 Merged libssh2-integration branch 2014-08-14 02:09:00 +00:00
devin
d68396d823 Merged Lpeg branch 2014-06-26 20:12:54 +00:00
d33tah
421176fc00 Get rid of double newline at the EOF I accidentally introduced in the
last commit.
2014-06-18 11:30:02 +00:00
d33tah
e3d1c178e3 Add newlines at the EOF in conformance to Daniel's coding standards
proposal. This only affects Nmap's root directory. We might also need to
modify the code which autogenerates Nmap's source code files such as IPv6
fingerprinting code.
2014-06-18 10:18:58 +00:00
dmiller
866db7eea3 Revert r32528, was not tested on Windows 2013-11-27 13:32:05 +00:00
dmiller
9c36367eea header file cleanup
see http://seclists.org/nmap-dev/2013/q4/168

Move some includes out of nmap.h: nmap.h gets included lots of places,
and unconditionally included math.h, ctype.h, errno.h, stdio.h,
sys/stat.h, fcntl.h, sys/types.h, and stdarg.h. This commit moves those
includes into the .cc files where they are necessary and out of nmap.h

Remove redundant include global_structures.h, included from nmap.h

Removed redundant code included from nmap.h

Removing #include nbase.h when nmap.h is included (redundant)

Remove duplicate #include lines

Add ifndef guards to a few .h files
2013-11-26 20:55:29 +00:00
henri
1e3115dbcb Renamed nmap_fileexistsandisreadable() by file_is_readable(). Former was
hardly readable and is not even a good candidate for longest method
name (http://msdn.microsoft.com/en-us/library/system.windows.media.textformatting.textsource.gettexteffectcharacterindexfromtextsourcecharacterindex.aspx#Y0)
2012-10-20 15:00:10 +00:00
dmiller
d59f85371c Handle NSE-returned strings with null characters
This was resulting in truncated normal output. To reproduce, run a
script that returns "test\0will not appear".
2012-08-17 20:14:44 +00:00
batrick
24e38466f5 Do version checking for Lua 5.2. 2012-08-14 22:19:09 +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
david
3f415ef38a Factor out XML script result writing. 2012-08-02 06:21:01 +00:00
david
87e3c861aa Put a comment on L_NSE. 2012-08-01 19:44:31 +00:00
perdo
6e5b999c99 Add parts of LuaFileSystem to NSE (support for mkdir, rmdir, link). 2012-07-17 18:07:28 +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
batrick
6fddf7e4c9 set srand when creating the Lua state not when beginning a new scan phase 2012-01-13 00:16:17 +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
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
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
djalal
4e7e302c9c Add a missing format argument. 2011-03-03 14:48:45 +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
david
69e1295384 Change the way ScriptResult::get_id and ScriptResult::get_output work to avoid
referencing deallocated memory.

The class was defined basically as follows:

class ScriptResult
{
private:
	std::string output;
public:
	std::string get_output() const
	{
		return this->output;
	}
};

The problem was when it was used like this, as in our script output
routines:

const char *s = sr.get_output().c_str();
printf("%s\n", s);

The reason is that the temporary std::string returned by get_output goes
out of scope after the line containing it, which invalidates the memory
pointed to by c_str(). By the time of the printf, s may be pointing to
deallocated memory.

This could have been fixed by returning a const reference that would
remain valid as long as the ScriptResult's output member is valid:

	const std::string& get_output() const
	{
		return this->output;
	}

However I noticed that get_output() was always immediately followed by a
c_str(), so I just had get_output return that instead, which has the
same period of validity.

This problem became visiable when compiling with Visual C++ 2010. The
first four bytes of script output in normal output would be garbage
(probably some kind of free list pointer). It didn't happen in XML
output, because the get_output-returned string happened to remain in
scope during that.
2010-11-09 19:47:18 +00:00
batrick
75bd2b0745 use utility functions 2010-09-20 19:47:08 +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
batrick
b08dfd2630 whitespace change 2010-09-03 18:02:21 +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
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
kris
eca6defda6 a couple more __func__ changes 2010-03-19 05:21:06 +00:00
batrick
ec79a3b59b Use defines for library names "nmap" and "stdnse.c" 2010-02-06 00:59:33 +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