1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00
Commit Graph

92 Commits

Author SHA1 Message Date
dmiller
68599ce140 Solve "unexpected signature" message in SMB extended session setup (NTLM type 2 message only sent once) 2016-01-07 20:33:10 +00:00
dmiller
f4619edece Update http urls for nmap.org to https 2015-11-05 20:41:05 +00:00
henri
b1d6bcd9be nselib/smb: fix find_files function (next_item coroutine)
Patch by Pierre LALET <pierre.lalet@cea.fr>
2015-04-30 17:58:13 +00:00
dmiller
ea58c6bebb Replace chained concatenation reassignment with simple concatenation
Example:

x = y
x = x .. z

Fixed:

x = y
.. z

This simple fix would save 1 string creation/deletion. Most changes
involve many more than this.
2015-03-02 13:47:42 +00:00
dmiller
0e74dd7a35 Replace some string.char and bin.pack calls with literals 2015-02-27 19:42:56 +00:00
dmiller
4f0518bd93 Replace concat-loop padding with string.rep 2015-02-27 14:55:42 +00:00
dmiller
40f36a4e3e Some string optimizations in NSE
Changes fall into these categories:

1. Avoid pathological string building. Loops over x = x .. "foo" can
become very slow. Instead, use strbuf.lua, table.concat, or just one
continuous concatenation; a = x .. y .. z is one operation, better than
a = x .. y; a = a .. z

2. Use hex-escaped strings instead of string.char. I find this more
readable in many cases, and it avoids a table lookup and function call.

3. Don't duplicate code. A few libraries and scripts had re-implemented
stdnse.generate_random_string or openssl.rand_bytes.
2014-09-03 04:49:54 +00:00
dmiller
2692746c42 NSEdoc cleanup
Mostly splitting function summaries (the first paragraph of NSEdoc) from
the body of the description to make the summary indexes shorter and
easier to scan.

Also fixed some unbalanced code tags like <code>foo</table>
2014-09-02 18:23:06 +00:00
batrick
ee6622aea4 nselib stdnse.print_debug -> stdnse.debug
$ f() { find -name \*.lua -exec /bin/echo sed -i "$1" {} \; ; }
$ f 's/stdnse.print_debug( *\([0-9]*\) *, */stdnse.debug\1(/'
$ f 's/stdnse.print_debug( *"\(.*\))/stdnse.debug1("\1)/'
2014-08-03 00:56:45 +00:00
dmiller
17c3e9755e NSEdoc cleanup.
1. The first paragraph of a function's NSEdoc is used as a short
summary. Some of these were very long, so I split off a shorter summary.

2. Use asterisks (*) to denote bulletted lists, not 'o'

3. Wrap lines at 80 columns

4. a couple other spelling and formatting fixes
2014-03-10 19:01:19 +00:00
dmiller
6e3980733e Use unicode library for msrpc/smb 2014-02-19 22:14:16 +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
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
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
69e343f0aa Reindent the last of the NSE libraries.
https://secwiki.org/w/Nmap/Code_Standards
2014-02-04 19:47:26 +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
patrik
81b6bae5eb Squashed commit of the following:
commit e5cb0a18d5474730310f1797016e1106c33ca059
Author: Patrik Karlsson <patrik@cqure.net>
Date:   Sun Oct 7 10:47:35 2012 +0200

    compatibility fixes to spnego authentication in smb and smbauth libraries

    the spnego authentication blob now decodes properly in wireshark
    fixes in spnego authentication for both Window 2003 and Windows 7
2012-10-07 08:54:34 +00:00
david
d9b73da3a1 Give sample return values for smb.get_os. 2012-09-08 17:05:33 +00:00
dmiller
9fbd30f191 Use ISO8601 time for smb-os-discovery 2012-08-16 15:46:37 +00:00
aca
6fec00655d Added smb-ms10-054 vuln check script to trunk 2012-07-23 09:52:38 +00:00
batrick
4ef2bb978a add appropriate comment 2012-07-09 17:06:04 +00:00
patrik
c80a28f5f2 Add netbios name lookup caching code in order to avoid multiple lookups for
the same host.ip.
2012-06-15 21:26:26 +00:00
patrik
bb359adaa1 Played a round of nse_check_globals and fixed a bunch of reported problems. 2012-06-15 19:32:36 +00:00
patrik
e6a42c9291 fix to get smb-enum-shares working on Windows 2008 and Windows 7 2012-06-13 20:35:50 +00:00
patrik
44b46bb148 Fixed global declarations in smb.lua 2012-06-11 17:40:21 +00:00
patrik
71e26189f6 o [NSE] More Windows 7 and Windows 2008 fixes for the smb library and smb-ls
scripts. [Patrik Karlsson]
2012-06-10 22:40:02 +00:00
patrik
bc0defc8ff o [NSE] Added SPNEGO authentication supporting Windows 7 and Windows 2008 to
the smb library. [Patrik Karlsson]
2012-06-09 12:17:01 +00:00
patrik
721ac80024 reverted previous commit, due to unfinnished changes in smb, asn1 and smbauth
libraries.
2012-06-06 22:04:28 +00:00
patrik
c4617f8d31 Fixed a bunch of errors reported by Ron Bowes;
http://seclists.org/nmap-dev/2012/q2/639
2012-06-06 21:57:00 +00:00
batrick
be0af7b304 Add some missing library requires. Patch generated by
$ nse_check_globals --patch

