Index: nselib/smb.lua
===================================================================
--- nselib/smb.lua (revision 36802)
+++ nselib/smb.lua (working copy)
@@ -136,6 +136,7 @@
local string = require "string"
local table = require "table"
local unicode = require "unicode"
+local smb2 = require "smb2"
_ENV = stdnse.module("smb", stdnse.seeall)
-- These arrays are filled in with constants at the bottom of this file
@@ -942,8 +943,9 @@
return true, header, parameters, data
end
---- Sends out SMB_COM_NEGOTIATE, which is typically the first SMB packet sent out.
---
+---
+-- Negotiates SMBv1 connections
+--
-- Sends the following:
-- * List of known protocols
--
@@ -974,37 +976,30 @@
-- * 'server_challenge' A random string used for challenge/response
-- * 'domain' The server's primary domain or workgroup
-- * 'server' The server's name
-function negotiate_protocol(smb, overrides)
+-- @param smb The SMB object associated with the connection.
+-- @param overrides Overrides table.
+-- @return (status, dialect) If status is true, the negotiated dialect in human readable form is returned as the second value.
+-- If status is false, the error message is returned.
+---
+function negotiate_v1(smb, overrides)
local header, parameters, data
- local pos
- local header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, pid, mid
+ local result, err
+ local pos, header1, header2, header3, header4, command, status, flags, flags2, pid_high, signature, unused, pid, uid, tid, mid
- header = smb_encode_header(smb, command_codes['SMB_COM_NEGOTIATE'], overrides)
-
+ header = smb_encode_header(smb, command_codes['SMB_COM_NEGOTIATE'], overrides)
-- Make sure we have overrides
overrides = overrides or {}
-- Parameters are blank
parameters = ""
+ data = bin.pack("