1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 20:29:03 +00:00

Switch to string packing instead of bin packing and return order for asn1-related libs

This commit is contained in:
dmiller
2017-03-29 20:42:01 +00:00
parent 3dec043ead
commit 4cef14a873
8 changed files with 120 additions and 134 deletions

View File

@@ -5,6 +5,7 @@ local nmap = require "nmap"
local os = require "os"
local shortport = require "shortport"
local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local unpwdb = require "unpwdb"
@@ -100,15 +101,13 @@ KRB5 = {
tagDecoder = {
["\x18"] = function( self, encStr, elen, pos )
return bin.unpack("A" .. elen, encStr, pos)
return string.unpack("c" .. elen, encStr, pos)
end,
["\x1B"] = function( ... ) return KRB5.tagDecoder["\x18"](...) end,
["\x6B"] = function( self, encStr, elen, pos )
local seq
pos, seq = self:decodeSeq(encStr, elen, pos)
return pos, seq
return self:decodeSeq(encStr, elen, pos)
end,
-- Not really sure what these are, but they all decode sequences
@@ -262,7 +261,7 @@ KRB5 = {
local decoder = asn1.ASN1Decoder:new()
decoder:registerTagDecoders(KRB5.tagDecoder)
decoder:setStopOnError(true)
local pos, result = decoder:decode(data)
local result = decoder:decode(data)
local msg = {}

View File

@@ -113,7 +113,7 @@ function action(host,port)
if ( not(status) ) then return data end
socket:close()
local _, response = ldap.decode(data)
local response = ldap.decode(data)
-- make sure the result code was a success
local rescode = ( #response >= 2 ) and response[2]

View File

@@ -194,8 +194,7 @@ local sniff_snmp_responses = function(host, port, lport, result)
end
local response = p:raw(p.udp_offset + 8, #p.buf)
local res
_, res = snmp.decode(response)
local res = snmp.decode(response)
if type(res) == "table" then
communities:add(nil, res[2], creds.State.VALID)

View File

@@ -74,7 +74,7 @@ action = function (host, port)
end
end
local pos, decoded = snmp.decode(response)
local decoded = snmp.decode(response)
-- Check for SNMP version 3 and msgid 0x4a69 (from the probe)
if ((not decoded) or
@@ -93,7 +93,7 @@ action = function (host, port)
end
-- Decode the msgSecurityParameters octet-string
pos, decoded = snmp.decode(decoded[3])
decoded = snmp.decode(decoded[3])
local output = stdnse.output_table()
-- Decode the msgAuthoritativeEngineID octet-string