Skip to content

Commit dff7eca

Browse files
committed
Fix some globals
1 parent 6b21729 commit dff7eca

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

nselib/msrpc.lua

+5-9
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ local UUID2EXE = {
200200
--@return status true or false
201201
--@return smbstate if status is true, or an error message.
202202
function start_smb(host, path, disable_extended, overrides)
203-
local sharename
204203
overrides = overrides or {}
205-
_, sharename = smb.get_fqpn(host, "IPC$")
204+
local _, sharename = smb.get_fqpn(host, "IPC$")
206205
return smb.start_ex(host, true, true, sharename, path, disable_extended, overrides)
207206
end
208207

@@ -666,18 +665,15 @@ end
666665
-- useful one being 'shares', which is a list of the system's shares.
667666
function srvsvc_netsharegetinfo(smbstate, server, share, level)
668667
stdnse.debug2("Calling NetShareGetInfo(%s, %s, %d)", server, share, level)
669-
local status, result, sharename
670-
local arguments
671-
local pos, align
672668

673669
--NetGetShareInfo seems to reject FQPN and reads the server value from the request
674670
--If any function called this function using a FQPN, this should take care of it.
675-
_, _, sharename = string.find(share, "\\\\.*\\(.*)")
671+
local _, _, sharename = string.find(share, "\\\\.*\\(.*)")
676672
if sharename then
677673
share = sharename
678674
end
679675
-- [in] [string,charset(UTF16)] uint16 *server_unc,
680-
arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true)
676+
local arguments = msrpctypes.marshall_unicode_ptr("\\\\" .. server, true)
681677

682678
-- [in] [string,charset(UTF16)] uint16 share_name[],
683679
.. msrpctypes.marshall_unicode(share, true)
@@ -689,7 +685,7 @@ function srvsvc_netsharegetinfo(smbstate, server, share, level)
689685

690686

691687
-- Do the call
692-
status, result = call_function(smbstate, 0x10, arguments)
688+
local status, result = call_function(smbstate, 0x10, arguments)
693689
if(status ~= true) then
694690
return false, result
695691
end
@@ -698,7 +694,7 @@ function srvsvc_netsharegetinfo(smbstate, server, share, level)
698694

699695
-- Make arguments easier to use
700696
arguments = result['arguments']
701-
pos = 1
697+
local pos = 1
702698

703699
-- [in] [string,charset(UTF16)] uint16 *server_unc,
704700
-- [in] [string,charset(UTF16)] uint16 share_name[],

nselib/smb.lua

+7-8
Original file line numberDiff line numberDiff line change
@@ -3449,19 +3449,18 @@ end
34493449
-- 'false' is simply returned.
34503450
function is_admin(host, username, domain, password, password_hash, hash_type)
34513451
local msrpc = require "msrpc" -- avoid require cycle
3452-
local status, smbstate, err, result, fqpn_share
34533452
local overrides = get_overrides(username, domain, password, password_hash, hash_type)
34543453

34553454
stdnse.debug1("SMB: Checking if %s is an administrator", username)
34563455

3457-
status, smbstate = start(host)
3456+
local status, smbstate = start(host)
34583457
if(status == false) then
34593458
stdnse.debug1("SMB; is_admin: Failed to start SMB: %s [%s]", smbstate, username)
34603459
stop(smbstate)
34613460
return false
34623461
end
34633462

3464-
status, err = negotiate_protocol(smbstate, overrides)
3463+
local status, err = negotiate_protocol(smbstate, overrides)
34653464
if(status == false) then
34663465
stdnse.debug1("SMB; is_admin: Failed to negotiate protocol: %s [%s]", err, username)
34673466
stop(smbstate)
@@ -3474,8 +3473,8 @@ function is_admin(host, username, domain, password, password_hash, hash_type)
34743473
stop(smbstate)
34753474
return false
34763475
end
3477-
3478-
_, fqpn_share = get_fqpn(host, "IPC$")
3476+
3477+
local _, fqpn_share = get_fqpn(host, "IPC$")
34793478
status, err = tree_connect(smbstate, fqpn_share, overrides)
34803479
if(status == false) then
34813480
stdnse.debug1("SMB; is_admin: Failed to connect tree: %s [%s]", err, username)
@@ -4234,10 +4233,10 @@ namedpipes =
42344233
self.name = namedpipes.make_pipe_name( self._host.ip, self._pipeSubPath )
42354234

42364235
stdnse.debug2("%s: Connecting to named pipe: %s", NP_LIBRARY_NAME, self.name )
4237-
local status, result, errorMessage, fqpn_share
4236+
local errorMessage
42384237
local bool_negotiate_protocol, bool_start_session, bool_disable_extended = true, true, false
4239-
_, fqpn_share = get_fqpn(host, "IPC$")
4240-
status, result = start_ex( self._host, bool_negotiate_protocol, bool_start_session,
4238+
local _, fqpn_share = get_fqpn(host, "IPC$")
4239+
local status, result = start_ex( self._host, bool_negotiate_protocol, bool_start_session,
42414240
fqpn_share, self._pipeSubPath, bool_disable_extended, self._overrides )
42424241

42434242
if status then

scripts/openwebnet-discovery.nse

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local stdnse = require "stdnse"
22
local shortport = require "shortport"
33
local comm = require "comm"
44
local string = require "string"
5+
local table = require "table"
56

67
description = [[
78
OpenWebNet is a communications protocol developed by Bticino since 2000.

scripts/puppet-naivesigning.nse

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ local shortport = require "shortport"
22
local stdnse = require "stdnse"
33
local http = require "http"
44
local vulns = require "vulns"
5+
local string = require "string"
56
local table = require "table"
67
local io = require "io"
78
local base64 = require "base64"

0 commit comments

Comments
 (0)