-- HTTP authentication information gathering script -- rev 1.1 (2007-05-25) id = "HTTP Auth" description = "If a web server requires authentication, prints the authentication scheme and realm" author = "Thomas Buchanan " license = "See nmaps COPYING for licence" -- uncomment the following line to enable safe category -- categories = {"safe"} categories = {"intrusive"} portrule = function(host, port) if ( port.number == 80 or port.number == 8080 or port.service == "http") and port.protocol == "tcp" and port.state == "open" then return true else return false end end action = function(host, port) local socket local catch = function() socket:close() end local try = nmap.new_try(catch) local get_http_headers = function(dst, dst_port, query_string) socket = nmap.new_socket() try(socket:connect(dst, dst_port)) try(socket:send(query_string)) local response = "" local lines local status while true do status, lines = socket:receive_lines(1) if not status then break end response = response .. lines end try(socket:close()) local tags = {"(.-)