From 7b67aaea5d6c58916d30cc1552cb5f06f9cbdae1 Mon Sep 17 00:00:00 2001 From: bigbael Date: Sun, 22 Dec 2019 18:17:04 -0600 Subject: [PATCH 1/2] smb.lua: Add SMB argument smbnativeos, which will override the default setting of 'Nmap' for 'Native OS'. Add new SMB argument, smbnativeos If set, this will override the default hard-coded value of Nmap --- nselib/smb.lua | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/nselib/smb.lua b/nselib/smb.lua index 3931777cd..43e68b003 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -117,6 +117,7 @@ -- to be the same protocol as port 445, not port 139. Since it probably isn't possible to change -- Windows' ports normally, this is mostly useful if you're bouncing through a relay or something. -- @args randomseed Set to a value to change the filenames/service names that are randomly generated. +-- @args smbnativeos Set the value of "Native OS", if not set, defaults to "Nmap". -- -- @author Ron Bowes -- @copyright Same as Nmap--See https://nmap.org/book/man-legal.html @@ -1143,6 +1144,7 @@ local function start_session_basic(smb, log_errors, overrides) local os, lanmanager local username, domain, password, password_hash, hash_type local busy_count = 0 + local nativeos header = smb_encode_header(smb, command_codes['SMB_COM_SESSION_SETUP_ANDX'], overrides) @@ -1158,6 +1160,13 @@ local function start_session_basic(smb, log_errors, overrides) result, username, domain, password, password_hash, hash_type = smbauth.get_account(smb['host']) end + -- Get the value of Native OS or set to default + if (nmap.registry.args.smbnativeos ~= nil) then + nativeos = nmap.registry.args.smbnativeos + else + nativeos = "Nmap" + end + while result ~= false do local lanman, ntlm @@ -1184,7 +1193,7 @@ local function start_session_basic(smb, log_errors, overrides) .. string.pack(" Date: Sun, 22 Dec 2019 21:17:50 -0600 Subject: [PATCH 2/2] Update smb.lua --- nselib/smb.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nselib/smb.lua b/nselib/smb.lua index 43e68b003..dae9727cc 100644 --- a/nselib/smb.lua +++ b/nselib/smb.lua @@ -1162,9 +1162,9 @@ local function start_session_basic(smb, log_errors, overrides) -- Get the value of Native OS or set to default if (nmap.registry.args.smbnativeos ~= nil) then - nativeos = nmap.registry.args.smbnativeos + nativeos = nmap.registry.args.smbnativeos else - nativeos = "Nmap" + nativeos = "Nmap" end while result ~= false do @@ -1333,9 +1333,9 @@ local function start_session_extended(smb, log_errors, overrides) -- Get the value of Native OS or set to default if (nmap.registry.args.smbnativeos ~= nil) then - nativeos = nmap.registry.args.smbnativeos + nativeos = nmap.registry.args.smbnativeos else - nativeos = "Nmap" + nativeos = "Nmap" end -- check what kind of security blob we were given in the negotiate protocol request