diff --git a/nselib/data/http-default-accounts-fingerprints.lua b/nselib/data/http-default-accounts-fingerprints.lua index 847d98a2f..bb0f1660f 100644 --- a/nselib/data/http-default-accounts-fingerprints.lua +++ b/nselib/data/http-default-accounts-fingerprints.lua @@ -82,11 +82,11 @@ end --- local function try_http_basic_login(host, port, path, user, pass, digest_auth) local credentials = {username = user, password = pass, digest = digest_auth} - local req = http_get_simple(host, port, path, {auth=credentials}) - return req.status - and req.status ~= 401 - and req.status ~= 403 - and req.status ~= 404 + local resp = http_get_simple(host, port, path, {auth=credentials}) + return resp.status + and resp.status ~= 401 + and resp.status ~= 403 + and resp.status ~= 404 end --- @@ -101,13 +101,13 @@ end -- @return True if login in was successful --- local function try_http_post_login(host, port, path, target, failstr, params, follow_redirects) - local req = http_post_simple(host, port, url.absolute(path, target), nil, params) - if not req.status then return false end - local status = tonumber(req.status) or 0 + local resp = http_post_simple(host, port, url.absolute(path, target), nil, params) + if not resp.status then return false end + local status = tonumber(resp.status) or 0 if follow_redirects and ( status > 300 and status < 400 ) then - req = http_get_simple(host, port, url.absolute(path, req.header.location)) + resp = http_get_simple(host, port, url.absolute(path, resp.header.location)) end - if req.status and req.status ~= 404 and not(http.response_contains(req, failstr)) then + if resp.status and resp.status ~= 404 and not(http.response_contains(resp, failstr)) then return true end return false @@ -234,9 +234,9 @@ table.insert(fingerprints, { {username = "admin", password = "zabbix"} }, login_check = function (host, port, path, user, pass) - local req = http_post_simple(host, port, url.absolute(path, "index.php"), nil, - {request="", name=user, password=pass, enter="Sign in"}) - return req.status == 302 and req.header["location"] == "dashboard.php" + local resp = http_post_simple(host, port, url.absolute(path, "index.php"), nil, + {request="", name=user, password=pass, enter="Sign in"}) + return resp.status == 302 and resp.header["location"] == "dashboard.php" end }) @@ -257,9 +257,9 @@ table.insert(fingerprints, { login_check = function (host, port, path, user, pass) local lurl = url.absolute(path, "users/login") -- harvest all hidden fields from the login form - local req1 = http_get_simple(host, port, lurl) - if req1.status ~= 200 then return false end - local html = req1.body and req1.body:match('
') + local resp1 = http_get_simple(host, port, lurl) + if resp1.status ~= 200 then return false end + local html = resp1.body and resp1.body:match('') if not html then return false end local form = {} for n, v in html:gmatch('window.location.replace(", 1, true) - or req.body:find("Another user is logged in", 1, true)) + local resp = http_post_simple(host, port, + url.absolute(path, "cgi-bin/login.cgi"), + nil, {username=user, password=pass}) + return resp.status == 200 + and resp.body + and (resp.body:find(">window.location.replace(", 1, true) + or resp.body:find("Another user is logged in", 1, true)) end }) @@ -1234,15 +1234,15 @@ table.insert(fingerprints, { }, login_check = function (host, port, path, user, pass) -- determine proper login path by locale - local req0 = http.get(host, port, path) - if req0.status ~= 200 then return false end - local lurl = req0.body and req0.body:match('location%.href="(/[^"]+/)mainFrame%.cgi"') + local resp0 = http.get(host, port, path) + if resp0.status ~= 200 then return false end + local lurl = resp0.body and resp0.body:match('location%.href="(/[^"]+/)mainFrame%.cgi"') if not lurl then return false end -- harvest the login form token - local req1 = http_get_simple(host, port, url.absolute(lurl, "authForm.cgi"), - {cookies="cookieOnOffChecker=on"}) - if req1.status ~= 200 then return false end - local token = req1.body and req1.body:match('true', 1, true) + local resp = http_post_simple(host, port, url.absolute(path, "soap"), + {header=header}, soapmsg) + return resp.status == 200 + and resp.body + and resp.body:find('