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('true', 1, true) end }) @@ -1363,14 +1363,14 @@ table.insert(fingerprints, { login_check = function (host, port, path, user, pass) local lurl = url.absolute(path, "server_eps.html") -- obtain login nonce - local req1 = http_get_simple(host, port, lurl) - local nonce = req1.status == 403 and sets_cookie(req1, "SrvrNonce", ".") + local resp1 = http_get_simple(host, port, lurl) + local nonce = resp1.status == 403 and sets_cookie(resp1, "SrvrNonce", ".") if not nonce then return false end -- credential is the MD5 hash of the nonce and the password (in upper case) local creds = stdnse.tohex(openssl.md5(nonce .. ":" .. pass:upper())) local cookies = ("SrvrNonce=%s; SrvrCreds=%s"):format(nonce, creds) - local req2 = http_get_simple(host, port, lurl, {cookies=cookies}) - return req2.status == 200 + local resp2 = http_get_simple(host, port, lurl, {cookies=cookies}) + return resp2.status == 200 end }) @@ -1410,10 +1410,10 @@ table.insert(fingerprints, { local creds = stdnse.tohex(openssl.md5(user .. "_" .. pass)) local header = {["Content-Type"] = "application/x-www-form-urlencoded", ["datatype"] = "json"} - local req = http_post_simple(host, port, url.absolute(path, "../"), - {header=header}, "/api/login/" .. creds) - return req.status == 200 - and (req.header["command-status"] or ""):find("^1 ") + local resp = http_post_simple(host, port, url.absolute(path, "../"), + {header=header}, "/api/login/" .. creds) + return resp.status == 200 + and (resp.header["command-status"] or ""):find("^1 ") end }) @@ -1442,10 +1442,10 @@ table.insert(fingerprints, { tzoffset="0", -- present twice in the original form nextURL="", -- present twice in the original form licAccept=""} - local req = http_post_simple(host, port, url.absolute(path, "login"), - nil, form) - local loc = req.header["location"] or "" - return req.status == 302 and loc:find("/gui$") + local resp = http_post_simple(host, port, url.absolute(path, "login"), + nil, form) + local loc = resp.header["location"] or "" + return resp.status == 302 and loc:find("/gui$") end }) @@ -1494,11 +1494,11 @@ table.insert(fingerprints, { {username = "", password = "Administrator"} }, login_check = function (host, port, path, user, pass) - local req = http_post_simple(host, port, url.absolute(path, "cgi-bin/login"), - nil, {password_value=pass, idle_timeout=60}) + local resp = http_post_simple(host, port, url.absolute(path, "cgi-bin/login"), + nil, {password_value=pass, idle_timeout=60}) -- successful login is a 302-redirect that sets a session cookie with hex -- value; failed login is the same but the cookie contains an error message - return req.status == 302 and sets_cookie(req, "session_id", "^%x+$") + return resp.status == 302 and sets_cookie(resp, "session_id", "^%x+$") end }) @@ -1572,10 +1572,10 @@ table.insert(fingerprints, { {username = "ADMIN", password = "ADMIN"} }, login_check = function (host, port, path, user, pass) - local req = http_post_simple(host, port, url.absolute(path, "cgi/login.cgi"), - nil, {name=user, pwd=pass}) - return req.status == 200 - and req.body - and req.body:find("../cgi/url_redirect.cgi?url_name=mainmenu", 1, true) + local resp = http_post_simple(host, port, url.absolute(path, "cgi/login.cgi"), + nil, {name=user, pwd=pass}) + return resp.status == 200 + and resp.body + and resp.body:find("../cgi/url_redirect.cgi?url_name=mainmenu", 1, true) end })