diff --git a/CHANGELOG b/CHANGELOG index 1afeb9a8e..9b3fbcb8e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,9 @@ # Nmap Changelog ($Id$); -*-text-*- +o [NSE][GH#862] SNMP scripts will now take a community string provided like + `--script-args creds.snmp=private`, which previously did not work because it + was interpreted as a username. [Daniel Miller] + o [NSE] Resolved several issues in the default HTTP redirect rules: - [GH#826] A redirect is now cancelled if the original URL contains embedded credentials diff --git a/nselib/snmp.lua b/nselib/snmp.lua index 0fa0eb8af..3b8ec98bc 100644 --- a/nselib/snmp.lua +++ b/nselib/snmp.lua @@ -447,9 +447,14 @@ Helper = { local creds_store = creds.Credentials:new(creds.ALL_DATA, host, port) for _,cs in ipairs({creds.State.PARAM, creds.State.VALID}) do local account = creds_store:getCredentials(cs)() - if (account and account.pass) then - o.community = account.pass == "" and "" or account.pass - break + if account then + if account.pass and account.pass ~= "" and account.pass ~= "" then + o.community = account.pass + break + elseif account.user then + o.community = account.user + break + end end end end