mirror of
https://github.com/nmap/nmap.git
synced 2026-10-22 11:51:52 +00:00
Categorize but don't fetch off-host URLs. Fixes #2238
This commit is contained in:
parent
bb8718a7d5
commit
cd2a82b6c0
1 changed files with 19 additions and 19 deletions
|
|
@ -33,28 +33,32 @@ portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open
|
|||
|
||||
action = function(host, port)
|
||||
|
||||
local scripts = {}
|
||||
|
||||
local crawler = httpspider.Crawler:new(host, port, '/', { scriptname = SCRIPT_NAME,
|
||||
maxpagecount = 30,
|
||||
maxdepth = -1,
|
||||
withinhost = 0,
|
||||
withindomain = 0
|
||||
withinhost = true
|
||||
})
|
||||
|
||||
crawler.options.doscraping = function(url)
|
||||
if crawler:iswithinhost(url)
|
||||
and not crawler:isresource(url, "js")
|
||||
and not crawler:isresource(url, "css") then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
crawler:set_timeout(10000)
|
||||
|
||||
if (not(crawler)) then
|
||||
if not crawler then
|
||||
return
|
||||
end
|
||||
|
||||
local scripts = {}
|
||||
crawler.options.withinhost = function(url)
|
||||
-- Check for cross-domain javascript
|
||||
if not crawler:iswithindomain(url) and crawler:isresource(url, "js") then
|
||||
scripts[tostring(url)] = true
|
||||
end
|
||||
-- But don't actually fetch it if it's not on the same host
|
||||
return crawler:iswithinhost(url)
|
||||
end
|
||||
|
||||
crawler.options.doscraping = function(url)
|
||||
return (not crawler:isresource(url, "js")
|
||||
and not crawler:isresource(url, "css"))
|
||||
end
|
||||
|
||||
crawler:set_timeout(10000)
|
||||
|
||||
while(true) do
|
||||
|
||||
|
|
@ -67,10 +71,6 @@ action = function(host, port)
|
|||
end
|
||||
end
|
||||
|
||||
if crawler:isresource(r.url, "js") and not crawler:iswithinhost(r.url) then
|
||||
scripts[tostring(r.url)] = true
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if next(scripts) == nil then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue