description = [[ Spiders a web server and displays its directory structure along with number and types of files in each folder. Note that files listed as having an 'Other' extension are ones that have no extension or that are a root document. ]] --- -- @usage -- nmap --script http-sitemap-generator -p 80 -- -- -- @output -- PORT STATE SERVICE REASON -- 80/tcp open http syn-ack -- | http-sitemap-generator: -- | Directory structure: -- | / -- | Other: 1 -- | /images/ -- | png: 1 -- | /shared/css/ -- | css: 1 -- | /shared/images/ -- | gif: 1; png: 1 -- | Longest directory structure: -- | Depth: 2 -- | Dir: /shared/css/ -- | Total files found (by extension): -- |_ Other: 1; css: 1; gif: 1; png: 2 -- -- @args http-sitemap-generator.maxdepth the maximum amount of directories beneath -- the initial url to spider. A negative value disables the limit. -- (default: 3) -- @args http-sitemap-generator.maxpagecount the maximum amount of pages to visit. -- A negative value disables the limit (default: 20) -- @args http-sitemap-generator.url the url to start spidering. This is a URL -- relative to the scanned host eg. /default.html (default: /) -- @args http-sitemap-generator.withinhost only spider URLs within the same host. -- (default: true) -- @args http-sitemap-generator.withindomain only spider URLs within the same -- domain. This widens the scope from withinhost and can -- not be used in combination. (default: false) -- author = "Piotr Olma" license = "Same as Nmap--See http://nmap.org/book/man-legal.html" categories = {"discovery", "intrusive"} local shortport = require 'shortport' local http = require 'http' local stdnse = require 'stdnse' local url = require 'url' local string = require 'string' local table = require 'table' portrule = shortport.port_or_service( {80, 443}, {"http", "https"}, "tcp", "open") function action(host, port) local r1 = http.modget(host, port, "/") if r1 then stdnse.print_debug("\t\tgot r1") end local r2 = http.modget(host, port, "/") if r2 then stdnse.print_debug("\t\tgot r2") end return nil end