1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-08 23:49:03 +00:00
Commit Graph

1149 Commits

Author SHA1 Message Date
dmiller
e296cdea2a Fix some @see NSEdoc
https://secwiki.org/w/Nmap/Code_Standards#NSEdoc_best-practices
2014-03-04 17:04:58 +00:00
dmiller
4cef3889f1 Remove unused and redundant snmp.dec function 2014-03-03 22:34:25 +00:00
dmiller
d50c47d621 Remove duplicate decodeLength function 2014-03-03 22:34:23 +00:00
dmiller
a959de5685 Update asn1.lua NSEdoc
https://secwiki.org/w/Nmap/Code_Standards#NSEdoc_best-practices
2014-03-03 22:34:21 +00:00
dmiller
abb2cab7e4 Fix NSEdoc tag: @class, not @type 2014-03-03 20:12:53 +00:00
dmiller
bdb8f258ef Update ajp.lua NSEdoc
@see NSEdoc elements weren't being rendered properly, so I updated
everything. Guidelines:
https://secwiki.org/w/Nmap/Code_Standards#NSEdoc_best-practices
2014-03-03 20:04:17 +00:00
sophron
a673b79aa6 Added an entry to http-default-accounts-fingerprints that detects F5 BIG-IP router. Patch by nnposter. 2014-03-02 17:46:06 +00:00
sophron
a4a648a56b Added an entry to http-devframework-fingerprints that detects SPIP framework. Patch by Paul AMAR. 2014-03-02 17:38:57 +00:00
dmiller
ddcfa8cc90 Spellcheck: common misspellings in the entire source tree 2014-02-21 21:10:51 +00:00
dmiller
c497ef4679 Fix a bug introduced in r32728 in upnp.lua
When payload was changed to a single string instead of a strbuf object,
calls to strbuf.dump() were not removed.
2014-02-20 21:30:05 +00:00
dmiller
6e3980733e Use unicode library for msrpc/smb 2014-02-19 22:14:16 +00:00
dmiller
1ff0062589 Use unicode library for NTLM in sasl.lua 2014-02-19 22:14:14 +00:00
dmiller
743c90c24a Use nsedebug.tostr in unittest to more clearly show how tests fail. 2014-02-19 18:32:25 +00:00
dmiller
f17cc56bf9 New utility functions for transcoding to and from Windows Unicode
Windows uses UTF-16 little-endian. Since this is a common use case,
utility functions are provided such that this:

    x = unicode.utf16to8(v)

is equivalent to this:

    x = unicode.encode(unicode.decode(v, unicode.utf16_dec),
    unicode.utf8_enc)

but faster (fewer intermediate tables)
2014-02-19 18:32:23 +00:00
dmiller
a76990b9ae Fix off-by-one error in unicode.decode.
Would fail to decode the last character in a string.
2014-02-19 18:32:21 +00:00
dmiller
44a006a7cf Let json.lua use unicode.lua for utf8_enc 2014-02-19 17:08:31 +00:00
dmiller
1273cb4200 New unicode.lua library. Supports utf-8 and UTF-16 2014-02-19 17:08:30 +00:00
dmiller
210d50a1d9 Add table_equal test to unittest.lua
Checks that 2 tables have the same length and list values.
2014-02-19 17:08:27 +00:00
dmiller
1b71f75aad Spelling fixes for Lua files
Mostly in documentation/comments, but a couple code bugs were caught,
including a call to stdnse.pirnt_debug and a mis-declared variable.
2014-02-19 04:15:46 +00:00
dmiller
1c0c090ace Refactor some Lua string concatenations.
Using this regular expression, '\(\w*\)\s*=\s*\1\s*\.\.', found and
replaced many string concatenation-reassignments. These can cause
performance issues, since a new string gets allocated for each
reassignment. In many cases, the replacement is simply a single string,
wrapped across lines with the '\z' escape, which consumes a newline and
whitespace following it. In other cases, a table is used to hold the
substrings until the final string is built with a single table.concat
operation (same technique used in stdnse.strbuf).

