mirror of
https://github.com/nmap/nmap.git
synced 2025-12-07 05:01:29 +00:00
Documentation, whitespace, style in http-affiliate-id.
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
description = [[
|
description = [[
|
||||||
|
Grabs affiliate network IDs from an HTML page. These can be used to
|
||||||
|
identify pages with the same owner.
|
||||||
|
|
||||||
This script grabs Google Analytics and Adsense IDs.
|
Supported IDs:
|
||||||
They could be used to further look for related websites (that have
|
* Google Analytics
|
||||||
the same owner.)
|
* Google AdSense
|
||||||
|
* Amazon Associates
|
||||||
]]
|
]]
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -16,9 +18,10 @@ the same owner.)
|
|||||||
-- @output
|
-- @output
|
||||||
-- PORT STATE SERVICE
|
-- PORT STATE SERVICE
|
||||||
-- 80/tcp open http
|
-- 80/tcp open http
|
||||||
-- | http-affiliate-id:
|
-- | http-affiliate-id:
|
||||||
-- | Google Analytics ID: UA-XXXXXXXX-XX
|
-- | Amazon Associates ID: XXXX-XX
|
||||||
-- |_ Google Adsense ID: pub-YYYYYYYYYYYYYYYY
|
-- | Google Adsense ID: pub-YYYY
|
||||||
|
-- |_ Google Analytics ID: UA-ZZZZ-ZZ
|
||||||
|
|
||||||
author = "Hani Benhabiles, Daniel Miller"
|
author = "Hani Benhabiles, Daniel Miller"
|
||||||
|
|
||||||
@@ -31,34 +34,31 @@ require 'http'
|
|||||||
require 'pcre'
|
require 'pcre'
|
||||||
require 'stdnse'
|
require 'stdnse'
|
||||||
|
|
||||||
portrule = shortport.port_or_service( {80,443}, {"http","https"} )
|
-- these are the regular expressions for affiliate IDs
|
||||||
|
local AFFILIATE_PATTERNS = {
|
||||||
action = function(host, port)
|
|
||||||
local url_path, body, analyticsid, adsenseid, result
|
|
||||||
result = ""
|
|
||||||
url_path = stdnse.get_script_args("http-affiliate-id.url-path") or "/"
|
|
||||||
body = http.get( host, port, url_path).body
|
|
||||||
|
|
||||||
-- these are the regular expressions for affiliate IDs
|
|
||||||
local affiliates = {
|
|
||||||
["Google Analytics ID"] = "(?P<id>UA-[0-9]{6,9}-[0-9]{1,2})",
|
["Google Analytics ID"] = "(?P<id>UA-[0-9]{6,9}-[0-9]{1,2})",
|
||||||
["Google Adsense ID"] = "(?P<id>pub-[0-9]{16,16})",
|
["Google Adsense ID"] = "(?P<id>pub-[0-9]{16,16})",
|
||||||
["Amazon Associates ID"] = "href=\"http://www.amazon.com/[^\"]*[&;]tag=(?P<id>\\w+-\\d+)",
|
["Amazon Associates ID"] = "href=\"http://www.amazon.com/[^\"]*[&;]tag=(?P<id>\\w+-\\d+)",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
portrule = shortport.http
|
||||||
|
|
||||||
|
action = function(host, port)
|
||||||
|
local url_path, body, result
|
||||||
|
result = {}
|
||||||
|
url_path = stdnse.get_script_args("http-affiliate-id.url-path") or "/"
|
||||||
|
body = http.get(host, port, url_path).body
|
||||||
|
|
||||||
-- Here goes affiliate matching
|
-- Here goes affiliate matching
|
||||||
for name,re in pairs(affiliates) do
|
for name, re in pairs(AFFILIATE_PATTERNS) do
|
||||||
local regex, limit, limit2, matches, affiliateid
|
local regex, limit, limit2, matches, affiliateid
|
||||||
regex = pcre.new(re, 0, "C")
|
regex = pcre.new(re, 0, "C")
|
||||||
limit, limit2, matches = regex:match(body)
|
limit, limit2, matches = regex:match(body)
|
||||||
if limit ~= nil then
|
if limit ~= nil then
|
||||||
affiliateid = matches["id"]
|
affiliateid = matches["id"]
|
||||||
result = result .. "\n " .. name .. ": " .. affiliateid
|
result[#result + 1] = name .. ": " .. affiliateid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if result ~= "" then
|
return stdnse.format_output(true, result)
|
||||||
return result
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user