1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-26 09:29:01 +00:00

Fixing locals/globals on following scripts

- telnet-brute.nse required a small refactoring to fix the use of a global variable called soc
This commit is contained in:
joao
2009-07-16 22:54:38 +00:00
parent 4d9094fb21
commit a14ab3c637
4 changed files with 24 additions and 22 deletions

View File

@@ -29,11 +29,13 @@ require "stdnse"
--@param tab The table to truncate.
--@return Truncated, formatted table.
local truncate = function(tab)
return tab[1] .. "\n" ..
tab[2] .. "\n" ..
tab[3] .. "\n" ..
tab[4] .. "\n" ..
tab[5] .. "\n";
local str = ""
str = str .. tab[1] .. "\n"
str = str .. tab[2] .. "\n"
str = str .. tab[3] .. "\n"
str = str .. tab[4] .. "\n"
str = str .. tab[5] .. "\n"
return str
end
--- Validates the HTTP response and checks for modifications.
@@ -83,17 +85,15 @@ local validate = function(response, original)
return
end
portrule = shortport.port_or_service({80, 8080}, "http")
portrule = shortport.port_or_service({80, 8080, 443}, {"http", "https"})
action = function(host, port)
local cmd = "TRACE / HTTP/1.0\r\n\r\n"
local status, response = comm.exchange(host, port, cmd, {lines=1,timeout=5000})
if not status then
local sd, response = comm.tryssl(host, port, cmd, false)
if not sd then
stdnse.print_debug("Unable to open connection")
return
end
return validate(response, cmd)
end