Also, some string-building loops of this form:

s = ""
for i = 1, 100, 1 do
  s = s .. "\0"
end

were replaced with this much faster and cleaner version:

s = string.rep("\0", 100)
2014-02-18 18:10:23 +00:00
dmiller
ac5a89a8e1 Remove unused NSE library requires
for lib in nselib/*.lua*; do l=${lib#*/}; l=${l%.lua*}; find . -name \
  \*.lua -o -name \*.nse | xargs grep -l "require .$l\>" | xargs grep \
  -c "\<$l\." | grep ':0$' | awk -F: '{print "'$l'", $1}'; done

Did not remove calls to stdnse.silent_require since these can be used to
abort script execution if OpenSSL is not included, even if the script
does not directly call openssl.* (perhaps it uses comm.tryssl instead,
for instance).

Also did not remove require "strict", since that library is special and
modifies the environment.
2014-02-13 16:39:17 +00:00
dmiller
a084340b6d Remove useless calls to string.format
stdnse.print_debug accepts a format string and arguments, making
string.format redundant in calls of this form:

stdnse.print_debug(1, string.format("%s: error", SCRIPT_NAME))
stdnse.print_debug(("length %d"):format(#tab))

These can be rewritten as:

stdnse.print_debug(1, "%s: error", SCRIPT_NAME)
stdnse.print_debug("length %d", #tab)
2014-02-13 15:47:41 +00:00
dmiller
b73c3aa60f Wrap long lines in NSE (>200 columns)
Mostly in documentation (the description field, for instance), but also
some long literal strings. Lua 5.2 introduces a string escape, "\z",
which escapes any amount of subsequent whitespace, including newlines.
This can be used to wrap string literals without upsetting indentation.
http://www.lua.org/manual/5.2/manual.html#3.1
2014-02-13 15:47:35 +00:00
dmiller
2896c21989 Convert some file encodings from ISO-8859-2 to UTF-8
https://secwiki.org/w/Nmap/Code_Standards
2014-02-12 19:49:43 +00:00
dmiller
6a98f70197 More DNS TCP support from John Bond
http://seclists.org/nmap-dev/2014/q1/154
2014-02-12 17:08:40 +00:00
dmiller
298c42d3b4 Update the usage examples in match.lua
The example uses of nmap.receive_buf() were missing the second
parameter, keeppattern. Also referenced the match library from
nmap.receive_buf's NSEdoc to avoid reimplementations of buffered
sockets.
2014-02-10 19:39:09 +00:00
dmiller
4e7e7c04f0 Factor out some clutter in dnsbl.lua
The constructor for DNS blacklist service objects was identical in every
case. Factoring it out will reduce errors and complexity.
2014-02-10 19:39:07 +00:00
dmiller
4ea4977a37 Replace "buffered socket" classes with socket.receive_buf()
The match library has a helpful function for doing exactly this, with
less copy-and-pasted code:
http://nmap.org/nsedoc/lib/match.html#numbytes
2014-02-10 17:27:09 +00:00
dmiller
fb67a6717e Re-indent some libs and scripts, change 4 to 2-space indent
Mostly found with:

    for i in nselib/*.lua scripts/*.nse; do
      echo $(perl -lne 'BEGIN{$a=$p=0}next unless $_;/^(\s*)/;' \
        -e '$l=length$1;next if$l==$p;$a+=(abs($l-$p)-$a)/$.;' \
        -e '$p=$l;END{print$a}' $i) $i
    done | sort -nr

And indented with: https://gist.github.com/bonsaiviking/8845871

whois-ip.nse was particularly mangled (probably my fault due to using
vim's built-in indentation script, but it could be structured better)
2014-02-06 23:25:28 +00:00
dmiller
96c1a4f46b Another reindent pass on smb.lua, this time fully automated
Using Vim and this indent script:
https://gist.github.com/bonsaiviking/8845871
2014-02-06 15:53:34 +00:00
dmiller
a56f73effb Add NSEdoc to formulas.lua 2014-02-05 19:02:31 +00:00
dmiller
e5fc094635 Add some NSEdoc for smbauth.get_host_info_from_security_blob 2014-02-05 18:30:57 +00:00
dmiller
7dd47ec3a3 Re-indent the Lua files in nselib/data/
https://secwiki.org/w/Nmap/Code_Standards
2014-02-05 17:58:36 +00:00
dmiller
69e343f0aa Reindent the last of the NSE libraries.
https://secwiki.org/w/Nmap/Code_Standards
2014-02-04 19:47:26 +00:00
dmiller
961ea25225 Re-indent some NSE libraries.
https://secwiki.org/w/Nmap/Code_Standards
2014-02-03 19:47:34 +00:00
dmiller
972d799143 Add TCP support to dns.lua
Slightly modified from patch from John Bond:
http://seclists.org/nmap-dev/2014/q1/118
2014-01-31 15:14:31 +00:00
dmiller
4eaa21e7cb Integrate David's ssl-enum-ciphers improvements
From this thread: http://seclists.org/nmap-dev/2014/q1/105

* Extensions now better supported in tls.lua
* ssl-enum-ciphers sends all EC options to ensure servers reply with
  supported EC suites
* tls.lua supports multiple messages of a single type within 1 record
* tls.record_buffer will read an entire TLS record into a buffer
* ssl-date and tls-nextprotoneg updated to use tls.record_buffer
2014-01-30 18:12:14 +00:00
dmiller
ef61c11831 Retab creds.lua (Fixes some nsedoc ugliness) 2014-01-23 21:52:38 +00:00
dmiller
620f9fdb34 Remove trailing whitespace in lua files
Whitespace is not significant, so this should not be a problem.
https://secwiki.org/w/Nmap/Code_Standards
2014-01-23 21:51:58 +00:00
dmiller
86ac3c0a19 Whitespace fixing on packetdecoders.lua
Changed indentation to 2 spaces, converted \r\n line endings to \n,
changed line-internal tabs to single space, removed whitespace at line
endings, reindented entire file with vim.
https://secwiki.org/w/Nmap/Code_Standards
2014-01-22 18:26:02 +00:00
dmiller
db1d82ad1f Fixed global assignments with nse_check_globals
All fixes made by hand. A couple real bugs/errors fixed, due to
copy-paste of code from other scripts without changing variable names.
2014-01-22 17:45:00 +00:00
dmiller
726b259b20 Consolidate "contains" functions into stdnse.contains
These implementations were all functionally identical. The replacement
has an extra feature of returning the index where the value was found,
currently unused.
2014-01-16 22:57:33 +00:00
dmiller
197f28265f New function stdnse.format_mac
This function will format a MAC address as colon-separated hex bytes.
It's really very simple: stdnse.tohex(mac, {separator=":"})

This commit updates all the instances I could find of the varying
convoluted attempts at performing this conversion.
2014-01-16 21:50:30 +00:00
dmiller
760da1788f Let tls-nextprotoneg use tls.lua library
Required fixes to tls lib's extensions (did not previously support
extension data)
2014-01-16 18:10:02 +00:00
dmiller
71b0769fc3 New tls.lua library for handling TLS records 2014-01-16 18:09:57 +00:00
dmiller
b083fb98e6 Update comm library NSEdoc
Document some missing options to the functions, and adjust an error
message to use the correct option name.
2014-01-15 20:11:39 +00:00
dmiller
3b5b0ba154 Note that HTTPS is supported by http NSE library 2014-01-15 16:52:46 +00:00
dmiller
c5a4ef91fb Add more unittests to ipOps 2014-01-14 23:18:28 +00:00
dmiller
4b34673a0b Add more complete unittests for ipOps.compare_ip 2014-01-11 15:05:43 +00:00
dmiller
3570ca78d8 Adjust unittest definitions to generate proper nsedoc 2014-01-04 03:48:13 +00:00