with some modifications for format consistency.
2012-06-05 15:21:54 +00:00
patrik
0372cf9e7a o [NSE] Added the script smb-ls that lists files on SMB shares and produces
output similar to the dir command on Windows. [Patrik Karlsson]
2012-06-03 18:10:49 +00:00
david
587cc517c3 Fix smb library shadowed parameters.
This happened as an unintentional side effect of Lua 5.2 changes. The
fix is by Daniel Miller.

http://seclists.org/nmap-dev/2012/q2/530
2012-05-29 21:05:39 +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
henri
5594173c17 Fixed a couple additional typos:
compatiable -> compatible
  prefered -> preferred
  connectiosn -> connections
  statis -> status
2012-01-30 10:19:22 +00:00
henri
49a61f0fa6 Fixed typo (functino -> function). 2012-01-30 10:05:18 +00:00
tomsellers
b5cb7a96fc Modified start_session_basic so as to return the
status code text when the variable status is not
nil.  This mimics the behavior of start_session_extended.

This should provide more reliable results to smb-brute
concerning the nature of login failure reasons.

More detail has been sent to the mailing list.
2011-09-03 17:01:13 +00:00
patrik
23d2e0d31f o [NSE] Applied patch from Chris Woodbury that adds the following additional
information to the output of smb-os-discovery:
  + Forest name
  + FQDN
  + NetBIOS computer name
  + NetBIOS domain name
2011-07-12 06:08:43 +00:00
batrick
4444071f03 use # length operator instead of string.len (canonicalize)
Used this perl command:

$ # perl -pi -e 's/string\.len\((.*?)\)/#\1/g' *.lua

Also fixed one instance where the above command didn't correctly
translate the intended code (string.len(a .. b .. c)).
2011-05-11 15:08:55 +00:00
ron
01f5e7cf51 Added a patch from Chris Woodbury that fixes a serious bug in the SMB Authentication library, where multiple concurrent scripts with valid credentials would fail to log in. 2011-04-28 23:00:01 +00:00
david
3447e2a6a2 Use get_script_args to handle smb-related flag options, to use our
common true/false logic and not hardcode "1" and "true" in places. Patch
by Chris Woodbury.
2011-04-20 21:35:10 +00:00
patrik
58edddaedb o [NSE] Merged the ms-sql branch with several improvements and changes to the
ms-sql scripts and library:
  - Improved version detection
  - Improved server discovery
  - Add support for named pipes
  - Add support for integrated authentication
  - Add support for connecting to instances by name or port
  - Improved script and library stability
  - Improved script and library documentation
 [Patrik Karlsson, Chris Woodbury]
2011-02-26 22:41:10 +00:00
ron
d33c79c65f Removed some duplicate shares for bruteforcing, alphabetized the list, and added TEMP and SHARE - all thanks to Chris Woodbury's suggestions 2011-02-09 04:22:15 +00:00
ron
b8e712ceeb Added a couple shares to the list of common ones (requested on IRC by kraigus) 2010-10-18 21:16:48 +00:00
ron
727661921a Implemented some changes (mostly in error handling) to let smb scripts run in parallel with each other against a single host. Previously, I had used a mutex to prevent that from happening. The changes are summarized in the following post: http://seclists.org/nmap-dev/2010/q3/819, but it comes down to three things:
1) Set the 'vc' ('virtual circuit') id to a non-zero value (if it's 0, the smb server will disconnect all hosts who are already connected)
2) Handle the authentication error NT_STATUS_REQUEST_NOT_ACCEPTED, which indicates that there are too many connected hosts (11 is the default on most versions of Windows, or 10 for the anonymous account). If we see the error, we wait and try again. 
3) Handle the file creation error, NT_STATUS_PIPE_NOT_AVAILABLE, which appears to be caused by a race condition of some sort. It happens when a large number of connections are attempted simultaneously, and is fixed by a short backoff (50ms worked fine, but I'm using 100ms)
The end result is a significant speedup in our SMB checks without losing data.
2010-10-03 22:40:41 +00:00
ron
2035b82dfd Fixed a really tricky bug that I spent all evening chasing. Normally, during login, every account in the list (by default, guest and anonymous) are attempted. Unless something fails badly, anonymous will work. Unfortunately, if something DOES fail badly, after the first script runs this list is empty. That means if something bad is happening, and two or more scripts are running, every script after the first will have an empty list of accounts to use, and it would fail mysteriously. This patch checks the return value from the get_next_account() function properly to see if we've run out of accounts and report that to the user rather than an ugly stacktrace. 2010-09-24 00:47:43 +00:00
david
3c89e089fc Change calls in these forms:
socket:connect(host.ip, port.number)
socket:connect(host.ip, port.number, port.protocol)

to this:

socket:connect(host, port)

connect can take host and port tables now, and the default protocol is
taken from the port table if possible.
2010-08-16 18:59:30 +00:00
ron
934cf2edf0 Significant changes, both bugfixes and best practice changes, to smb-psexec.nse. Primarily:
o It no longer uses the global environment to store the modules table
o It now uses loadfile() to load the configuration files, which follows best practices better
o The module() line at the top of the configuration files is no longer required, but if it exists all that happens is a warning is printed
o Worked around what appears to be a bug in one person's Nmap install where absolute paths didn't resolve properly -- I couldn't replicate, but he confirmed it was fixed
2010-08-07 19:36:47 +00:00
david
7d0c08a097 Brief copyediting of NSEDoc for modules. 2010-07-12 19:42:43 +00:00
ron
50b9af97b6 Added extra 'overrides' calls all over smb.lua. They're required for some modifications to smb-check-vulns.nse I'm planning. 2010-05-15 15:57:01 +00:00
drazen
f41a94622a --A small formating fix. 2010-05-11 18:31:47 +00:00