Commit Graph

123 Commits

Author SHA1 Message Date
dmiller 3cb5343e43 Report error enumerating shares. Fixes #2272 2026-07-23 21:55:44 +00:00
dmiller b47e7f07ef Change explicit X==true to X 2026-07-08 00:42:18 +00:00
dmiller ce2b1e6d39 Change explicit X==false to not X 2026-07-07 14:50:05 +00:00
dmiller 63a39b7a90 Remove unused ip param from smbauth functions. Fixes #268 2026-06-16 14:20:17 +00:00
dmiller b2ebc18360 NSEdoc fixes 2025-03-13 18:13:21 +00:00
nnposter 58617a79f7 SMB2 dialect refactoring. Fixes #2203, closes #2208 2021-01-18 21:21:43 +00:00
nnposter 6998bfca49 Refactors function smb.find_files()
- Replaces its coroutine design to avoid sharing sockets across threads
    (Fixes #1837)
  - Corrects conversion of file attributes into bitmask
  - Removes side effect of modifying parameter "options" by populating
    member "srch_attrs"
  - Implements options.maxfiles to take advantage of script arg ls.maxfiles,
    reducing file requests that would be ultimately ignored anyway
  - Improves performace by supporting larger SMB block sizes
  - Implements rudimentary support for Trans2_Data by smb.send_transaction2()
  - Adds standard definitions for SMB file attributes
2019-12-19 20:13:16 +00:00
nnposter be3d719dd7 Correct a constant value typo 2019-12-15 20:45:54 +00:00
nnposter c491143358 Do not trust SMB challenge length field with Extended Security in use
Some Samba servers fail to zero it out. See
https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb/d883d0a5-5a0a-4626-8e3e-87b0b66b79aa
Fixes #1707, closes #1476
2019-09-08 00:40:27 +00:00
nnposter d608b26eb5 Fix off-by-one bug 2019-09-07 22:50:33 +00:00
nnposter ce28753b89 Rectify error "bad argument #2 to 'format'" in SMB scripts
Fixes #1713, closes #1714, closes #1480
2019-09-06 04:13:07 +00:00
nnposter 59c53f07fd Prevent an error when optional argument "overrides" is not passed
Prevent a potentially unexpected side-effect when the argument is passed.
2019-09-05 21:56:54 +00:00
nnposter 90a2063c9d Only one dialect is returned by smb.negotiate_v1() 2019-09-05 21:28:44 +00:00
dmiller 0855eb4c0c Fix logic error with parentheses. Fixes #1544 2019-04-13 21:42:55 +00:00
dmiller 16504696a5 Move length checks to before string.unpack to avoid throwing errors 2018-09-05 19:01:51 +00:00
dmiller 5c9959104d Check available data before unpacking 2018-09-02 20:51:04 +00:00
dmiller cc768ddec8 Remove unneeded retries around send/receive_buf(numbytes) left from when different behavior was used 2018-09-01 18:50:19 +00:00
dmiller fd86015cde Remove bin.lua from smb.lua 2018-08-30 03:25:14 +00:00
dmiller e0af0179eb Remove use of bit library from all NSE libs 2018-08-28 15:21:53 +00:00
dmiller 46eca7f35f Move date/time functions from stdnse to datetime. See #517 2018-08-27 22:00:10 +00:00
nnposter 19693c334c More string.sub vs. string.byte optimizations 2018-08-19 01:49:08 +00:00
dmiller c892dab9a3 Handle large dates on platforms that can't. Fixes #1303 2018-08-10 19:42:50 +00:00
dmiller 689ea0e05d Spelling corrections. Fixes #1160 2018-03-26 14:59:41 +00:00
rewanth 6ee953a5ff Removes trailing spaces in 69 files. Closes #971. 2017-08-23 08:52:40 +00:00
paulino ed0b960057 Adds new NSE library for SMB2/SMB3 and scripts smb-protocols,smb2-time,smb2-capabilities,smb2-security-mode,smb2-vuln-uptime. Closes #943 2017-07-28 09:01:02 +00:00
dmiller dff7eca79f Fix some globals 2017-07-18 18:46:01 +00:00
waituck b4e1daef74 Fixed bug in smb.lua share_get_list function to use anonymous connections first. Closes #904 2017-06-11 19:42:33 +00:00
paulino b0228a212b Updates smb.lua and msrpc.lua to support fully qualified path names as share names and updates match for OID. Modern Windows versions require FQPN and older version work the same. The level of information requested with the call NetShareGetInfo was reduced to support newer versions of Windows. This closes #266, closes #704, closes #238, and closes #883. 2017-05-27 07:28:44 +00:00
dmiller 70e9d70a48 Avoid passing float to os.time. Fixes #588 2016-11-30 00:10:04 +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
tomsellers e2cfda9dc0 Change to smb-os-discovery to enable it to augment SMB version detection. Closes #348 2016-03-31 10:56:29 +00:00
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