From 848bc4d1d7139390cb1f16582591905688183123 Mon Sep 17 00:00:00 2001 From: fyodor Date: Sat, 11 Aug 2007 03:32:56 +0000 Subject: [PATCH] merge soc07 r4805 - new httpauth nse script --- scripts/HTTPAuth.nse | 141 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 scripts/HTTPAuth.nse diff --git a/scripts/HTTPAuth.nse b/scripts/HTTPAuth.nse new file mode 100644 index 0000000000..5092dcb13a --- /dev/null +++ b/scripts/HTTPAuth.nse @@ -0,0 +1,141 @@ +-- 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 = {"(.-)