1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 21:21:31 +00:00

nse_check_globals cleanup

This commit is contained in:
patrik
2012-07-24 10:08:43 +00:00
parent f4e06ca3d7
commit 217b27bace
18 changed files with 48 additions and 17 deletions

View File

@@ -7,7 +7,11 @@
-- @author "Patrik Karlsson <patrik@cqure.net>" -- @author "Patrik Karlsson <patrik@cqure.net>"
-- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html -- @copyright Same as Nmap--See http://nmap.org/book/man-legal.html
local bin = require "bin"
local bit = require "bit"
local math = require "math"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local table = require "table"
local ipOps = require "ipOps" local ipOps = require "ipOps"
local packet = require "packet" local packet = require "packet"
_ENV = stdnse.module("ospf", stdnse.seeall) _ENV = stdnse.module("ospf", stdnse.seeall)
@@ -61,6 +65,7 @@ OSPF = {
pos, header.auth_data.password = bin.unpack(">A8", data, pos) pos, header.auth_data.password = bin.unpack(">A8", data, pos)
-- MD5 hash authentication -- MD5 hash authentication
elseif header.auth_type == 0x02 then elseif header.auth_type == 0x02 then
local _
_, header.auth_data.keyid = bin.unpack(">C", data, pos+2) _, header.auth_data.keyid = bin.unpack(">C", data, pos+2)
_, header.auth_data.length = bin.unpack(">C", data, pos+3) _, header.auth_data.length = bin.unpack(">C", data, pos+3)
_, header.auth_data.seq = bin.unpack(">C", data, pos+4) _, header.auth_data.seq = bin.unpack(">C", data, pos+4)

View File

@@ -8,6 +8,7 @@
-- --
local bin = require("bin") local bin = require("bin")
local nmap = require("nmap")
local stdnse = require("stdnse") local stdnse = require("stdnse")
_ENV = stdnse.module("rdp", stdnse.seeall) _ENV = stdnse.module("rdp", stdnse.seeall)

View File

@@ -6,6 +6,7 @@ local nmap = require "nmap"
local shortport = require "shortport" local shortport = require "shortport"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local table = require "table" local table = require "table"
local unpwdb = require "unpwdb"
description = [[ description = [[
Attempts to guess the name of the CVS repositories hosted on the remote server. Attempts to guess the name of the CVS repositories hosted on the remote server.
@@ -104,7 +105,7 @@ action = function(host, port)
end end
end end
repository_iterator = function() local function repository_iterator()
local function next_repo() local function next_repo()
for line in f:lines() do for line in f:lines() do
if ( not(line:match("#!comment")) ) then if ( not(line:match("#!comment")) ) then

View File

@@ -431,7 +431,7 @@ local RD = {
end, end,
DNAME = parse_domain, DNAME = parse_domain,
SINK = function(data, offset) -- http://bgp.potaroo.net/ietf/all-ids/draft-eastlake-kitchen-sink-02.txt SINK = function(data, offset) -- http://bgp.potaroo.net/ietf/all-ids/draft-eastlake-kitchen-sink-02.txt
local coding, subcoding local coding, subcoding, field
coding = string.byte(data, offset) coding = string.byte(data, offset)
subcoding = string.byte(data, offset+1) subcoding = string.byte(data, offset+1)
offset, field = bin.unpack("A" .. (bto16(data, offset-2)-2), data, offset+2) offset, field = bin.unpack("A" .. (bto16(data, offset-2)-2), data, offset+2)

View File

@@ -96,6 +96,7 @@ ftp_helper = {
-- Until we get adequate packet -- Until we get adequate packet
while (nmap.clock_ms() - start) < timeout do while (nmap.clock_ms() - start) < timeout do
local _
status, _, l2data, l3data = sniffer:pcap_receive() status, _, l2data, l3data = sniffer:pcap_receive()
if status and string.find(l3data, "220 ") then if status and string.find(l3data, "220 ") then
break break
@@ -261,7 +262,7 @@ action = function(host, port)
end end
-- Then we check if target port is now open. -- Then we check if target port is now open.
testsock = nmap.new_socket() local testsock = nmap.new_socket()
testsock:set_timeout(1000) testsock:set_timeout(1000)
local status, _ = testsock:connect(host.ip, targetport) local status, _ = testsock:connect(host.ip, targetport)
testsock:close() testsock:close()

View File

@@ -20,6 +20,8 @@
local http = require("http") local http = require("http")
local shortport = require("shortport") local shortport = require("shortport")
local stdnse = require("stdnse") local stdnse = require("stdnse")
local string = require("string")
local table = require("table")
description = [[ description = [[
Checks for a Git repository found in a website's document root (GET /.git/<something> HTTP/1.1) Checks for a Git repository found in a website's document root (GET /.git/<something> HTTP/1.1)
@@ -155,7 +157,7 @@ function action(host, port)
-- This function will take a Git hosting service URL or a service -- This function will take a Git hosting service URL or a service
-- the allows deployment via Git and find out if there is an entry -- the allows deployment via Git and find out if there is an entry
-- for it in the configuration file -- for it in the configuration file
function lookforremote(config, url, service, success_string) local function lookforremote(config, url, service, success_string)
-- Different combinations of separating characters in the remote can -- Different combinations of separating characters in the remote can
-- indicate the access method - I know about SSH, HTTP, and Smart HTTP -- indicate the access method - I know about SSH, HTTP, and Smart HTTP
local access1, access2, reponame = string.match( local access1, access2, reponame = string.match(

View File

@@ -49,6 +49,8 @@ local shortport = require 'shortport'
local url = require 'url' local url = require 'url'
local stdnse = require 'stdnse' local stdnse = require 'stdnse'
local vulns = require 'vulns' local vulns = require 'vulns'
local string = require 'string'
local table = require 'table'
portrule = shortport.http portrule = shortport.http

View File

@@ -1,3 +1,7 @@
local coroutine = require "coroutine"
local math = require "math"
local nmap = require "nmap"
local os = require "os"
local shortport = require "shortport" local shortport = require "shortport"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local http = require "http" local http = require "http"
@@ -165,7 +169,7 @@ local doMonitor = function(host,port)
break break
end end
end end
status, data = monitor:receive_lines(1) local status, data = monitor:receive_lines(1)
if not status then if not status then
stdnse.print_debug("MONITOR: Didn't get a reply from " .. host.ip .. "." ) stdnse.print_debug("MONITOR: Didn't get a reply from " .. host.ip .. "." )
monitor:close() monitor:close()
@@ -214,7 +218,6 @@ local worker_schedluer = function(host, port)
for thread in pairs(threads) do for thread in pairs(threads) do
if coroutine.status(thread) == "dead" then if coroutine.status(thread) == "dead" then
threads[thread] = nil threads[thread] = nil
end end
end end
stdnse.print_debug("starting new thread") stdnse.print_debug("starting new thread")

View File

@@ -26,6 +26,8 @@ categories = {"version", "safe"}
local http = require "http" local http = require "http"
local nmap = require "nmap" local nmap = require "nmap"
local stdnse = require "stdnse"
local string = require "string"
portrule = function(host, port) portrule = function(host, port)
if port.version ~= nil and port.version.product ~= nil then if port.version ~= nil and port.version.product ~= nil then

View File

@@ -1,3 +1,4 @@
local nmap = require "nmap"
local shortport = require "shortport" local shortport = require "shortport"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local string = require "string" local string = require "string"
@@ -223,7 +224,7 @@ end
-- write command and read result helper -- write command and read result helper
local write_read_console = function(host,port,token, console_id,command) local write_read_console = function(host,port,token, console_id,command)
if write_console(host,port,token,console_id, command) then if write_console(host,port,token,console_id, command) then
read_data = read_console(host,port,token,console_id) local read_data = read_console(host,port,token,console_id)
if read_data then if read_data then
read_data = string.sub(read_data,string.find(read_data,"\n")+1) -- skip command echo read_data = string.sub(read_data,string.find(read_data,"\n")+1) -- skip command echo
return read_data return read_data

View File

@@ -1,3 +1,4 @@
local coroutine = require "coroutine"
local mssql = require "mssql" local mssql = require "mssql"
local nmap = require "nmap" local nmap = require "nmap"
local stdnse = require "stdnse" local stdnse = require "stdnse"

View File

@@ -36,13 +36,13 @@ portrule = shortport.port_or_service(111, {"rpcbind", "mountd"}, {"tcp", "udp"}
local function get_exports(host, port) local function get_exports(host, port)
local mnt = rpc.Mount:new() local mnt = rpc.Mount:new()
mnt_comm = rpc.Comm:new('mountd', port.version.rpc_highver) local mnt_comm = rpc.Comm:new('mountd', port.version.rpc_highver)
status, result = mnt_comm:Connect(host, port) local status, result = mnt_comm:Connect(host, port)
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "get_exports: %s", result) stdnse.print_debug(4, "get_exports: %s", result)
return false, result return false, result
end end
status, mounts = mnt:Export(mnt_comm) local status, mounts = mnt:Export(mnt_comm)
mnt_comm:Disconnect() mnt_comm:Disconnect()
if ( not(status) ) then if ( not(status) ) then
stdnse.print_debug(4, "get_exports: %s", mounts) stdnse.print_debug(4, "get_exports: %s", mounts)

View File

@@ -29,6 +29,9 @@ author = "Patrik Karlsson"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
local bin = require("bin")
local nmap = require("nmap")
local table = require("table")
local shortport = require("shortport") local shortport = require("shortport")
local rdp = require("rdp") local rdp = require("rdp")
local stdnse = require("stdnse") local stdnse = require("stdnse")
@@ -60,7 +63,7 @@ local function enum_protocols(host, port)
return false, "ERROR: Failed to connect to server" return false, "ERROR: Failed to connect to server"
end end
local cr = rdp.Request.ConnectionRequest:new(v) local cr = rdp.Request.ConnectionRequest:new(v)
status, response = comm:exch(cr) local status, response = comm:exch(cr)
comm:close() comm:close()
if ( not(status) ) then if ( not(status) ) then
return false, response return false, response
@@ -102,7 +105,7 @@ local function enum_ciphers(host, port)
local res_ciphers = {} local res_ciphers = {}
local function get_ordered_ciphers() local function get_ordered_ciphers()
i = 0 local i = 0
return function() return function()
i = i + 1 i = i + 1
if ( not(CIPHERS[i]) ) then return end if ( not(CIPHERS[i]) ) then return end
@@ -119,7 +122,7 @@ local function enum_ciphers(host, port)
end end
local cr = rdp.Request.ConnectionRequest:new() local cr = rdp.Request.ConnectionRequest:new()
status, response = comm:exch(cr) local status, response = comm:exch(cr)
if ( not(status) ) then if ( not(status) ) then
break break
end end

View File

@@ -1,3 +1,4 @@
local nmap = require "nmap"
local shortport = require "shortport" local shortport = require "shortport"
local sip = require "sip" local sip = require "sip"
local stdnse = require "stdnse" local stdnse = require "stdnse"

View File

@@ -1,3 +1,6 @@
local io = require "io"
local nmap = require "nmap"
local string = require "string"
local shortport = require "shortport" local shortport = require "shortport"
local sip = require "sip" local sip = require "sip"
local stdnse = require "stdnse" local stdnse = require "stdnse"
@@ -121,7 +124,7 @@ local useriterator = function(list)
end end
f = io.open(f) f = io.open(f)
if ( not(f) ) then if ( not(f) ) then
return false, ("\n ERROR: Failed to open %s"):format(DEFAULT_ACCOUNTS) return false, ("\n ERROR: Failed to open %s"):format(list)
end end
return function() return function()
for line in f:lines() do for line in f:lines() do
@@ -171,7 +174,7 @@ Driver = {
self.session = sip.Session:new(self.host, self.port) self.session = sip.Session:new(self.host, self.port)
local status = self.session:connect() local status = self.session:connect()
if ( not(status) ) then if ( not(status) ) then
return false, brute.Error:new( "Couldn't connect to host: " .. err ) return false, brute.Error:new( "Couldn't connect to host" )
end end
return true return true
end, end,
@@ -247,7 +250,7 @@ action = function(host, port)
local iterator = numiterator(minext, maxext, padding) local iterator = numiterator(minext, maxext, padding)
if users then if users then
usernames, err = useriterator(usersfile) local usernames, err = useriterator(usersfile)
if not usernames then if not usernames then
return err return err
end end

View File

@@ -1,3 +1,4 @@
local nmap = require "nmap"
local shortport = require "shortport" local shortport = require "shortport"
local sip = require "sip" local sip = require "sip"
local stdnse = require "stdnse" local stdnse = require "stdnse"

View File

@@ -917,6 +917,7 @@ local function try_protocol(host, port, protocol, upresults)
compressors = find_compressors(host, port, protocol, ciphers[1]) compressors = find_compressors(host, port, protocol, ciphers[1])
-- Add rankings to ciphers -- Add rankings to ciphers
local cipherstr
for i, name in ipairs(ciphers) do for i, name in ipairs(ciphers) do
if rankedciphersfilename and rankedciphers[name] then if rankedciphersfilename and rankedciphers[name] then
cipherstr=rankedciphers[name] cipherstr=rankedciphers[name]

View File

@@ -1,3 +1,5 @@
local nmap = require "nmap"
local string = require "string"
local shortport = require "shortport" local shortport = require "shortport"
local stdnse = require "stdnse" local stdnse = require "stdnse"
local table = require "table" local table = require "table"
@@ -131,7 +133,8 @@ local check_npn = function(response)
end end
-- Get the server hello length -- Get the server hello length
_, shlength = bin.unpack(">S", response, 4) local _
_, shlength = bin.unpack(">S", response, 4)
local serverhello = string.sub(response, 6, 6 + shlength) local serverhello = string.sub(response, 6, 6 + shlength)
-- If server didn't return TLS NPN extension -- If server didn't return TLS NPN extension