1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-06 12:41:29 +00:00

nse_check_globals cleanup

This commit is contained in:
patrik
2013-01-28 04:28:38 +00:00
parent 37ab88e840
commit d79e431e7a
2 changed files with 11 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
local _G = require "_G" local _G = require "_G"
local bin = require "bin"
local nmap = require "nmap" local nmap = require "nmap"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local string = require "string"
local table = require "table" local table = require "table"
local math = require "math" local math = require "math"
local io = require "io" local io = require "io"
@@ -91,7 +93,7 @@ local function load_fingerprints()
-- Check there are fingerprints to use -- Check there are fingerprints to use
if(#fingerprints == 0 ) then if(#fingerprints == 0 ) then
return false, "No fingerprints were loaded after processing ".. filename return false, "No fingerprints were loaded after processing ".. filename_full
end end
return true, fingerprints return true, fingerprints
@@ -135,7 +137,7 @@ local function extract_payloads(packet)
-- loop over packet -- loop over packet
while payloads[np] ~= "None" and index <= packet:len() do while payloads[np] ~= "None" and index <= packet:len() do
payload_length = tonumber("0x"..packet:sub(index, index+3)) * 2 local payload_length = tonumber("0x"..packet:sub(index, index+3)) * 2
payload = string.lower(packet:sub(index+4, index+payload_length-5)) payload = string.lower(packet:sub(index+4, index+payload_length-5))
-- debug -- debug
@@ -325,7 +327,7 @@ end
function send_request( host, port, packet ) function send_request( host, port, packet )
local socket = nmap.new_socket() local socket = nmap.new_socket()
local s_status, r_status, data, i, hexstring local s_status, r_status, data, i, hexstring, _
-- send the request packet -- send the request packet
socket:set_timeout(1000) socket:set_timeout(1000)
@@ -395,7 +397,7 @@ end
-- Currently only DES, 3DES and AES encryption is supported -- Currently only DES, 3DES and AES encryption is supported
-- --
local function generate_transform(auth, encryption, hash, group, number, total) local function generate_transform(auth, encryption, hash, group, number, total)
local key_length, trans_length, aes_enc, sep local key_length, trans_length, aes_enc, sep, enc
local next_payload, payload_number local next_payload, payload_number
-- handle special case of aes -- handle special case of aes
@@ -403,7 +405,7 @@ local function generate_transform(auth, encryption, hash, group, number, total)
trans_length = "0028" trans_length = "0028"
aes_enc = enc_methods[encryption] aes_enc = enc_methods[encryption]
sep = aes_enc:find("/") sep = aes_enc:find("/")
enc = aes_enc:sub(1,sep-1) enc = aes_enc:sub(1,sep-1)
key_length = aes_enc:sub(sep+1, aes_enc:len()) key_length = aes_enc:sub(sep+1, aes_enc:len())
else else
trans_length = "0024" trans_length = "0024"

View File

@@ -1,7 +1,9 @@
local bit = require "bit" local bit = require "bit"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local math = require "math"
local nmap = require "nmap" local nmap = require "nmap"
local strbuf = require "strbuf" local strbuf = require "strbuf"
local string = require "string"
local table = require "table" local table = require "table"
local shortport = require "shortport" local shortport = require "shortport"
@@ -310,11 +312,11 @@ local dec_data = function(str, len, key)
-- skip the header (first 20 bytes) -- skip the header (first 20 bytes)
local data = { string.byte(str, 21, 20 + len) } local data = { string.byte(str, 21, 20 + len) }
a1 = bit.band(key, 0xFF) local a1 = bit.band(key, 0xFF)
if a1 == 0 then if a1 == 0 then
return table.concat(data) return table.concat(data)
end end
a2 = bit.rshift(key, 8) local a2 = bit.rshift(key, 8)
for i = 1,len do for i = 1,len do
data[i] = bit.band(data[i] - (crypt_data[a2 + 1] + ((i - 1) % 72)), 0xFF) data[i] = bit.band(data[i] - (crypt_data[a2 + 1] + ((i - 1) % 72)), 0xFF)