1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-16 04:39:03 +00:00

Fix snmp.lua after conversion to tohex instead of pack('H') changed hex to lowercase

This commit is contained in:
dmiller
2017-03-29 14:14:39 +00:00
parent 19acf2feaf
commit 0073334d30

View File

@@ -85,11 +85,11 @@ local tagDecoder = {}
-- Response-PDU -- Response-PDU
-- TOOD: Figure out how to remove these dependencies -- TOOD: Figure out how to remove these dependencies
tagDecoder["A2"] = function( self, encStr, elen, pos ) tagDecoder["a2"] = function( self, encStr, elen, pos )
local seq = {} local seq = {}
pos, seq = self:decodeSeq(encStr, elen, pos) pos, seq = self:decodeSeq(encStr, elen, pos)
seq._snmp = "A2" seq._snmp = "a2"
return pos, seq return pos, seq
end end
@@ -123,14 +123,14 @@ function decode(encStr, pos)
tagDecoder["47"] = decoder.decoder["02"] -- UInteger32 tagDecoder["47"] = decoder.decoder["02"] -- UInteger32
-- Context specific tags -- Context specific tags
tagDecoder["A0"] = decoder.decoder["30"] -- GetRequest-PDU tagDecoder["a0"] = decoder.decoder["30"] -- GetRequest-PDU
tagDecoder["A1"] = decoder.decoder["30"] -- GetNextRequest-PDU tagDecoder["a1"] = decoder.decoder["30"] -- GetNextRequest-PDU
--tagDecoder["A2"] = decoder.decoder["30"] -- Response-PDU --tagDecoder["a2"] = decoder.decoder["30"] -- Response-PDU
tagDecoder["A3"] = decoder.decoder["30"] -- SetRequest-PDU tagDecoder["a3"] = decoder.decoder["30"] -- SetRequest-PDU
tagDecoder["A4"] = decoder.decoder["30"] -- Trap-PDU tagDecoder["a4"] = decoder.decoder["30"] -- Trap-PDU
tagDecoder["A5"] = decoder.decoder["30"] -- GetBulkRequest-PDU tagDecoder["a5"] = decoder.decoder["30"] -- GetBulkRequest-PDU
tagDecoder["A6"] = decoder.decoder["30"] -- InformRequest-PDU (not implemented here yet) tagDecoder["a6"] = decoder.decoder["30"] -- InformRequest-PDU (not implemented here yet)
tagDecoder["A7"] = decoder.decoder["30"] -- SNMPv2-Trap-PDU (not implemented here yet) tagDecoder["a7"] = decoder.decoder["30"] -- SNMPv2-Trap-PDU (not implemented here yet)
end end
@@ -174,7 +174,7 @@ function buildGetRequest(options, ...)
if not options.errIdx then options.errIdx = 0 end if not options.errIdx then options.errIdx = 0 end
local req = {} local req = {}
req._snmp = 'A0' req._snmp = 'a0'
req[1] = options.reqId req[1] = options.reqId
req[2] = options.err req[2] = options.err
req[3] = options.errIdx req[3] = options.errIdx
@@ -206,7 +206,7 @@ function buildGetNextRequest(options, ...)
options.errIdx = options.errIdx or 0 options.errIdx = options.errIdx or 0
local req = {} local req = {}
req._snmp = 'A1' req._snmp = 'a1'
req[1] = options.reqId req[1] = options.reqId
req[2] = options.err req[2] = options.err
req[3] = options.errIdx req[3] = options.errIdx
@@ -242,7 +242,7 @@ function buildSetRequest(options, oid, value)
if not options.errIdx then options.errIdx = 0 end if not options.errIdx then options.errIdx = 0 end
local req = {} local req = {}
req._snmp = 'A3' req._snmp = 'a3'
req[1] = options.reqId req[1] = options.reqId
req[2] = options.err req[2] = options.err
req[3] = options.errIdx req[3] = options.errIdx
@@ -268,7 +268,7 @@ end
-- @return Table representing PDU -- @return Table representing PDU
function buildTrap(enterpriseOid, agentIp, genTrap, specTrap, timeStamp) function buildTrap(enterpriseOid, agentIp, genTrap, specTrap, timeStamp)
local req = {} local req = {}
req._snmp = 'A4' req._snmp = 'a4'
if (type(enterpriseOid) == "string") then if (type(enterpriseOid) == "string") then
req[1] = str2oid(enterpriseOid) req[1] = str2oid(enterpriseOid)
else else
@@ -309,7 +309,7 @@ function buildGetResponse(options, oid, value)
if not options.errIdx then options.errIdx = 0 end if not options.errIdx then options.errIdx = 0 end
local resp = {} local resp = {}
resp._snmp = 'A2' resp._snmp = 'a2'
resp[1] = options.reqId resp[1] = options.reqId
resp[2] = options.err resp[2] = options.err
resp[3] = options.errIdx resp[3] = options.errIdx
@@ -393,9 +393,9 @@ function fetchResponseValues(resp)
end end
local varBind local varBind
if (resp._snmp and resp._snmp == 'A2') then if (resp._snmp and resp._snmp == 'a2') then
varBind = resp[4] varBind = resp[4]
elseif (resp[3] and resp[3]._snmp and resp[3]._snmp == 'A2') then elseif (resp[3] and resp[3]._snmp and resp[3]._snmp == 'a2') then
varBind = resp[3][4] varBind = resp[3][4]
end end