From 5d5a0dde21290c787a4ce728c44b62969dc294a5 Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 12 Jul 2008 07:41:43 +0000 Subject: [PATCH] add a warning that NSE is under active dev, and remove nse-example-script-owner section since already profiled showOwner.nse in the script tutorial section --- docs/scripting.xml | 101 +++------------------------------------------ 1 file changed, 5 insertions(+), 96 deletions(-) diff --git a/docs/scripting.xml b/docs/scripting.xml index 7ba1bec7d..b3e9106af 100644 --- a/docs/scripting.xml +++ b/docs/scripting.xml @@ -98,6 +98,11 @@ uses for NSE. + The Nmap Scripting Engine is a new Nmap feature + which already works well, but is under active development. To + provide the latest NSE news and updates, this chapter has been + updated and posted for free online at + . Scripts are written in the @@ -3626,102 +3631,6 @@ scripts return one result). end - - - Service Owner Lookup via Identd - Service owner script - auth service - showOwner.nse demonstrates the flexibility - of NSE, which is unmatched by other parts of Nmap. If the target - is running an identd daemon it connects to it for - each running service and tries to identify its owner. - - -id = "Service owner"id script variable - -description = "Opens a connection to the scanned port, opens a connection to \ -port 113, queries the owner of the service on the scanned port and prints it."description script variable - -author = "Diman Todorov <diman.todorov@gmail.com>"Todorov, Dimanauthor script variable - -license = "Same as Nmap--See http://nmap.org/book/man-legal.html"license script variable - -categories = {"default", "safe"}categories script variabledefault script categorysafe script category - - - -Portrules are not restricted to those provided by the -short-port module (). -They can be any function taking a host- and a port table as argument and -returning a boolean. - - - -portrule = function(host, port) portrule script variable - local auth_port = { number=113, protocol="tcp" } - - -In order to determine the state of a port, which is not provided -as argument we just have to construct a table describing the port -(i.e. its number and the protocol it's using) and pass it to -nmap.get_port_state() which returns a table filled -with the information Nmap has about the port. - - - local identd = nmap.get_port_state(host, auth_port) - - if identd ~= nil - and identd.state == "open" - and port.protocol == "tcp" - and port.state == "open" - then - return true - else - return false - end -end - -action = function(host, port) - local owner = "" - - -Scripts may open any number of connections. - - - local client_ident = nmap.new_socket() - local client_service = nmap.new_socket() - - local catch = function() - client_ident:close() - client_service:close() - end - - local try = nmap.new_try(catch) - - try(client_ident:connect(host.ip, 113)) - try(client_service:connect(host.ip, port.number)) - - local localip,localport,remoteip,remoteport = try(client_service:get_info()) - - local request = port.number .. ", " .. localport .. "\n" - - try(client_ident:send(request)) - - owner = try(client_ident:receive_lines(1)) - - if string.match(owner, "ERROR") then - owner = nil - else - owner = string.match(owner, "USERID : .+ : (.+)\n", 1) - end - - try(client_ident:close()) - try(client_service:close()) - - return owner -end - -