mirror of
https://github.com/nmap/nmap.git
synced 2025-12-10 09:49:05 +00:00
o Added a new NSE Comm library for common network discovery tasks such
as banner-grabbing (get_banner()) and making a quick exchange of data (exchange()). 16 scripts were updated to use this library. [Kris] I have *not* been able to test all of these scripts; however, I have reviewed them and they should all work properly. I would really like some more testing, though :) This commit includes scripting.xml documentation.
This commit is contained in:
@@ -18,6 +18,7 @@ license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
|
||||
categories = { "default", "discovery", "safe" }
|
||||
|
||||
require 'bit'
|
||||
require 'comm'
|
||||
|
||||
-- Grabs NUL-terminated string
|
||||
local getstring = function(orig)
|
||||
@@ -105,28 +106,14 @@ portrule = function(host, port)
|
||||
end
|
||||
|
||||
action = function(host, port)
|
||||
local sock
|
||||
local response = ""
|
||||
local output = ""
|
||||
|
||||
sock = nmap.new_socket()
|
||||
local status, response = comm.get_banner(host, port, {timeout=5000})
|
||||
|
||||
sock:set_timeout(5000)
|
||||
|
||||
sock:connect(host.ip, port.number)
|
||||
|
||||
while true do
|
||||
local status, line = sock:receive_lines(1)
|
||||
|
||||
if not status then
|
||||
break
|
||||
end
|
||||
|
||||
response = response .. line
|
||||
if not status then
|
||||
return
|
||||
end
|
||||
|
||||
sock:close()
|
||||
|
||||
local length = ntoh3(response:sub(1, 3))
|
||||
|
||||
if length ~= response:len() - 4 then
|
||||
|
||||
Reference in New Issue
Block a user