1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-06 14:39:03 +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:
kris
2008-06-12 14:32:25 +00:00
parent cede9ab542
commit 2f9321360f
19 changed files with 297 additions and 268 deletions

View File

@@ -3,6 +3,7 @@ description="Determines if remote service is Skype protocol version 2"
author = "Brandon Enright <bmenrigh@ucsd.edu>"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"version"}
require "comm"
portrule = function(host, port)
if (port.number == 80 or
@@ -22,42 +23,25 @@ portrule = function(host, port)
end
action = function(host, port)
local socket = nmap.new_socket()
local result;
local status = true
socket:connect(host.ip, port.number, port.protocol)
socket:send("GET / HTTP/1.0\r\n\r\n")
status, result = socket:receive_bytes(26);
local status, result = comm.exchange(host, port, "GET / HTTP/1.0\r\n\r\n", {bytes=26, proto=port.protocol})
if (not status) then
socket:close()
return
end
if (result ~= "HTTP/1.0 404 Not Found\r\n\r\n") then
socket:close()
return
end
socket:close();
-- So far so good, now see if we get random data for another request
socket:connect(host.ip, port.number, port.protocol)
socket:send("random data\r\n\r\n")
status, result = socket:receive_bytes(15);
status, result = comm.exchange(host, port, "random data\r\n\r\n", {bytes=15, proto=port.protocol})
if (not status) then
socket:close()
return
end
if string.match(result, "[^%s!-~].*[^%s!-~].*[^%s!-~]") then
socket:close()
port.version.name = "skype2"
port.version.product = "Skype"
port.version.confidence = 10
@@ -67,7 +51,5 @@ action = function(host, port)
-- return "Skype v2 server detected"
end
socket:close();
return
end