mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +00:00
Use canonical IP validation function from ipOps.lua. Fixes #889
This commit is contained in:
parent
8d04c3b850
commit
edd0676e4b
1 changed files with 2 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
local http = require "http"
|
||||
local ipOps = require "ipOps"
|
||||
local table = require "table"
|
||||
local shortport = require "shortport"
|
||||
local stdnse = require "stdnse"
|
||||
|
|
@ -93,15 +94,6 @@ local function get_options (host, port, path)
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
local function validateIP(matched_ip)
|
||||
local oct_1, oct_2, oct_3, oct_4 = matched_ip:match('^(%d+)%.(%d+)%.(%d+)%.(%d+)$')
|
||||
if tonumber(oct_1) > 255 or tonumber(oct_2) > 255 or tonumber(oct_3) > 255 or tonumber(oct_4) > 255 then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
-- a function to extract internal ip addresses from PROPFIND response.
|
||||
local function getIPs(body)
|
||||
local ip_pats = {'%f[%d]192%.168%.%d+%.%d+',
|
||||
|
|
@ -112,7 +104,7 @@ local function getIPs(body)
|
|||
local result = {}
|
||||
for _, ip_pat in pairs(ip_pats) do
|
||||
for ip in body:gmatch(ip_pat) do
|
||||
if validateIP(ip) then
|
||||
if ipOps.expand_ip(ip) then
|
||||
result[ip] = true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue