1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-22 15:39:03 +00:00

Change CRLF line endings to LF in ip-geolocation-*.nse.

This commit is contained in:
david
2011-11-02 16:50:38 +00:00
parent aceb760703
commit d3c6976fca
4 changed files with 827 additions and 827 deletions

View File

@@ -1,76 +1,76 @@
description = [[ description = [[
Tries to identify the physical location of an IP address using the Tries to identify the physical location of an IP address using the
Geobytes geolocation web service Geobytes geolocation web service
(http://www.geobytes.com/iplocator.htm). The limit of lookups using (http://www.geobytes.com/iplocator.htm). The limit of lookups using
this service is 20 requests per hour. Once the limit is reached, an this service is 20 requests per hour. Once the limit is reached, an
nmap.registry["ip-geolocation-geobytes"].blocked boolean is set so no nmap.registry["ip-geolocation-geobytes"].blocked boolean is set so no
further requests are made during a scan. further requests are made during a scan.
]] ]]
--- ---
-- @usage -- @usage
-- nmap --script ip-geolocation-geobytes <target> -- nmap --script ip-geolocation-geobytes <target>
-- --
-- @output -- @output
-- | ip-geolocation-geobytes: -- | ip-geolocation-geobytes:
-- | 74.207.244.221 (scanme.nmap.org) -- | 74.207.244.221 (scanme.nmap.org)
-- | coordinates (lat,lon): 43.667,-79.417 -- | coordinates (lat,lon): 43.667,-79.417
-- |_ city: Toronto, Ontario, Canada -- |_ city: Toronto, Ontario, Canada
-- --
author = "Gorjan Petrovski" author = "Gorjan Petrovski"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery","external","safe"} categories = {"discovery","external","safe"}
require "nmap" require "nmap"
require "stdnse" require "stdnse"
require "ipOps" require "ipOps"
require "json" require "json"
require "http" require "http"
hostrule = function(host) hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip ) local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err ) stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
return false return false
end end
return not is_private return not is_private
end end
-- Limit is 20 request per hour per requesting host, when reached all table -- Limit is 20 request per hour per requesting host, when reached all table
-- values are filled with a "Limit Exceeded" value. A record in the registry is -- values are filled with a "Limit Exceeded" value. A record in the registry is
-- made so no more requests are made to the server during one scan -- made so no more requests are made to the server during one scan
local geobytes = function(ip) local geobytes = function(ip)
if nmap.registry["ip-geolocation-geobytes"] and nmap.registry["ip-geolocation-geobytes"].blocked then if nmap.registry["ip-geolocation-geobytes"] and nmap.registry["ip-geolocation-geobytes"].blocked then
return nil return nil
end end
local response = http.get("www.geobytes.com", 80, "/IpLocator.htm?GetLocation&template=json.txt&IpAddress="..ip, nil) local response = http.get("www.geobytes.com", 80, "/IpLocator.htm?GetLocation&template=json.txt&IpAddress="..ip, nil)
local stat, out = json.parse(response.body) local stat, out = json.parse(response.body)
local loc = out.geobytes local loc = out.geobytes
local output={} local output={}
if stat then if stat then
if loc.city and loc.city == "Limit Exceeded" then if loc.city and loc.city == "Limit Exceeded" then
if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end if not nmap.registry["ip-geolocation-geobytes"] then nmap.registry["ip-geolocation-geobytes"]={} end
nmap.registry["ip-geolocation-geobytes"].blocked = true nmap.registry["ip-geolocation-geobytes"].blocked = true
return nil return nil
end end
-- Process output -- Process output
table.insert(output, "coordinates (lat,lon): " .. loc.latitude .. "," .. loc.longitude) table.insert(output, "coordinates (lat,lon): " .. loc.latitude .. "," .. loc.longitude)
table.insert(output,"city: ".. loc.city..", ".. loc.region..", ".. loc.country) table.insert(output,"city: ".. loc.city..", ".. loc.region..", ".. loc.country)
return output return output
end end
return nil return nil
end end
action = function(host,port) action = function(host,port)
local output = geobytes(host.ip) local output = geobytes(host.ip)
if(#output~=0) then if(#output~=0) then
output.name = host.ip output.name = host.ip
if host.targetname then if host.targetname then
output.name = output.name.." ("..host.targetname..")" output.name = output.name.." ("..host.targetname..")"
end end
end end
return stdnse.format_output(true,output) return stdnse.format_output(true,output)
end end

View File

@@ -1,60 +1,60 @@
description = [[ description = [[
Tries to identify the physical location of an IP address using the Tries to identify the physical location of an IP address using the
Geoplugin geolocation web service (http://www.geoplugin.com/). There Geoplugin geolocation web service (http://www.geoplugin.com/). There
is no limit on lookups using this service. is no limit on lookups using this service.
]] ]]
--- ---
-- @usage -- @usage
-- nmap --script ip-geolocation-geoplugin <target> -- nmap --script ip-geolocation-geoplugin <target>
-- --
-- @output -- @output
-- | ip-geolocation-geoplugin: -- | ip-geolocation-geoplugin:
-- | 74.207.244.221 (scanme.nmap.org) -- | 74.207.244.221 (scanme.nmap.org)
-- | coordinates (lat,lon): 39.4208984375,-74.497703552246 -- | coordinates (lat,lon): 39.4208984375,-74.497703552246
-- |_ state: New Jersey, United States -- |_ state: New Jersey, United States
-- --
author = "Gorjan Petrovski" author = "Gorjan Petrovski"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery","external","safe"} categories = {"discovery","external","safe"}
require "stdnse" require "stdnse"
require "ipOps" require "ipOps"
require "json" require "json"
require "http" require "http"
hostrule = function(host) hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip ) local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then if is_private == nil then
stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err ) stdnse.print_debug( "%s Error in Hostrule: %s.", SCRIPT_NAME, err )
return false return false
end end
return not is_private return not is_private
end end
-- No limit on requests -- No limit on requests
local geoplugin = function(ip) local geoplugin = function(ip)
local response = http.get("www.geoplugin.net", 80, "/json.gp?ip="..ip, nil) local response = http.get("www.geoplugin.net", 80, "/json.gp?ip="..ip, nil)
local stat, loc = json.parse(response.body:match("geoPlugin%((.+)%)")) local stat, loc = json.parse(response.body:match("geoPlugin%((.+)%)"))
if not stat then return nil end if not stat then return nil end
local output = {} local output = {}
table.insert(output, "coordinates (lat,lon): "..loc.geoplugin_latitude..","..loc.geoplugin_longitude) table.insert(output, "coordinates (lat,lon): "..loc.geoplugin_latitude..","..loc.geoplugin_longitude)
table.insert(output,"state: ".. loc.geoplugin_regionName..", ".. loc.geoplugin_countryName) table.insert(output,"state: ".. loc.geoplugin_regionName..", ".. loc.geoplugin_countryName)
return output return output
end end
action = function(host,port) action = function(host,port)
local output = geoplugin(host.ip) local output = geoplugin(host.ip)
if(#output~=0) then if(#output~=0) then
output.name = host.ip output.name = host.ip
if host.targetname then if host.targetname then
output.name = output.name.." ("..host.targetname..")" output.name = output.name.." ("..host.targetname..")"
end end
end end
return stdnse.format_output(true,output) return stdnse.format_output(true,output)
end end

View File

@@ -1,85 +1,85 @@
description = [[ description = [[
Tries to identify the physical location of an IP address using the Tries to identify the physical location of an IP address using the
IPInfoDB geolocation web service IPInfoDB geolocation web service
(http://ipinfodb.com/ip_location_api.php). (http://ipinfodb.com/ip_location_api.php).
There is no limit on requests to this service. However, the API key There is no limit on requests to this service. However, the API key
needs to be obtained through free registration for this service: needs to be obtained through free registration for this service:
<code>http://ipinfodb.com/login.php</code> <code>http://ipinfodb.com/login.php</code>
]] ]]
--- ---
-- @usage -- @usage
-- nmap --script ip-geolocation-ipinfodb <target> --script-args ip-geolocation-ipinfodb.apikey=<API_key> -- nmap --script ip-geolocation-ipinfodb <target> --script-args ip-geolocation-ipinfodb.apikey=<API_key>
-- --
-- @args ip-geolocation-ipinfodb.apikey A sting specifying the api-key which -- @args ip-geolocation-ipinfodb.apikey A sting specifying the api-key which
-- the user wants to use to access this service -- the user wants to use to access this service
-- --
-- @output -- @output
-- | ip-geolocation-ipinfodb: -- | ip-geolocation-ipinfodb:
-- | 74.207.244.221 (scanme.nmap.org) -- | 74.207.244.221 (scanme.nmap.org)
-- | coordinates (lat,lon): 37.5384,-121.99 -- | coordinates (lat,lon): 37.5384,-121.99
-- |_ city: FREMONT, CALIFORNIA, UNITED STATES -- |_ city: FREMONT, CALIFORNIA, UNITED STATES
-- --
author = "Gorjan Petrovski" author = "Gorjan Petrovski"
license = "Same as Nmap--See http://nmap.org/book/man-legal.html" license = "Same as Nmap--See http://nmap.org/book/man-legal.html"
categories = {"discovery","external","safe"} categories = {"discovery","external","safe"}
require "stdnse" require "stdnse"
require "ipOps" require "ipOps"
require "json" require "json"
require "http" require "http"
hostrule = function(host) hostrule = function(host)
local is_private, err = ipOps.isPrivate( host.ip ) local is_private, err = ipOps.isPrivate( host.ip )
if is_private == nil then if is_private == nil then
stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err ) stdnse.print_debug( "%s not running: Error in Hostrule: %s.", SCRIPT_NAME, err )
return false return false
elseif is_private then elseif is_private then
stdnse.print_debug("%s not running: Private IP address of target: %s", SCRIPT_NAME, host.ip) stdnse.print_debug("%s not running: Private IP address of target: %s", SCRIPT_NAME, host.ip)
return false return false
end end
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey") local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
if not (type(api_key)=="string") then if not (type(api_key)=="string") then
stdnse.print_debug("%s not running: No IPInfoDB API key specified.", SCRIPT_NAME) stdnse.print_debug("%s not running: No IPInfoDB API key specified.", SCRIPT_NAME)
return false return false
end end
return true return true
end end
-- No limit on requests. A free registration for an API key is a prerequisite -- No limit on requests. A free registration for an API key is a prerequisite
local ipinfodb = function(ip) local ipinfodb = function(ip)
local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey") local api_key = stdnse.get_script_args(SCRIPT_NAME..".apikey")
local response = http.get("api.ipinfodb.com", 80, "/v3/ip-city/?key="..api_key.."&format=json".."&ip="..ip, nil) local response = http.get("api.ipinfodb.com", 80, "/v3/ip-city/?key="..api_key.."&format=json".."&ip="..ip, nil)
local stat, loc = json.parse(response.body) local stat, loc = json.parse(response.body)
if not stat then if not stat then
stdnse.print_debug("No response, possibly a network problem.") stdnse.print_debug("No response, possibly a network problem.")
return nil return nil
end end
if loc.statusMessage and loc.statusMessage == "Invalid API key." then if loc.statusMessage and loc.statusMessage == "Invalid API key." then
stdnse.print_debug(loc.statusMessage) stdnse.print_debug(loc.statusMessage)
return nil return nil
end end
local output = {} local output = {}
table.insert(output, "coordinates (lat,lon): "..loc.latitude..","..loc.longitude) table.insert(output, "coordinates (lat,lon): "..loc.latitude..","..loc.longitude)
table.insert(output,"city: ".. loc.cityName..", ".. loc.regionName..", ".. loc.countryName) table.insert(output,"city: ".. loc.cityName..", ".. loc.regionName..", ".. loc.countryName)
return output return output
end end
action = function(host,port) action = function(host,port)
local output = ipinfodb(host.ip) local output = ipinfodb(host.ip)
if(#output~=0) then if(#output~=0) then
output.name = host.ip output.name = host.ip
if host.targetname then if host.targetname then
output.name = output.name.." ("..host.targetname..")" output.name = output.name.." ("..host.targetname..")"
end end
end end
return stdnse.format_output(true,output) return stdnse.format_output(true,output)
end end

File diff suppressed because it is too large Load Diff