mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Documentation, whitespace, style in http-affiliate-id.
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
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.
|
||||
They could be used to further look for related websites (that have
|
||||
the same owner.)
|
||||
|
||||
Supported IDs:
|
||||
* Google Analytics
|
||||
* Google AdSense
|
||||
* Amazon Associates
|
||||
]]
|
||||
|
||||
---
|
||||
@@ -17,8 +19,9 @@ the same owner.)
|
||||
-- PORT STATE SERVICE
|
||||
-- 80/tcp open http
|
||||
-- | http-affiliate-id:
|
||||
-- | Google Analytics ID: UA-XXXXXXXX-XX
|
||||
-- |_ Google Adsense ID: pub-YYYYYYYYYYYYYYYY
|
||||
-- | Amazon Associates ID: XXXX-XX
|
||||
-- | Google Adsense ID: pub-YYYY
|
||||
-- |_ Google Analytics ID: UA-ZZZZ-ZZ
|
||||
|
||||
author = "Hani Benhabiles, Daniel Miller"
|
||||
|
||||
@@ -31,34 +34,31 @@ require 'http'
|
||||
require 'pcre'
|
||||
require 'stdnse'
|
||||
|
||||
portrule = shortport.port_or_service( {80,443}, {"http","https"} )
|
||||
|
||||
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 = {
|
||||
-- these are the regular expressions for affiliate IDs
|
||||
local AFFILIATE_PATTERNS = {
|
||||
["Google Analytics ID"] = "(?P<id>UA-[0-9]{6,9}-[0-9]{1,2})",
|
||||
["Google Adsense ID"] = "(?P<id>pub-[0-9]{16,16})",
|
||||
["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
|
||||
for name,re in pairs(affiliates) do
|
||||
for name, re in pairs(AFFILIATE_PATTERNS) do
|
||||
local regex, limit, limit2, matches, affiliateid
|
||||
regex = pcre.new(re, 0, "C")
|
||||
limit, limit2, matches = regex:match(body)
|
||||
if limit ~= nil then
|
||||
affiliateid = matches["id"]
|
||||
result = result .. "\n " .. name .. ": " .. affiliateid
|
||||
result[#result + 1] = name .. ": " .. affiliateid
|
||||
end
|
||||
end
|
||||
|
||||
if result ~= "" then
|
||||
return result
|
||||
end
|
||||
return stdnse.format_output(true, result)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user