Fix early-exit bug; add IconsTrait secondary probe, nonce extraction, fallback manifests

This commit is contained in:
Aditya Agrawal 2026-07-18 11:40:23 +05:30
parent 8604e0abd7
commit ae76570d1c
2 changed files with 196 additions and 56 deletions

View file

@ -4,6 +4,7 @@ local stdnse = require "stdnse"
local string = require "string"
local table = require "table"
local json = require "json"
local rand = require "rand"
local vulns = require "vulns"
description = [[
@ -77,6 +78,17 @@ local EP_ACTION_ABSENT = 3
local COMMON_WP_PATHS = {"", "/wordpress", "/wp", "/blog", "/site", "/cms"}
local NONCE_PATTERNS = {
'["\']nonce["\']%s*:%s*["\']([A-Za-z0-9_%-]+)["\']',
'["\']wpfnl_nonce["\']%s*:%s*["\']([A-Za-z0-9_%-]+)["\']',
'["\']security["\']%s*:%s*["\']([A-Za-z0-9_%-]+)["\']',
'data%-nonce=["\']([A-Za-z0-9_%-]+)["\']',
}
local NONCE_PARAM_NAMES = {"_wpnonce", "security", "wpfnl_nonce"}
local NONCE_FETCH_PATHS = {"/", "/checkout/", "/cart/", "/checkout", "/cart"}
local function version_ge(v1, v2)
local function split(v)
local parts = {}
@ -155,7 +167,7 @@ local function classify_ajax_response(resp)
if trimmed and string.sub(trimmed, 1, 1) == "<" then
return nil
end
return EP_ACTION_ACTIVE
return nil
end
local function try_get_version(host, port, base_path)
@ -189,6 +201,7 @@ end
local function find_base_path(host, port)
local path_arg = stdnse.get_script_args(SCRIPT_NAME .. ".path")
if path_arg and #path_arg > 0 then
path_arg = string.match(path_arg, "^(.-)/*$") or path_arg
return path_arg
end
for _, p in ipairs(COMMON_WP_PATHS) do
@ -201,6 +214,50 @@ local function find_base_path(host, port)
return ""
end
local function url_encode(s)
if not s then return "" end
local result = ""
for i = 1, #s do
local c = string.byte(s, i)
if (c >= 48 and c <= 57) or (c >= 65 and c <= 90) or (c >= 97 and c <= 122) or c == 45 or c == 46 or c == 95 or c == 126 then
result = result .. string.char(c)
else
result = result .. string.format("%%%02X", c)
end
end
return result
end
local function extract_nonce(host, port, base_path)
for _, rel_path in ipairs(NONCE_FETCH_PATHS) do
local url = base_path .. rel_path
local resp = http.get(host, port, url)
if resp and resp.status == 200 and resp.body then
for _, pattern in ipairs(NONCE_PATTERNS) do
local nonce = string.match(resp.body, pattern)
if nonce and #nonce >= 8 then
return nonce
end
end
end
end
return nil
end
local function try_ajax_with_nonce(host, port, ajax_path, probe_value, nonce)
local param = NONCE_PARAM_NAMES[1]
local content = "action=wpfnl_log&postData=" .. url_encode(probe_value) .. "&" .. param .. "=" .. url_encode(nonce)
local resp = http.post(host, port, ajax_path, {
header = {["Content-Type"] = "application/x-www-form-urlencoded"},
content = content,
})
local ep = classify_ajax_response(resp)
if ep == EP_ACTION_ACTIVE then
return ep
end
return nil
end
action = function(host, port)
local vuln = {
title = "WPFunnels WordPress Unauthenticated RCE",
@ -228,12 +285,21 @@ is subsequently executed via include_once when an admin views the log (CVSS 9.8)
return report:make_output(vuln)
end
end
local probe_value = rand.random_alpha(12)
local ajax_path = base_path .. "/wp-admin/admin-ajax.php"
local resp = http.post(host, port, ajax_path, {
header = {["Content-Type"] = "application/x-www-form-urlencoded"},
content = "action=wpfnl_log&postData=CVE-2026-14345-probe",
})
local ep_class = classify_ajax_response(resp)
local nonce = extract_nonce(host, port, base_path)
local ep_class
if nonce then
ep_class = try_ajax_with_nonce(host, port, ajax_path, probe_value, nonce)
end
if not ep_class then
local content = "action=wpfnl_log&postData=" .. probe_value
local resp = http.post(host, port, ajax_path, {
header = {["Content-Type"] = "application/x-www-form-urlencoded"},
content = content,
})
ep_class = classify_ajax_response(resp)
end
if ep_class == EP_ACTION_ACTIVE or ep_class == EP_ACTION_BLOCKED then
if found_version then
vuln.state = vulns.STATE.VULN

View file

@ -86,6 +86,12 @@ local LOGIN_PATH_INDICATORS = {
local COMMON_JOOMLA_PATHS = {"", "/joomla", "/cms", "/site", "/joomla3", "/joomla4"}
local MANIFEST_PATHS = {
"administrator/components/com_sppagebuilder/sp_page_builder.xml",
"administrator/components/com_sppagebuilder/sppagebuilder.xml",
"administrator/components/com_sppagebuilder/com_sppagebuilder.xml",
}
local function version_ge(v1, v2)
local function split(v)
local parts = {}
@ -229,10 +235,27 @@ local function is_controller_response(resp)
if not is_joomla_json_format(data) then
return false
end
if indicates_auth(data) then
return not indicates_auth(data)
end
local function is_auth_response(resp)
if not resp or not resp.body or #resp.body == 0 then
return false
end
return true
if body_is_html(resp.body) then
return false
end
if not has_json_content_type(resp) and not response_looks_like_json(resp.body) then
return false
end
local ok, data = json.parse(resp.body)
if not ok or type(data) ~= "table" then
return false
end
if not is_joomla_json_format(data) then
return false
end
return indicates_auth(data)
end
local function is_login_redirect(resp)
@ -245,10 +268,16 @@ local function is_login_redirect(resp)
return true
end
end
local set_cookie = resp.header["set-cookie"] or ""
if string.find(string.lower(set_cookie), "session", 1, true) or
string.find(string.lower(set_cookie), "joomla", 1, true) then
return true
if resp.rawheader then
for _, line in ipairs(resp.rawheader) do
local lower = string.lower(line)
if string.find(lower, "^set%-cookie:", 1) then
if string.find(lower, "session", 1, true) or
string.find(lower, "joomla", 1, true) then
return true
end
end
end
end
return false
end
@ -257,8 +286,13 @@ local function classify_endpoint(resp)
if not resp then
return nil
end
if resp.status == 200 and is_controller_response(resp) then
return EP_UNPROTECTED
if resp.status == 200 then
if is_controller_response(resp) then
return EP_UNPROTECTED
end
if is_auth_response(resp) then
return EP_AUTH_ENFORCED
end
end
if resp.status == 401 or resp.status == 403 then
return EP_AUTH_ENFORCED
@ -282,14 +316,16 @@ local function classify_endpoint(resp)
end
local function try_get_version(host, port, base_path)
local manifest_path = base_path .. "/administrator/components/com_sppagebuilder/sp_page_builder.xml"
local resp = http.get(host, port, manifest_path)
if resp and resp.status == 200 and resp.body then
local ver = string.match(resp.body, "<version>([^<]+)</version>")
if ver then
ver = string.match(ver, "%d[%d%.]*")
for _, manifest_rel in ipairs(MANIFEST_PATHS) do
local manifest_path = base_path .. "/" .. manifest_rel
local resp = http.get(host, port, manifest_path)
if resp and resp.status == 200 and resp.body then
local ver = string.match(resp.body, "<version>([^<]+)</version>")
if ver then
return ver
ver = string.match(ver, "%d[%d%.]*")
if ver then
return ver
end
end
end
end
@ -299,6 +335,7 @@ end
local function find_base_path(host, port)
local path_arg = stdnse.get_script_args(SCRIPT_NAME .. ".path")
if path_arg and #path_arg > 0 then
path_arg = string.match(path_arg, "^(.-)/*$") or path_arg
return path_arg
end
for _, p in ipairs(COMMON_JOOMLA_PATHS) do
@ -311,6 +348,62 @@ local function find_base_path(host, port)
return ""
end
local function build_probe_parts()
local boundary = "----NseB" .. rand.random_alpha(8)
local empty_zip = string.char(
0x50, 0x4B, 0x05, 0x06,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00
)
local parts = {}
table.insert(parts, "--" .. boundary)
table.insert(parts, 'Content-Disposition: form-data; name="custom_icon"; filename="icon.zip"')
table.insert(parts, "Content-Type: application/zip")
table.insert(parts, "")
table.insert(parts, empty_zip)
table.insert(parts, "--" .. boundary .. "--")
return boundary, table.concat(parts, "\r\n")
end
local function probe_endpoint(host, port, base_path, probe_suffixes)
local boundary, body = build_probe_parts()
local best = nil
for _, suffix in ipairs(probe_suffixes) do
local url = base_path .. suffix
local resp = http.post(host, port, url, {
header = {["Content-Type"] = "multipart/form-data; boundary=" .. boundary},
content = body,
})
local ep = classify_endpoint(resp)
if ep == EP_UNPROTECTED then
return EP_UNPROTECTED
end
if ep ~= nil and ep ~= EP_ABSENT then
return ep
end
if ep == EP_ABSENT and best == nil then
best = EP_ABSENT
end
end
return best
end
local function combine_classifications(c1, c2)
if c1 == EP_UNPROTECTED or c2 == EP_UNPROTECTED then
return EP_UNPROTECTED
end
if c1 == nil then return c2 end
if c2 == nil then return c1 end
if c1 == EP_ABSENT then return c2 end
if c2 == EP_ABSENT then return c1 end
return math.min(c1, c2)
end
action = function(host, port)
local vuln = {
title = "SP Page Builder for Joomla Unauthenticated RCE",
@ -330,38 +423,19 @@ leading to PHP code execution and full server compromise (CVSS 10.0).
local report = vulns.Report:new(SCRIPT_NAME, host, port)
local base_path = find_base_path(host, port)
local found_version = try_get_version(host, port, base_path)
if found_version then
if version_ge(found_version, "6.6.2") then
return report:make_output(vuln)
end
if version_lt(found_version, "1.0.0") then
return report:make_output(vuln)
end
if found_version and version_lt(found_version, "1.0.0") then
return report:make_output(vuln)
end
local boundary = "----NseB" .. rand.random_alpha(8)
local empty_zip = string.char(
0x50, 0x4B, 0x05, 0x06,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00
)
local probe_parts = {}
table.insert(probe_parts, "--" .. boundary)
table.insert(probe_parts, 'Content-Disposition: form-data; name="custom_icon"; filename="icon.zip"')
table.insert(probe_parts, "Content-Type: application/zip")
table.insert(probe_parts, "")
table.insert(probe_parts, empty_zip)
table.insert(probe_parts, "--" .. boundary .. "--")
local probe_path = base_path .. "/index.php?option=com_sppagebuilder&task=asset.uploadCustomIcon"
local resp = http.post(host, port, probe_path, {
header = {["Content-Type"] = "multipart/form-data; boundary=" .. boundary},
content = table.concat(probe_parts, "\r\n"),
local ep_class = probe_endpoint(host, port, base_path, {
"/index.php?option=com_sppagebuilder&task=asset.uploadCustomIcon",
})
local ep_class = classify_endpoint(resp)
if ep_class ~= EP_UNPROTECTED then
local ep_class2 = probe_endpoint(host, port, base_path, {
"/index.php?option=com_sppagebuilder&task=editor.uploadIcons",
"/administrator/index.php?option=com_sppagebuilder&task=editor.uploadIcons",
})
ep_class = combine_classifications(ep_class, ep_class2)
end
if ep_class == EP_UNPROTECTED then
if found_version then
vuln.state = vulns.STATE.VULN
@ -369,15 +443,15 @@ leading to PHP code execution and full server compromise (CVSS 10.0).
vuln.state = vulns.STATE.LIKELY_VULN
end
elseif ep_class == EP_AUTH_ENFORCED then
if found_version then
if found_version and version_ge(found_version, "6.6.2") then
vuln.state = vulns.STATE.NOT_VULN
else
vuln.state = vulns.STATE.LIKELY_VULN
end
elseif ep_class == EP_PRESENT_METHOD_REJECTED then
if found_version then
vuln.state = vulns.STATE.LIKELY_VULN
end
vuln.state = vulns.STATE.LIKELY_VULN
elseif ep_class == EP_ABSENT then
if found_version then
if found_version and not version_ge(found_version, "6.6.2") then
vuln.state = vulns.STATE.LIKELY_VULN
end
end