From ce2b1e6d3941dcb67d56166b1b7a640266453bdb Mon Sep 17 00:00:00 2001 From: dmiller Date: Tue, 7 Jul 2026 14:50:05 +0000 Subject: [PATCH] Change explicit X==false to not X --- nselib/coap.lua | 2 +- nselib/dhcp.lua | 2 +- nselib/dicom.lua | 18 +-- nselib/http.lua | 2 +- nselib/msrpc.lua | 168 ++++++++++++------------- nselib/msrpcperformance.lua | 26 ++-- nselib/msrpctypes.lua | 4 +- nselib/netbios.lua | 16 +-- nselib/smb.lua | 158 +++++++++++------------ nselib/ssh2.lua | 4 +- scripts/bacnet-info.nse | 12 +- scripts/dicom-ping.nse | 2 +- scripts/enip-info.nse | 2 +- scripts/hartip-info.nse | 8 +- scripts/http-headers.nse | 2 +- scripts/http-iis-webdav-vuln.nse | 4 +- scripts/http-malware-host.nse | 2 +- scripts/msrpc-enum.nse | 4 +- scripts/nbstat.nse | 8 +- scripts/p2p-conficker.nse | 12 +- scripts/s7-info.nse | 4 +- scripts/samba-vuln-cve-2012-1182.nse | 6 +- scripts/smb-brute.nse | 40 +++--- scripts/smb-double-pulsar-backdoor.nse | 2 +- scripts/smb-enum-processes.nse | 2 +- scripts/smb-enum-services.nse | 6 +- scripts/smb-enum-sessions.nse | 30 ++--- scripts/smb-enum-shares.nse | 4 +- scripts/smb-enum-users.nse | 2 +- scripts/smb-os-discovery.nse | 2 +- scripts/smb-print-text.nse | 6 +- scripts/smb-psexec.nse | 28 ++--- scripts/smb-security-mode.nse | 4 +- scripts/smb-server-stats.nse | 2 +- scripts/smb-system-info.nse | 22 ++-- scripts/smb-vuln-conficker.nse | 8 +- scripts/smb-vuln-cve-2017-7494.nse | 2 +- scripts/smb-vuln-cve2009-3103.nse | 10 +- scripts/smb-vuln-ms06-025.nse | 10 +- scripts/smb-vuln-ms07-029.nse | 8 +- scripts/smb-vuln-ms08-067.nse | 8 +- scripts/smb-vuln-ms10-054.nse | 2 +- scripts/smb-vuln-ms10-061.nse | 6 +- scripts/smb-vuln-ms17-010.nse | 2 +- scripts/smb-vuln-regsvc-dos.nse | 10 +- scripts/smb-vuln-webexec.nse | 2 +- scripts/smb-webexec-exploit.nse | 2 +- scripts/smb2-capabilities.nse | 4 +- scripts/smb2-security-mode.nse | 2 +- scripts/snmp-brute.nse | 4 +- 50 files changed, 348 insertions(+), 348 deletions(-) diff --git a/nselib/coap.lua b/nselib/coap.lua index 978146ffe..b8dd33491 100644 --- a/nselib/coap.lua +++ b/nselib/coap.lua @@ -1286,7 +1286,7 @@ COAP.header.options.value.block.build = function(val) -- Finally, we want to check that we haven't over-shifted, which is -- characterized by the result being longer than expected based on -- the original number. - if val.number == 0 and val.more == false and val.length == 16 then + if val.number == 0 and not val.more and val.length == 16 then assert(#str == 0) elseif val.number <= 15 then assert(#str == 1) diff --git a/nselib/dhcp.lua b/nselib/dhcp.lua index 3702fffae..432c37d7e 100644 --- a/nselib/dhcp.lua +++ b/nselib/dhcp.lua @@ -532,7 +532,7 @@ function dhcp_parse(data, transaction_id) stdnse.debug2("dhcp-discover: Attempting to parse %s", action['name']) pos, value = action['func'](data, pos, length) - if(nmap.verbosity() == 0 and action.default == false) then + if(nmap.verbosity() == 0 and not action.default) then stdnse.debug1("dhcp-discover: Server returned unrequested option (%s => %s)", action['name'], value) else diff --git a/nselib/dicom.lua b/nselib/dicom.lua index 5b3f2f2c8..d751ef8a6 100644 --- a/nselib/dicom.lua +++ b/nselib/dicom.lua @@ -71,7 +71,7 @@ function start_connection(host, port) status, err = dcm['socket']:connect(host, port, "tcp") - if(status == false) then + if not status then return false, "DICOM: Failed to connect to host: " .. err end @@ -90,7 +90,7 @@ function send(dcm, data) stdnse.debug2("DICOM: Sending DICOM packet (%d)", #data) if dcm['socket'] then status, err = dcm['socket']:send(data) - if status == false then + if not status then return false, err end else @@ -107,7 +107,7 @@ end --- function receive(dcm) local status, data = dcm['socket']:receive() - if status == false then + if not status then return false, data end stdnse.debug1("DICOM: receive() read %d bytes", #data) @@ -156,7 +156,7 @@ function associate(host, port, calling_aet, called_aet) local userinfo_context = "" local status, dcm = start_connection(host, port) - if status == false then + if not status then return false, dcm end @@ -220,7 +220,7 @@ function associate(host, port, calling_aet, called_aet) local status, header = pdu_header_encode(PDU_CODES["ASSOCIATE_REQUEST"], #assoc_request) -- Something might be wrong with our header - if status == false then + if not status then return false, header end @@ -231,11 +231,11 @@ function associate(host, port, calling_aet, called_aet) return false, string.format("ASSOCIATE request PDU must be at least %d bytes and we tried to send %d.", MIN_SIZE_ASSOC_REQ, #assoc_request) end local status, err = send(dcm, assoc_request) - if status == false then + if not status then return false, string.format("Couldn't send ASSOCIATE request:%s", err) end status, err = receive(dcm) - if status == false then + if not status then return false, string.format("Couldn't read ASSOCIATE response:%s", err) end @@ -254,12 +254,12 @@ end function send_pdata(dicom, data) local status, header = pdu_header_encode(PDU_CODES["DATA"], #data) - if status == false then + if not status then return false, header end local err status, err = send(dicom, header .. data) - if status == false then + if not status then return false, err end end diff --git a/nselib/http.lua b/nselib/http.lua index 2a91307fe..7b2165f5e 100644 --- a/nselib/http.lua +++ b/nselib/http.lua @@ -1739,7 +1739,7 @@ local ret_false = function () return false end -- @return redirect_ok function used to validate HTTP redirects local function get_redirect_ok(host, port, options) if ( options ) then - if ( options.redirect_ok == false ) then + if not options.redirect_ok then return ret_false elseif( "function" == type(options.redirect_ok) ) then return options.redirect_ok(host, port) diff --git a/nselib/msrpc.lua b/nselib/msrpc.lua index 2a942438d..cfad707de 100644 --- a/nselib/msrpc.lua +++ b/nselib/msrpc.lua @@ -435,12 +435,12 @@ function call_function(smbstate, opnum, arguments) is_last = ((result['packet_flags'] & 0x02) == 0x02) -- We have a fragmented packet, make sure it's the first (if we're on the first) - if(first == true and is_first == false) then + if first and not is_first then return false, "MSRPC: First fragment doesn't have proper 'first' (0x01) flag set" end -- We have a fragmented packet, make sure it isn't the first (if we aren't on the first) - if(first == false and is_first) then + if not first and is_first then return false, "MSRPC: Middle (or last) fragment doesn't have proper 'first' (0x01) flag set" end @@ -3792,20 +3792,20 @@ function samr_enum_users(host) -- Create the SMB session status, smbstate = start_smb(host, SAMR_PATH, true) - if(status == false) then + if not status then return false, smbstate end -- Bind to SAMR service status, bind_result = bind(smbstate, SAMR_UUID, SAMR_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Call connect4() status, connect4_result = samr_connect4(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, connect4_result end @@ -3815,7 +3815,7 @@ function samr_enum_users(host) -- Call EnumDomains() status, enumdomains_result = samr_enumdomains(smbstate, connect_handle) - if(status == false) then + if not status then stop_smb(smbstate) return false, enumdomains_result end @@ -3834,7 +3834,7 @@ function samr_enum_users(host) if(domain ~= 'Builtin') then -- Call LookupDomain() local status, lookupdomain_result = samr_lookupdomain(smbstate, connect_handle, domain) - if(status == false) then + if not status then stop_smb(smbstate) return false, lookupdomain_result end @@ -3844,7 +3844,7 @@ function samr_enum_users(host) -- Call OpenDomain() local status, opendomain_result = samr_opendomain(smbstate, connect_handle, sid) - if(status == false) then + if not status then stop_smb(smbstate) return false, opendomain_result end @@ -3857,7 +3857,7 @@ function samr_enum_users(host) repeat -- Call QueryDisplayInfo() local status, querydisplayinfo_result = samr_querydisplayinfo(smbstate, domain_handle, j, SAMR_GROUPSIZE) - if(status == false) then + if not status then stop_smb(smbstate) return false, querydisplayinfo_result end @@ -3911,20 +3911,20 @@ function samr_enum_groups(host) -- Create the SMB session local status, smbstate = start_smb(host, SAMR_PATH, true) - if(status == false) then + if not status then return false, smbstate end -- Bind to SAMR service local status, bind_result = bind(smbstate, SAMR_UUID, SAMR_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Call connect4() local status, connect4_result = samr_connect4(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, connect4_result end @@ -3934,7 +3934,7 @@ function samr_enum_groups(host) -- Call EnumDomains() local status, enumdomains_result = samr_enumdomains(smbstate, connect_handle) - if(status == false) then + if not status then stop_smb(smbstate) return false, enumdomains_result end @@ -3954,7 +3954,7 @@ function samr_enum_groups(host) -- Call LookupDomain() local status, lookupdomain_result = samr_lookupdomain(smbstate, connect_handle, domain) - if(status == false) then + if not status then stop_smb(smbstate) return false, lookupdomain_result end @@ -3964,7 +3964,7 @@ function samr_enum_groups(host) -- Call OpenDomain() local status, opendomain_result = samr_opendomain(smbstate, connect_handle, domain_sid) - if(status == false) then + if not status then stop_smb(smbstate) return false, opendomain_result end @@ -3974,7 +3974,7 @@ function samr_enum_groups(host) -- Get a list of groups local status, enumaliases_result = samr_enumdomainaliases(smbstate, domain_handle) - if(status == false) then + if not status then stop_smb(smbstate) return false, "Couldn't enumerate groups: " .. enumaliases_result end @@ -4049,20 +4049,20 @@ function samr_enum_groups(host) -- Now, we need a handle to LSA (in order to convert the RIDs to users -- Create the SMB session local status, smbstate = start_smb(host, LSA_PATH, true) - if(status == false) then + if not status then return false, smbstate end -- Bind to LSA service local status, bind_result = bind(smbstate, LSA_UUID, LSA_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Open the LSA policy local status, openpolicy2_result = lsa_openpolicy2(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, openpolicy2_result end @@ -4072,7 +4072,7 @@ function samr_enum_groups(host) for group_rid, group in pairs(domain_data) do -- Look up the SIDs local status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], group['member_sids']) - if(status == false) then + if not status then stop_smb(smbstate) return false, "Error looking up RIDs: " .. lookupsids2_result end @@ -4117,20 +4117,20 @@ function lsa_enum_users(host) -- Create the SMB session status, smbstate = start_smb(host, LSA_PATH, true) - if(status == false) then + if not status then return false, smbstate end -- Bind to LSA service status, bind_result = bind(smbstate, LSA_UUID, LSA_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Open the LSA policy status, openpolicy2_result = lsa_openpolicy2(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, openpolicy2_result end @@ -4160,7 +4160,7 @@ function lsa_enum_users(host) -- Look up the names, if any are valid than the server's SID will be returned status, lookupnames2_result = lsa_lookupnames2(smbstate, openpolicy2_result['policy_handle'], names) - if(status == false) then + if not status then stop_smb(smbstate) return false, lookupnames2_result end @@ -4176,7 +4176,7 @@ function lsa_enum_users(host) end status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) - if(status == false) then + if not status then stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result) else -- Put the details for each name into an array @@ -4210,7 +4210,7 @@ function lsa_enum_users(host) -- Try converting this group of RIDs into names status, lookupsids2_result = lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], sids) - if(status == false) then + if not status then stdnse.debug1("Error looking up RIDs: %s", lookupsids2_result) else -- Put the details for each name into an array @@ -4251,7 +4251,7 @@ function lsa_enum_users(host) -- Go to the next set of RIDs start = start + LSA_GROUPSIZE - until (status == false or (empty == LSA_MINEMPTY)) + until not status or (empty == LSA_MINEMPTY) end -- Close the handle @@ -4276,7 +4276,7 @@ function get_user_list(host) local names = {} status_lsa, result_lsa = lsa_enum_users(host) - if(status_lsa == false) then + if not status_lsa then stdnse.debug1("MSRPC: Failed to enumerate users through LSA: %s", result_lsa) else for i = 1, #result_lsa, 1 do @@ -4287,7 +4287,7 @@ function get_user_list(host) end status_samr, result_samr = samr_enum_users(host) - if(status_samr == false) then + if not status_samr then stdnse.debug1("MSRPC: Failed to enumerate users through SAMR: %s", result_samr) else for i = 1, #result_samr, 1 do @@ -4297,7 +4297,7 @@ function get_user_list(host) end end - if(status_samr == false and status_lsa == false) then + if not status_samr and not status_lsa then return false, "MSRPC: Couldn't enumerate users; see debug output for more information" end @@ -4317,27 +4317,27 @@ local function get_domain_info(host, domain) -- Create the SMB session status, smbstate = start_smb(host, SAMR_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SAMR service status, bind_result = bind(smbstate, SAMR_UUID, SAMR_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Call connect4() status, connect4_result = samr_connect4(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, connect4_result end -- Call LookupDomain() status, lookupdomain_result = samr_lookupdomain(smbstate, connect4_result['connect_handle'], domain) - if(status == false) then + if not status then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, "Couldn't look up the domain: " .. lookupdomain_result @@ -4345,7 +4345,7 @@ local function get_domain_info(host, domain) -- Call OpenDomain() status, opendomain_result = samr_opendomain(smbstate, connect4_result['connect_handle'], lookupdomain_result['sid']) - if(status == false) then + if not status then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, opendomain_result @@ -4357,19 +4357,19 @@ local function get_domain_info(host, domain) local status_8, querydomaininfo2_result_8 = samr_querydomaininfo2(smbstate, opendomain_result['domain_handle'], 8) local status_12, querydomaininfo2_result_12 = samr_querydomaininfo2(smbstate, opendomain_result['domain_handle'], 12) - if(status_1 == false) then + if not status_1 then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, querydomaininfo2_result_1 end - if(status_8 == false) then + if not status_8 then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, querydomaininfo2_result_8 end - if(status_12 == false) then + if not status_12 then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, querydomaininfo2_result_12 @@ -4377,7 +4377,7 @@ local function get_domain_info(host, domain) -- Call EnumDomainUsers() to get users status, enumdomainusers_result = samr_enumdomainusers(smbstate, opendomain_result['domain_handle']) - if(status == false) then + if not status then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, enumdomainusers_result @@ -4385,7 +4385,7 @@ local function get_domain_info(host, domain) -- Call EnumDomainAliases() to get groups local status, enumdomaingroups_result = samr_enumdomainaliases(smbstate, opendomain_result['domain_handle']) - if(status == false) then + if not status then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) return false, enumdomaingroups_result @@ -4485,27 +4485,27 @@ function get_domains(host) -- Create the SMB session status, smbstate = start_smb(host, SAMR_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SAMR service status, bind_result = bind(smbstate, SAMR_UUID, SAMR_VERSION, nil) - if(status == false) then + if not status then stop_smb(smbstate) return false, bind_result end -- Call connect4() status, connect4_result = samr_connect4(smbstate, host.ip) - if(status == false) then + if not status then stop_smb(smbstate) return false, connect4_result end -- Call EnumDomains() status, enumdomains_result = samr_enumdomains(smbstate, connect4_result['connect_handle']) - if(status == false) then + if not status then samr_close(smbstate, connect4_result['connect_handle']) stop_smb(smbstate) @@ -4569,13 +4569,13 @@ function service_create(host, servicename, path) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SVCCTL service status, bind_result = bind(smbstate, SVCCTL_UUID, SVCCTL_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end @@ -4583,7 +4583,7 @@ function service_create(host, servicename, path) -- Open the service manager stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip, 0x02000000) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_result end @@ -4591,20 +4591,20 @@ function service_create(host, servicename, path) -- Create the service stdnse.debug2("Creating the service") status, create_result = svcctl_createservicew(smbstate, open_result['handle'], servicename, servicename, path) - if(status == false) then + if not status then smb.stop(smbstate) return false, create_result end -- Close the handle to the service status, close_result = svcctl_closeservicehandle(smbstate, create_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end -- Close the service manager status, close_result = svcctl_closeservicehandle(smbstate, open_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end @@ -4633,13 +4633,13 @@ function service_start(host, servicename, args) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SVCCTL service status, bind_result = bind(smbstate, SVCCTL_UUID, SVCCTL_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end @@ -4647,7 +4647,7 @@ function service_start(host, servicename, args) -- Open the service manager stdnse.debug1("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip, 0x02000000) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_result end @@ -4655,7 +4655,7 @@ function service_start(host, servicename, args) -- Get a handle to the service stdnse.debug2("Getting a handle to the service") status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename, 0x000f01ff) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_service_result end @@ -4663,7 +4663,7 @@ function service_start(host, servicename, args) -- Start it stdnse.debug2("Starting the service") status, start_result = svcctl_startservicew(smbstate, open_service_result['handle'], args) - if(status == false) then + if not status then smb.stop(smbstate) return false, start_result end @@ -4672,7 +4672,7 @@ function service_start(host, servicename, args) stdnse.debug1("Waiting for the service to start") repeat status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, query_result end @@ -4681,14 +4681,14 @@ function service_start(host, servicename, args) -- Close the handle to the service status, close_result = svcctl_closeservicehandle(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end -- Close the service manager status, close_result = svcctl_closeservicehandle(smbstate, open_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end @@ -4715,13 +4715,13 @@ function service_stop(host, servicename) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SVCCTL service status, bind_result = bind(smbstate, SVCCTL_UUID, SVCCTL_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end @@ -4729,7 +4729,7 @@ function service_stop(host, servicename) -- Open the service manager stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip, 0x02000000) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_result end @@ -4737,7 +4737,7 @@ function service_stop(host, servicename) -- Get a handle to the service stdnse.debug2("Getting a handle to the service") status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename, 0x000f01ff) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_service_result end @@ -4745,7 +4745,7 @@ function service_stop(host, servicename) -- Stop it stdnse.debug2("Stopping the service") status, control_result = svcctl_controlservice(smbstate, open_service_result['handle'], "SERVICE_CONTROL_STOP") - if(status == false) then + if not status then smb.stop(smbstate) return false, control_result end @@ -4754,7 +4754,7 @@ function service_stop(host, servicename) stdnse.debug2("Waiting for the service to stop") repeat status, query_result = svcctl_queryservicestatus(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, query_result end @@ -4763,14 +4763,14 @@ function service_stop(host, servicename) -- Close the handle to the service status, close_result = svcctl_closeservicehandle(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end -- Close the service manager status, close_result = svcctl_closeservicehandle(smbstate, open_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end @@ -4794,13 +4794,13 @@ function service_delete(host, servicename) -- Create the SMB session status, smbstate = start_smb(host, SVCCTL_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SVCCTL service status, bind_result = bind(smbstate, SVCCTL_UUID, SVCCTL_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end @@ -4808,7 +4808,7 @@ function service_delete(host, servicename) -- Open the service manager stdnse.debug2("Opening the remote service manager") status, open_result = svcctl_openscmanagerw(smbstate, host.ip, 0x02000000) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_result end @@ -4816,7 +4816,7 @@ function service_delete(host, servicename) -- Get a handle to the service stdnse.debug2("Getting a handle to the service: %s", servicename) status, open_service_result = svcctl_openservicew(smbstate, open_result['handle'], servicename, 0x000f01ff) - if(status == false) then + if not status then smb.stop(smbstate) return false, open_service_result end @@ -4824,21 +4824,21 @@ function service_delete(host, servicename) -- Delete the service stdnse.debug2("Deleting the service") status, delete_result = svcctl_deleteservice(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, delete_result end -- Close the handle to the service status, close_result = svcctl_closeservicehandle(smbstate, open_service_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end -- Close the service manager status, close_result = svcctl_closeservicehandle(smbstate, open_result['handle']) - if(status == false) then + if not status then smb.stop(smbstate) return false, close_result end @@ -4864,20 +4864,20 @@ function get_server_stats(host) -- Create the SMB session status, smbstate = start_smb(host, SRVSVC_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service local status, bind_result = bind(smbstate, SRVSVC_UUID, SRVSVC_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end -- Call netservergetstatistics for 'server' local status, netservergetstatistics_result = srvsvc_netservergetstatistics(smbstate, host.ip) - if(status == false) then + if not status then smb.stop(smbstate) return false, netservergetstatistics_result end @@ -4925,20 +4925,20 @@ function enum_shares(host) -- Create the SMB session status, smbstate = start_smb(host, SRVSVC_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service status, bind_result = bind(smbstate, SRVSVC_UUID, SRVSVC_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end -- Call netshareenumall status, netshareenumall_result = srvsvc_netshareenumall(smbstate, host.ip) - if(status == false) then + if not status then smb.stop(smbstate) return false, netshareenumall_result end @@ -4968,13 +4968,13 @@ function get_share_info(host, name) -- Create the SMB session local status, smbstate = start_smb(host, SRVSVC_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service local status, bind_result = bind(smbstate, SRVSVC_UUID, SRVSVC_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return false, bind_result end @@ -4983,7 +4983,7 @@ function get_share_info(host, name) local status, netsharegetinfo_result = srvsvc_netsharegetinfo(smbstate, host.ip, name, 2) stdnse.debug2("NetShareGetInfo status:%s result:%s", status, netsharegetinfo_result) - if(status == false) then + if not status then if(string.find(netsharegetinfo_result, "NT_STATUS_WERR_ACCESS_DENIED")) then stdnse.debug2("Calling NetShareGetInfo with information level 1") status, netsharegetinfo_result = srvsvc_netsharegetinfo(smbstate, host.ip, name, 1) @@ -5128,7 +5128,7 @@ function RRAS_SubmitRequest(smbstate, pReqBuffer, dwcbBufSize) RRAS_Opnums["RasRpcSubmitRequest"], req_blob) --sanity check - if(status == false) then + if not status then stdnse.debug( RRAS_DEBUG_LVL, "RRAS_SubmitRequest: Call function failed: %s", @@ -5266,7 +5266,7 @@ function DNSSERVER_Query(smbstate, server_name, zone, operation) DNSSERVER_Opnums['R_DnssrvQuery'], req_blob) --sanity check - if(status == false) then + if not status then stdnse.debug( DNSSERVER_DEBUG_LVL, "DNSSERVER_Query: Call function failed: %s", diff --git a/nselib/msrpcperformance.lua b/nselib/msrpcperformance.lua index 0656888ec..6c2da5a7e 100644 --- a/nselib/msrpcperformance.lua +++ b/nselib/msrpcperformance.lua @@ -435,26 +435,26 @@ function get_performance_data(host, objects) -- Create the SMB session local status, smbstate = msrpc.start_smb(host, msrpc.WINREG_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to WINREG service local status, bind_result = msrpc.bind(smbstate, msrpc.WINREG_UUID, msrpc.WINREG_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end -- Open HKEY_PERFORMANCE_DATA local status, openhkpd_result = msrpc.winreg_openhkpd(smbstate) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, openhkpd_result end local status, queryvalue_result = msrpc.winreg_queryvalue(smbstate, openhkpd_result['handle'], "Counter 009") - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, queryvalue_result end @@ -464,7 +464,7 @@ function get_performance_data(host, objects) local status local result = {} status, pos, result['title_database'] = parse_perf_title_database(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -474,7 +474,7 @@ function get_performance_data(host, objects) if(objects ~= nil and #objects > 0) then -- Query for the objects local status, queryvalue_result = msrpc.winreg_queryvalue(smbstate, openhkpd_result['handle'], objects) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, queryvalue_result end @@ -483,7 +483,7 @@ function get_performance_data(host, objects) pos = 1 local status, data_block status, pos, data_block = parse_perf_data_block(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -502,7 +502,7 @@ function get_performance_data(host, objects) -- Get the type of the object (this is basically the class definition -- info about the object instances) local status, object_type status, pos, object_type = parse_perf_object_type(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -523,7 +523,7 @@ function get_performance_data(host, objects) -- Parse the counter definitions for j = 1, object_type['NumCounters'], 1 do status, pos, counter_definitions[j] = parse_perf_counter_definition(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -542,7 +542,7 @@ function get_performance_data(host, objects) -- Instance definition local status status, pos, object_instances[j] = parse_perf_instance_definition(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -563,7 +563,7 @@ function get_performance_data(host, objects) -- The counter block local status, counter_block status, pos, counter_block = parse_perf_counter_block(queryvalue_result['value'], pos) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -572,7 +572,7 @@ function get_performance_data(host, objects) -- Each individual counter local status, counter_result status, pos, counter_result = parse_perf_counter(queryvalue_result['value'], pos, counter_definitions[k]) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end @@ -592,7 +592,7 @@ function get_performance_data(host, objects) -- Each individual counter local status, counter_result status, pos, counter_result = parse_perf_counter(queryvalue_result['value'], pos, counter_definitions[k]) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, pos end diff --git a/nselib/msrpctypes.lua b/nselib/msrpctypes.lua index bb8987f20..31e56f466 100644 --- a/nselib/msrpctypes.lua +++ b/nselib/msrpctypes.lua @@ -786,7 +786,7 @@ function marshall_int16(int16, pad) stdnse.debug4("MSRPC: Entering marshall_int16()") - if(pad == false) then + if not pad then return string.pack(" 0 and "WebDAV is ENABLED. Protected folder found but could not be exploited. Server does not appear to be vulnerable." or nil else return nmap.verbosity() > 0 and "WebDAV is ENABLED. No protected folder found; check not run. If you know a protected folder, add --script-args=webdavfolder=" or nil diff --git a/scripts/http-malware-host.nse b/scripts/http-malware-host.nse index 32bfb3ffd..263f28d45 100644 --- a/scripts/http-malware-host.nse +++ b/scripts/http-malware-host.nse @@ -40,7 +40,7 @@ portrule = shortport.http action = function(host, port) -- Check what response we get for a 404 local result, result_404, known_404 = http.identify_404(host, port) - if(result == false) then + if not result then return stdnse.format_output(false, "Couldn't identify 404 message: " .. result_404) end diff --git a/scripts/msrpc-enum.nse b/scripts/msrpc-enum.nse index 63dc63db8..df22a22da 100644 --- a/scripts/msrpc-enum.nse +++ b/scripts/msrpc-enum.nse @@ -78,13 +78,13 @@ end action = function(host,port) local status, smbstate status, smbstate = msrpc.start_smb(host,msrpc.EPMAPPER_PATH,true) - if(status == false) then + if not status then stdnse.debug1("SMB: " .. smbstate) return false, smbstate end local bind_result,epresult -- bind to endpoint mapper service status, bind_result = msrpc.bind(smbstate,msrpc.EPMAPPER_UUID, msrpc.EPMAPPER_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) stdnse.debug1("SMB: " .. bind_result) return false, bind_result diff --git a/scripts/nbstat.nse b/scripts/nbstat.nse index 758cf30b2..8d3242b3a 100644 --- a/scripts/nbstat.nse +++ b/scripts/nbstat.nse @@ -119,25 +119,25 @@ action = function(host) status, names, statistics = netbios.do_nbstat(host) status, names, statistics = netbios.do_nbstat(host) status, names, statistics = netbios.do_nbstat(host) - if(status == false) then + if not status then return stdnse.format_output(false, names) end -- Get the server name local status, server_name = netbios.get_server_name(host, names) - if(status == false) then + if not status then return stdnse.format_output(false, server_name) end -- Get the workstation name local status, workstation_name = netbios.get_workstation_name(host, names) - if(status == false) then + if not status then return stdnse.format_output(false, workstation_name) end -- Get the logged in user local status, user_name = netbios.get_user_name(host, names) - if(status == false) then + if not status then return stdnse.format_output(false, user_name) end diff --git a/scripts/p2p-conficker.nse b/scripts/p2p-conficker.nse index 4e457832e..800bd47fe 100644 --- a/scripts/p2p-conficker.nse +++ b/scripts/p2p-conficker.nse @@ -258,7 +258,7 @@ local function prng_generate_ports(ip, seed) ports[(i % 2) + 3] = (v2 & 0xFFFF) ~ ports[(i % 2) + 3] end - until(is_blacklisted_port(ports[3]) == false and is_blacklisted_port(ports[4]) == false and ports[3] ~= ports[4]) + until not is_blacklisted_port(ports[3]) and not is_blacklisted_port(ports[4]) and ports[3] ~= ports[4] return {ports[1], ports[2], ports[3], ports[4]} end @@ -483,7 +483,7 @@ local function conficker_check(ip, port, protocol) local response status, packet = p2p_create_packet(protocol) - if(status == false) then + if not status then return false, packet end @@ -491,7 +491,7 @@ local function conficker_check(ip, port, protocol) socket = nmap.new_socket() socket:set_timeout(5000) status, response = socket:connect(ip, port, protocol) - if(status == false) then + if not status then return false, "Couldn't establish connection (" .. response .. ")" end @@ -500,7 +500,7 @@ local function conficker_check(ip, port, protocol) -- Read a response (2 bytes minimum, because that's the TCP length) status, response = socket:receive_bytes(2) - if(status == false) then + if not status then return false, "Couldn't receive bytes: " .. response elseif(response == "ERROR") then return false, "Failed to receive data" @@ -522,7 +522,7 @@ local function conficker_check(ip, port, protocol) tries = tries - 1 local status, response2 = socket:receive_bytes(length - (#response - 2)) - if(status == false) then + if not status then return false, "Couldn't receive bytes: " .. response2 elseif(response2 == "ERROR") then return false, "Failed to receive data" @@ -544,7 +544,7 @@ local function conficker_check(ip, port, protocol) local status, result = p2p_parse(response) - if(status == false) then + if not status then return false, "Data received, but wasn't Conficker data: " .. result end diff --git a/scripts/s7-info.nse b/scripts/s7-info.nse index 38980aec3..bc0a6ca1a 100644 --- a/scripts/s7-info.nse +++ b/scripts/s7-info.nse @@ -63,12 +63,12 @@ portrule = shortport.version_port_or_service(102, "iso-tsap", "tcp") -- @param bytes how many bytes (minimum) you expect back local function send_receive(socket, query, bytes) local sendstatus, senderr = socket:send(query) - if(sendstatus == false) then + if not sendstatus then return "Error Sending S7COMM" end -- receive response local rcvstatus, response = socket:receive_bytes(bytes) - if(rcvstatus == false) then + if not rcvstatus then return "Error Reading S7COMM" end return response diff --git a/scripts/samba-vuln-cve-2012-1182.nse b/scripts/samba-vuln-cve-2012-1182.nse index 8e33c80a7..7148e9d9e 100644 --- a/scripts/samba-vuln-cve-2012-1182.nse +++ b/scripts/samba-vuln-cve-2012-1182.nse @@ -96,14 +96,14 @@ from an anonymous connection. -- create SMB session local status, smbstate status, smbstate = msrpc.start_smb(host, msrpc.SAMR_PATH,true) - if(status == false) then + if not status then return false, smbstate end -- bind to SAMR service local bind_result status, bind_result = msrpc.bind(smbstate, msrpc.SAMR_UUID, msrpc.SAMR_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end @@ -119,7 +119,7 @@ from an anonymous connection. local marshaledHandle = string.rep("X",20) status, result = msrpc.samr_getaliasmembership(smbstate,marshaledHandle, data) stdnse.debug2("msrpc.samr_getaliasmembership: %s, '%s'", status, result) - if(status == false and string.find(result,"Failed to receive bytes after 5 attempts") ~= nil) then + if not status and string.find(result, "Failed to receive bytes after 5 attempts") then samba_cve.state = vulns.STATE.VULN -- connection dropped, server crashed end diff --git a/scripts/smb-brute.nse b/scripts/smb-brute.nse index 4931afb50..51d8705f9 100644 --- a/scripts/smb-brute.nse +++ b/scripts/smb-brute.nse @@ -254,7 +254,7 @@ local function stop_session(hostinfo) if(hostinfo['smbstate'] ~= nil) then stdnse.debug2("Stopping the SMB session") status, err = smb.stop(hostinfo['smbstate']) - if(status == false) then + if not status then return false, err end @@ -277,7 +277,7 @@ local function restart_session(hostinfo) stdnse.debug2("Starting the SMB session") status, smbstate = smb.start_ex(hostinfo['host'], true, nil, nil, nil, true) - if(status == false) then + if not status then return false, smbstate end @@ -547,7 +547,7 @@ local function initialize(host) -- Get the OS (identifying windows versions tells us which hash to use) result, os = smb.get_os(host) - if(result == false or os['os'] == nil) then + if not result or not os['os'] then hostinfo['os'] = "" else hostinfo['os'] = os['os'] @@ -577,7 +577,7 @@ local function initialize(host) if(not(hostinfo['have_user_list'])) then stdnse.debug1("Couldn't enumerate users (normal for Windows XP and higher), using unpwdb initially") status, hostinfo['user_list_default'] = unpwdb.usernames() - if(status == false) then + if not status then return false, "Couldn't open username file" end end @@ -585,7 +585,7 @@ local function initialize(host) -- Open the password file stdnse.debug1("Opening password list") status, hostinfo['password_list'] = unpwdb.passwords() - if(status == false) then + if not status then return false, "Couldn't open password file" end @@ -593,7 +593,7 @@ local function initialize(host) stdnse.debug1("Starting the initial SMB session") local err status, err = restart_session(hostinfo) - if(status == false) then + if not status then stop_session(hostinfo) return false, err end @@ -630,7 +630,7 @@ local function initialize(host) -- Restart the SMB connection so we have a clean slate stdnse.debug1("Restarting the session before the bruteforce") status, err = restart_session(hostinfo) - if(status == false) then + if not status then stop_session(hostinfo) return false, err end @@ -808,7 +808,7 @@ local function validate_usernames(hostinfo) -- Start a session status, err = restart_session(hostinfo) - if(status == false) then + if not status then return false, err end @@ -850,13 +850,13 @@ local function validate_usernames(hostinfo) -- Any password works (often happens with 'guest' account) stdnse.debug1("All passwords accepted for %s (goes to %s)", username, result_short_strings[result]) status, err = found_account(hostinfo, username, "", result) - if(status == false) then + if not status then return false, err end else -- Blank password worked, but not random one status, err = found_account(hostinfo, username, "", result) - if(status == false) then + if not status then return false, err end end @@ -901,7 +901,7 @@ function found_account(hostinfo, username, password, result) if(result == results.SUCCESS) then -- Stop the connection -- this lets us do some queries status, err = stop_session(hostinfo) - if(status == false) then + if not status then return false, err end @@ -925,7 +925,7 @@ function found_account(hostinfo, username, password, result) end -- If we haven't retrieved the real user list yet, do so - if(hostinfo['have_user_list'] == false) then + if not hostinfo['have_user_list'] then -- Attempt to enumerate users stdnse.debug1("Trying to get user list from server using newly discovered account") local _ @@ -947,7 +947,7 @@ function found_account(hostinfo, username, password, result) -- Start the session again status, err = restart_session(hostinfo) - if(status == false) then + if not status then return false, err end @@ -968,20 +968,20 @@ local function go(host) -- Initialize the hostinfo object, which sets up the initial variables result, hostinfo = initialize(host) - if(result == false) then + if not result then return false, hostinfo end -- If invalid accounts don't give guest, we can determine the existence of users by trying to -- log in with an invalid password and checking the value status, err = validate_usernames(hostinfo) - if(status == false) then + if not status then return false, err end -- Start up the SMB session status, err = restart_session(hostinfo) - if(status == false) then + if not status then return false, err end @@ -1015,7 +1015,7 @@ local function go(host) if(not(stdnse.get_script_args( "smblockout" ))) then -- Mark it as found, which is technically true status, err = found_account(hostinfo, username, nil, results.ACCOUNT_LOCKED_NOW) - if(status == false) then + if not status then return err end @@ -1032,7 +1032,7 @@ local function go(host) -- Reset the connection stdnse.debug2("Found an account; resetting connection") status, err = restart_session(hostinfo) - if(status == false) then + if not status then return false, err end @@ -1048,7 +1048,7 @@ local function go(host) -- Take normal actions for finding an account status, err = found_account(hostinfo, username, case_password, result) - if(status == false) then + if not status then return err end end @@ -1075,7 +1075,7 @@ action = function(host) local locked_result status, result, locked_result = go(host) - if(status == false) then + if not status then return stdnse.format_output(false, result) end diff --git a/scripts/smb-double-pulsar-backdoor.nse b/scripts/smb-double-pulsar-backdoor.nse index b0b991dfe..a2d28aa3b 100644 --- a/scripts/smb-double-pulsar-backdoor.nse +++ b/scripts/smb-double-pulsar-backdoor.nse @@ -84,7 +84,7 @@ local function send_transaction2(smbstate, sub_command, function_parameters, fun -- Send the transaction request stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2") local result, err = smb.smb_send(smbstate, header, parameters, data, overrides) - if(result == false) then + if not result then return false, err end diff --git a/scripts/smb-enum-processes.nse b/scripts/smb-enum-processes.nse index cb81df52e..88560f2af 100644 --- a/scripts/smb-enum-processes.nse +++ b/scripts/smb-enum-processes.nse @@ -197,7 +197,7 @@ end action = function(host) -- Get the process list local status, result = msrpcperformance.get_performance_data(host, "230") - if status == false then + if not status then return stdnse.format_output(false, result) end diff --git a/scripts/smb-enum-services.nse b/scripts/smb-enum-services.nse index b6885bdbb..8d01af2c7 100644 --- a/scripts/smb-enum-services.nse +++ b/scripts/smb-enum-services.nse @@ -868,7 +868,7 @@ action = function(host, port) status, bind_result = msrpc.bind(smbstate, msrpc.SVCCTL_UUID, msrpc.SVCCTL_VERSION, nil) - if(status == false) then + if not status then smb.stop(smbstate) return nil, stdnse.format_output(false, bind_result) end @@ -878,7 +878,7 @@ action = function(host, port) status, open_result = msrpc.svcctl_openscmanagerw(smbstate, host.ip, 0x02000000) - if(status == false) then + if not status then smb.stop(smbstate) return nil, stdnse.format_output(false, open_result) end @@ -904,7 +904,7 @@ action = function(host, port) -- Fetches service name, display name and service status of every service. status, result = msrpc.svcctl_enumservicesstatusw(smbstate, open_result["handle"], dwservicetype, dwservicestate) - if(status == false) then + if not status then smb.stop(smbstate) return nil, stdnse.format_output(false, result) end diff --git a/scripts/smb-enum-sessions.nse b/scripts/smb-enum-sessions.nse index 495c583cb..b71c8f5dd 100644 --- a/scripts/smb-enum-sessions.nse +++ b/scripts/smb-enum-sessions.nse @@ -86,20 +86,20 @@ local function srvsvc_enum_sessions(host) -- Create the SMB session status, smbstate = msrpc.start_smb(host, msrpc.SRVSVC_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service status, bind_result = msrpc.bind(smbstate, msrpc.SRVSVC_UUID, msrpc.SRVSVC_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end -- Call netsessenum status, netsessenum_result = msrpc.srvsvc_netsessenum(smbstate, host.ip) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, netsessenum_result end @@ -125,19 +125,19 @@ local function winreg_enum_rids(host) -- Create the SMB session local status, smbstate = msrpc.start_smb(host, msrpc.WINREG_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to WINREG service local status, bind_result = msrpc.bind(smbstate, msrpc.WINREG_UUID, msrpc.WINREG_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end local status, openhku_result = msrpc.winreg_openhku(smbstate) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, openhku_result end @@ -161,13 +161,13 @@ local function winreg_enum_rids(host) -- Query the info about this key. The response will tell us when the user logged into the server. local status, queryinfokey_result = msrpc.winreg_queryinfokey(smbstate, openkey_result['handle']) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, queryinfokey_result end local status, closekey_result = msrpc.winreg_closekey(smbstate, openkey_result['handle']) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, closekey_result end @@ -184,7 +184,7 @@ local function winreg_enum_rids(host) until status ~= true local status, closekey_result = msrpc.winreg_closekey(smbstate, openhku_result['handle']) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, closekey_result end @@ -193,20 +193,20 @@ local function winreg_enum_rids(host) -- Start a new SMB session local status, smbstate = msrpc.start_smb(host, msrpc.LSA_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to LSA service local status, bind_result = msrpc.bind(smbstate, msrpc.LSA_UUID, msrpc.LSA_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end -- Get a policy handle local status, openpolicy2_result = msrpc.lsa_openpolicy2(smbstate, host.ip) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, openpolicy2_result end @@ -223,7 +223,7 @@ local function winreg_enum_rids(host) local status, lookupsids2_result = msrpc.lsa_lookupsids2(smbstate, openpolicy2_result['policy_handle'], {elements[i]['name']}) - if(status == false) then + if not status then -- It may not succeed, if it doesn't that's ok stdnse.debug3("MSRPC: Lookup failed") else @@ -273,7 +273,7 @@ action = function(host) -- Enumerate the logged in users local logged_in = {} local status1, users = winreg_enum_rids(host) - if(status1 == false) then + if not status1 then logged_in['warning'] = "Couldn't enumerate login sessions: " .. users else logged_in['name'] = "Users logged in" @@ -292,7 +292,7 @@ action = function(host) -- Get the connected sessions local sessions_output = {} local status2, sessions = srvsvc_enum_sessions(host) - if(status2 == false) then + if not status2 then sessions_output['warning'] = "Couldn't enumerate SMB sessions: " .. sessions else sessions_output['name'] = "Active SMB sessions" diff --git a/scripts/smb-enum-shares.nse b/scripts/smb-enum-shares.nse index f21dac468..f6ccfd5ee 100644 --- a/scripts/smb-enum-shares.nse +++ b/scripts/smb-enum-shares.nse @@ -108,7 +108,7 @@ action = function(host) -- Get the list of shares status, shares, extra = smb.share_get_list(host) - if(status == false) then + if not status then return stdnse.format_output(false, string.format("Couldn't enumerate shares: %s", shares)) end @@ -118,7 +118,7 @@ action = function(host) -- Find out who the current user is local result, username, domain = smb.get_account(host) - if(result == false) then + if not result then username = "" domain = "" end diff --git a/scripts/smb-enum-users.nse b/scripts/smb-enum-users.nse index 19ba7fb43..424e070c5 100644 --- a/scripts/smb-enum-users.nse +++ b/scripts/smb-enum-users.nse @@ -200,7 +200,7 @@ action = function(host) end -- Check if both failed - if(samr_status == false and lsa_status == false) then + if not samr_status and not lsa_status then if(string.find(lsa_result, 'ACCESS_DENIED')) then return stdnse.format_output(false, "Access denied while trying to enumerate users; except against Windows 2000, Guest or better is typically required") end diff --git a/scripts/smb-os-discovery.nse b/scripts/smb-os-discovery.nse index 879941575..b01649358 100644 --- a/scripts/smb-os-discovery.nse +++ b/scripts/smb-os-discovery.nse @@ -151,7 +151,7 @@ action = function(host) local request_time = os.time() local status, result = smb.get_os(host) - if(status == false) then + if not status then return stdnse.format_output(false, result) end diff --git a/scripts/smb-print-text.nse b/scripts/smb-print-text.nse index 3e6b5f92b..2d98fd384 100644 --- a/scripts/smb-print-text.nse +++ b/scripts/smb-print-text.nse @@ -57,14 +57,14 @@ action = function(host,port) file:close() end status, smbstate = msrpc.start_smb(host, msrpc.SPOOLSS_PATH,true) - if(status == false) then + if not status then stdnse.debug1("SMB: " .. smbstate) return false, smbstate end local bind_result status, bind_result = msrpc.bind(smbstate,msrpc.SPOOLSS_UUID, msrpc.SPOOLSS_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) stdnse.debug1("SMB: " .. bind_result) return false, bind_result @@ -77,7 +77,7 @@ action = function(host,port) local REMSmb_NetShareEnum_P = "WrLeh" local REMSmb_share_info_1 = "B13BWz" status, lanman_result = msrpc.call_lanmanapi(smbstate,0,REMSmb_NetShareEnum_P,REMSmb_share_info_1,string.pack(" \\\\%s\\%s", config.local_service_file, config.share, config.service_file) local status, err status, err = smb.file_upload(host, config.local_service_file, config.share, "\\" .. config.service_file, overrides, is_xor_encoded) - if(status == false) then + if not status then cleanup(host, config) return false, string.format("Couldn't upload the service file: %s\n", err) end @@ -1140,7 +1140,7 @@ local function upload_everything(host, config) if(mod.upload) then stdnse.debug1("Uploading: %s => \\\\%s\\%s", mod.filename, config.share, mod.upload_name) status, err = smb.file_upload(host, mod.filename, config.share, "\\" .. mod.upload_name, overrides) - if(status == false) then + if not status then cleanup(host, config) return false, string.format("Couldn't upload module %s: %s\n", mod.program, err) end @@ -1159,7 +1159,7 @@ local function upload_everything(host, config) stdnse.debug1("Uploading extra file: %s => \\\\%s\\%s", extrafile_local, config.share, extrafile) status, err = smb.file_upload(host, extrafile_local, config.share, extrafile, overrides) - if(status == false) then + if not status then cleanup(host, config) return false, string.format("Couldn't upload extra file %s: %s\n", extrafile_local, err) end @@ -1178,7 +1178,7 @@ end --@return err An error message if status is false. local function create_service(host, config) local status, err = msrpc.service_create(host, config.service_name, config.path .. "\\" .. config.service_file) - if(status == false) then + if not status then stdnse.debug1("Couldn't create the service: %s", err) cleanup(host, config) @@ -1235,7 +1235,7 @@ end --@return err An error message if status is false. local function start_service(host, config, params) local status, err = msrpc.service_start(host, config.service_name, params) - if(status == false) then + if not status then stdnse.debug1("Couldn't start the service: %s", err) return false, string.format("Couldn't start the service on the remote machine: %s", err) end @@ -1546,7 +1546,7 @@ and place it in nselib/data/psexec/ under the Nmap DATADIR. -- Build the output into a nice table local response status, response = parse_output(config, result) - if(status == false) then + if not status then return stdnse.format_output(false, "Couldn't parse output: " .. response) end diff --git a/scripts/smb-security-mode.nse b/scripts/smb-security-mode.nse index 8bf823d78..995354284 100644 --- a/scripts/smb-security-mode.nse +++ b/scripts/smb-security-mode.nse @@ -93,12 +93,12 @@ action = function(host) local overrides = {} status, state = smb.start(host) - if(status == false) then + if not status then return stdnse.format_output(false, state) end status, err = smb.negotiate_protocol(state, overrides) - if(status == false) then + if not status then smb.stop(state) return stdnse.format_output(false, err) end diff --git a/scripts/smb-server-stats.nse b/scripts/smb-server-stats.nse index caa93643d..6d2720594 100644 --- a/scripts/smb-server-stats.nse +++ b/scripts/smb-server-stats.nse @@ -51,7 +51,7 @@ action = function(host) result, stats = msrpc.get_server_stats(host) - if(result == false) then + if not result then return stdnse.format_output(false, response) end diff --git a/scripts/smb-system-info.nse b/scripts/smb-system-info.nse index ba69513e0..e23e89562 100644 --- a/scripts/smb-system-info.nse +++ b/scripts/smb-system-info.nse @@ -74,19 +74,19 @@ end local function reg_get_value(smbstate, handle, key, value) -- Open the key local status, openkey_result = msrpc.winreg_openkey(smbstate, handle, key) - if(status == false) then + if not status then return false, openkey_result end -- Query the value local status, queryvalue_result = msrpc.winreg_queryvalue(smbstate, openkey_result['handle'], value) - if(status == false) then + if not status then return false, queryvalue_result end -- Close the key local status, closekey_result = msrpc.winreg_closekey(smbstate, openkey_result['handle'], value) - if(status == false) then + if not status then return false, closekey_result end @@ -99,27 +99,27 @@ local function get_info_registry(host) -- Create the SMB session local status, smbstate = msrpc.start_smb(host, msrpc.WINREG_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to WINREG service local status, bind_result = msrpc.bind(smbstate, msrpc.WINREG_UUID, msrpc.WINREG_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end -- Open HKEY_LOCAL_MACHINE local status, openhklm_result = msrpc.winreg_openhklm(smbstate) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, openhklm_result end -- Processor information result['status-number_of_processors'], result['number_of_processors'] = reg_get_value(smbstate, openhklm_result['handle'], "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "NUMBER_OF_PROCESSORS") - if(result['status-number_of_processors'] == false) then + if not result['status-number_of_processors'] then result['number_of_processors'] = 0 end result['status-os'], result['os'] = reg_get_value(smbstate, openhklm_result['handle'], "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment", "OS") @@ -148,7 +148,7 @@ local function get_info_registry(host) -- OS Information result['status-csdversion'], result['csdversion'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Windows NT\\CurrentVersion", "CSDVersion") - if(result['status-csdversion'] == false) then + if not result['status-csdversion'] then result['csdversion'] = "(no service packs)" end result['status-currentbuildnumber'], result['currentbuildnumber'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Windows NT\\CurrentVersion", "CurrentBuildNumber") @@ -172,7 +172,7 @@ local function get_info_registry(host) -- Software versions result['status-ie_version'], result['ie_version'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Microsoft\\Internet Explorer\\Version Vector", "IE") result['status-ff_version'], result['ff_version'] = reg_get_value(smbstate, openhklm_result['handle'], "Software\\Mozilla\\Mozilla Firefox", "CurrentVersion") - if(result['status-ff_version'] == false) then + if not result['status-ff_version'] then result['ff_version'] = "" end @@ -185,7 +185,7 @@ action = function(host) local status, result = get_info_registry(host) - if(status == false) then + if not status then return stdnse.format_output(false, result) end @@ -207,7 +207,7 @@ action = function(host) -- remove trailing zero terminator local num_procs = result['number_of_processors']:match("^[^%z]*") for i = 0, tonumber(num_procs) - 1, 1 do - if(result['status-processornamestring'..i] == false) then + if not result['status-processornamestring'..i] then result['status-processornamestring'..i] = "Unknown" end diff --git a/scripts/smb-vuln-conficker.nse b/scripts/smb-vuln-conficker.nse index 976a92617..ebf330542 100644 --- a/scripts/smb-vuln-conficker.nse +++ b/scripts/smb-vuln-conficker.nse @@ -108,13 +108,13 @@ function check_conficker(host) -- Create the SMB session status, smbstate = msrpc.start_smb(host, "\\\\BROWSER", true) - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service status, bind_result = msrpc.bind(smbstate, msrpc.SRVSVC_UUID, msrpc.SRVSVC_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end @@ -130,7 +130,7 @@ function check_conficker(host) -- Try checking an illegal string ("\..\") to find Conficker.C and earlier status, netpathcanonicalize_result, error_result = msrpc.srvsvc_netpathcanonicalize(smbstate, host.ip, "\\..\\") - if(status == false) then + if not status then if(string.find(netpathcanonicalize_result, "INVALID_NAME")) then msrpc.stop_smb(smbstate) return true, CLEAN @@ -168,7 +168,7 @@ This system shows signs of being infected by a variant of the worm Conficker.]], -- Check for Conficker status, result = check_conficker(host) - if(status == false) then + if not status then vuln_table.extra_info = CONFICKER_ERROR_HELP[result] or "UNKNOWN; got error " .. result vuln_table.state = vulns.STATE.NOT_VULN else diff --git a/scripts/smb-vuln-cve-2017-7494.nse b/scripts/smb-vuln-cve-2017-7494.nse index e48407c4d..6bf2a5fbd 100644 --- a/scripts/smb-vuln-cve-2017-7494.nse +++ b/scripts/smb-vuln-cve-2017-7494.nse @@ -459,7 +459,7 @@ and execute it. if not version then local status, result = smb.get_os(host) - if(status == false) then + if not status then return stdnse.format_output(false, result) end diff --git a/scripts/smb-vuln-cve2009-3103.nse b/scripts/smb-vuln-cve2009-3103.nse index 955fac94d..eb5c1c8f7 100644 --- a/scripts/smb-vuln-cve2009-3103.nse +++ b/scripts/smb-vuln-cve2009-3103.nse @@ -85,13 +85,13 @@ local function check_smbv2_dos(host) end local status, result = socket:connect(host, 445) - if(status == false) then + if not status then socket:close() return false, "Couldn't connect to host: " .. result end status, result = socket:send(buf) - if(status == false) then + if not status then socket:close() return false, "Couldn't send the buffer: " .. result end @@ -115,7 +115,7 @@ local function check_smbv2_dos(host) status, result = socket:connect(host, 445) -- Check the result - if(status == false or status == nil) then + if not status then stdnse.debug1("Connect failed, host is likely vulnerable!") socket:close() return true, VULNERABLE @@ -124,7 +124,7 @@ local function check_smbv2_dos(host) -- Try sending something stdnse.debug1("Attempting to send data to the host") status, result = socket:send("AAAA") - if(status == false or status == nil) then + if not status then stdnse.debug1("Send failed, host is likely vulnerable!") socket:close() return true, VULNERABLE @@ -161,7 +161,7 @@ action = function(host) -- Check for SMBv2 vulnerability status, result = check_smbv2_dos(host) - if(status == false) then + if not status then vuln_table.state = vulns.STATE.NOT_VULN else if(result == VULNERABLE) then diff --git a/scripts/smb-vuln-ms06-025.nse b/scripts/smb-vuln-ms06-025.nse index 1da09615c..a772e3b02 100644 --- a/scripts/smb-vuln-ms06-025.nse +++ b/scripts/smb-vuln-ms06-025.nse @@ -80,10 +80,10 @@ function check_ms06_025(host) --first we try with the "\router" pipe, then the "\srvsvc" pipe. local status, smb_result, smbstate, err_msg status, smb_result = msrpc.start_smb(host, msrpc.ROUTER_PATH) - if(status == false) then + if not status then err_msg = smb_result status, smb_result = msrpc.start_smb(host, msrpc.SRVSVC_PATH) --rras is also accessible across SRVSVC pipe - if(status == false) then + if not status then return false, NOTUP --if not accessible across both pipes then service is inactive end end @@ -91,7 +91,7 @@ function check_ms06_025(host) --bind to RRAS service local bind_result status, bind_result = msrpc.bind(smbstate, msrpc.RASRPC_UUID, msrpc.RASRPC_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, UNKNOWN --if bind operation results with a false status we can't conclude anything. end @@ -107,7 +107,7 @@ function check_ms06_025(host) status, sr_result = msrpc.RRAS_SubmitRequest(smbstate, req) msrpc.stop_smb(smbstate) --sanity check - if(status == false) then + if not status then stdnse.debug3("check_ms06_025: RRAS_SubmitRequest failed") if(sr_result == "NT_STATUS_PIPE_BROKEN") then return true, VULNERABLE @@ -142,7 +142,7 @@ action = function(host) -- Check for ms06-025 status, result = check_ms06_025(host) - if(status == false) then + if not status then if(result == NOTUP) then vuln_table.extra_info = "Ras RPC service is not enabled." vuln_table.state = vulns.STATE.NOT_VULN diff --git a/scripts/smb-vuln-ms07-029.nse b/scripts/smb-vuln-ms07-029.nse index 0c725559a..e390cdf11 100644 --- a/scripts/smb-vuln-ms07-029.nse +++ b/scripts/smb-vuln-ms07-029.nse @@ -76,14 +76,14 @@ function check_ms07_029(host) --create the SMB session local status, smbstate status, smbstate = msrpc.start_smb(host, msrpc.DNSSERVER_PATH) - if(status == false) then + if not status then stdnse.debug1("check_ms07_029: Service is not active.") return false, NOTUP --if not accessible across pipe then the service is inactive end --bind to DNSSERVER service local bind_result status, bind_result = msrpc.bind(smbstate, msrpc.DNSSERVER_UUID, msrpc.DNSSERVER_VERSION) - if(status == false) then + if not status then stdnse.debug1("check_ms07_029: false") msrpc.stop_smb(smbstate) return false, UNKNOWN --if bind operation results with a false status we can't conclude anything. @@ -97,7 +97,7 @@ function check_ms07_029(host) 1)--any op num will do --sanity check msrpc.stop_smb(smbstate) - if(status == false) then + if not status then stdnse.debug1("check_ms07_029: DNSSERVER_Query failed") if(q_result == "NT_STATUS_PIPE_BROKEN") then return true, VULNERABLE @@ -132,7 +132,7 @@ action = function(host) -- Check for ms07-029 status, result = check_ms07_029(host) - if(status == false) then + if not status then if(result == NOTUP) then vuln_table.extra_info = "Service is not active." vuln_table.state = vulns.STATE.NOT_VULN diff --git a/scripts/smb-vuln-ms08-067.nse b/scripts/smb-vuln-ms08-067.nse index 74ab3279e..57dbedca7 100644 --- a/scripts/smb-vuln-ms08-067.nse +++ b/scripts/smb-vuln-ms08-067.nse @@ -80,13 +80,13 @@ function check_ms08_067(host) -- Create the SMB session status, smbstate = msrpc.start_smb(host, "\\\\BROWSER") - if(status == false) then + if not status then return false, smbstate end -- Bind to SRVSVC service status, bind_result = msrpc.bind(smbstate, msrpc.SRVSVC_UUID, msrpc.SRVSVC_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end @@ -101,7 +101,7 @@ function check_ms08_067(host) -- Stop the SMB session msrpc.stop_smb(smbstate) - if(status == false) then + if not status then if(string.find(netpathcompare_result, "WERR_INVALID_PARAMETER") ~= nil) then return true, INFECTED elseif(string.find(netpathcompare_result, "INVALID_NAME") ~= nil) then @@ -136,7 +136,7 @@ action = function(host) } -- Check for ms08-067 status, result, message = check_ms08_067(host) - if(status == false) then + if not status then vuln_table.state = vulns.STATE.NOT_VULN else if(result == VULNERABLE) then diff --git a/scripts/smb-vuln-ms10-054.nse b/scripts/smb-vuln-ms10-054.nse index ebaf09f47..372709c0c 100644 --- a/scripts/smb-vuln-ms10-054.nse +++ b/scripts/smb-vuln-ms10-054.nse @@ -90,7 +90,7 @@ local function send_transaction2(smbstate, sub_command, function_parameters) -- Send the transaction request stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION2") local result, err = smb.smb_send(smbstate, header, parameters, data, {}) - if(result == false) then + if not result then return false, err end diff --git a/scripts/smb-vuln-ms10-061.nse b/scripts/smb-vuln-ms10-061.nse index a910ed982..d8ec9beb4 100644 --- a/scripts/smb-vuln-ms10-061.nse +++ b/scripts/smb-vuln-ms10-061.nse @@ -91,14 +91,14 @@ aka "Print Spooler Service Impersonation Vulnerability." ms10_061.state = vulns.STATE.NOT_VULN local status, smbstate status, smbstate = msrpc.start_smb(host, msrpc.SPOOLSS_PATH,true) - if(status == false) then + if not status then stdnse.debug1("SMB: " .. smbstate) return false, smbstate end local bind_result status, bind_result = msrpc.bind(smbstate,msrpc.SPOOLSS_UUID, msrpc.SPOOLSS_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) stdnse.debug1("SMB: " .. bind_result) return false, bind_result @@ -112,7 +112,7 @@ aka "Print Spooler Service Impersonation Vulnerability." local REMSmb_share_info_1 = "B13BWz" status, lanman_result = msrpc.call_lanmanapi( smbstate, 0, REMSmb_NetShareEnum_P, REMSmb_share_info_1, "\x01\x00\x7e\xff") - if status == false then + if not status then stdnse.debug1("SMB: " .. lanman_result) stdnse.debug1("SMB: Looks like LANMAN API is not available. Try setting printer script arg.") end diff --git a/scripts/smb-vuln-ms17-010.nse b/scripts/smb-vuln-ms17-010.nse index e2cea30ae..8bff5c85a 100644 --- a/scripts/smb-vuln-ms17-010.nse +++ b/scripts/smb-vuln-ms17-010.nse @@ -123,7 +123,7 @@ local function check_ms17010(host, port, sharename) ) stdnse.debug2("SMB: Sending SMB_COM_TRANSACTION") local result, err = smb.smb_send(smbstate, smb_header, smb_params, '', overrides) - if(result == false) then + if not result then stdnse.debug1("There was an error in the SMB_COM_TRANSACTION request") return false, err end diff --git a/scripts/smb-vuln-regsvc-dos.nse b/scripts/smb-vuln-regsvc-dos.nse index 4b523e725..1653d5297 100644 --- a/scripts/smb-vuln-regsvc-dos.nse +++ b/scripts/smb-vuln-regsvc-dos.nse @@ -66,20 +66,20 @@ function check_winreg_Enum_crash(host) -- Create the SMB session status, smbstate = msrpc.start_smb(host, msrpc.WINREG_PATH) - if(status == false) then + if not status then return false, smbstate end -- Bind to WINREG service status, bind_result = msrpc.bind(smbstate, msrpc.WINREG_UUID, msrpc.WINREG_VERSION, nil) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, bind_result end local openhku_result status, openhku_result = msrpc.winreg_openhku(smbstate) - if(status == false) then + if not status then msrpc.stop_smb(smbstate) return false, openhku_result end @@ -89,7 +89,7 @@ function check_winreg_Enum_crash(host) status, enumkey_result = msrpc.winreg_enumkey(smbstate, openhku_result['handle'], 0, nil) msrpc.stop_smb(smbstate) - if(status == false) then + if not status then return true, VULNERABLE end return true, PATCHED @@ -111,7 +111,7 @@ while working on smb-enum-sessions. -- Check for a winreg_Enum crash status, result = check_winreg_Enum_crash(host) - if(status == false) then + if not status then vuln_table.state = vulns.STATE.NOT_VULN else if(result == VULNERABLE) then diff --git a/scripts/smb-vuln-webexec.nse b/scripts/smb-vuln-webexec.nse index 9fedaa0a8..c7d999f3c 100644 --- a/scripts/smb-vuln-webexec.nse +++ b/scripts/smb-vuln-webexec.nse @@ -105,7 +105,7 @@ action = function(host, port) end local open_status, open_service_result = msrpc.svcctl_openservicew(smbstate, open_result['handle'], 'webexservice', 0x00010) - if open_status == false then + if not open_status then status, close_result = msrpc.svcctl_closeservicehandle(smbstate, open_result['handle']) smb.stop(smbstate) if string.match(open_service_result, 'NT_STATUS_SERVICE_DOES_NOT_EXIST') then diff --git a/scripts/smb-webexec-exploit.nse b/scripts/smb-webexec-exploit.nse index 06b727a13..b54544786 100644 --- a/scripts/smb-webexec-exploit.nse +++ b/scripts/smb-webexec-exploit.nse @@ -96,7 +96,7 @@ action = function(host, port) local open_status, open_service_result = msrpc.svcctl_openservicew(smbstate, open_result['handle'], 'webexservice', 0x00010) - if open_status == false then + if not open_status then status, close_result = msrpc.svcctl_closeservicehandle(smbstate, open_result['handle']) smb.stop(smbstate) if string.match(open_service_result, 'NT_STATUS_SERVICE_DOES_NOT_EXIST') then diff --git a/scripts/smb2-capabilities.nse b/scripts/smb2-capabilities.nse index 172882324..bc80f44f4 100644 --- a/scripts/smb2-capabilities.nse +++ b/scripts/smb2-capabilities.nse @@ -59,7 +59,7 @@ action = function(host,port) -- Checking if SMB 2+ is supported in general status, smbstate = smb.start(host) - if(status == false) then + if not status then return false, smbstate end local max_dialect @@ -73,7 +73,7 @@ action = function(host,port) for i, dialect in pairs(smb2.dialects()) do -- we need a clean connection for each negotiate request status, smbstate = smb.start(host) - if(status == false) then + if not status then stdnse.debug1("Could not establish a connection.") return nil end diff --git a/scripts/smb2-security-mode.nse b/scripts/smb2-security-mode.nse index ae99caaa4..a20dd60f9 100644 --- a/scripts/smb2-security-mode.nse +++ b/scripts/smb2-security-mode.nse @@ -43,7 +43,7 @@ action = function(host,port) local output = stdnse.output_table() local status, smbstate = smb.start(host) - if(status == false) then + if not status then return false, smbstate end -- SMB signing configuration appears to be global so diff --git a/scripts/snmp-brute.nse b/scripts/snmp-brute.nse index 03ff4a00e..8ca75cee6 100644 --- a/scripts/snmp-brute.nse +++ b/scripts/snmp-brute.nse @@ -247,12 +247,12 @@ action = function(host, port) local socket = nmap.new_socket("udp") status = socket:connect(host, port) - if ( not(status) ) then + if not status then return fail("Failed to connect to server") end local status, _, lport = socket:get_info() - if( not(status) ) then + if not status then return fail("Failed to retrieve local port") end