1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-08 21:51:28 +00:00
Files
nmap/scripts/ripeQuery.nse
kris 2f9321360f 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.
2008-06-12 14:32:25 +00:00

34 lines
724 B
Lua

require "comm"
require "ipOps"
id = "RIPE query"
description = "Connects to the RIPE database, extracts and prints the role: entry for the IP."
author = "Diman Todorov <diman.todorov@gmail.com>"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery"}
hostrule = function(host, port)
return not ipOps.isPrivate(host.ip)
end
action = function(host, port)
local status, result = comm.exchange("whois.ripe.net", 43, host.ip .. "\n")
if not status then
return
end
local value = string.match(result, "role:(.-)\n")
if (value == "see http://www.iana.org.") then
value = nil
end
if (value == nil) then
return
end
return "IP belongs to: " .. value:gsub("^%s*", "")
end