From 230203d3c964139701f41dced5636b4129bbbefd Mon Sep 17 00:00:00 2001 From: Am <77095239+am0o0@users.noreply.github.com> Date: Fri, 22 Nov 2024 11:17:32 +0330 Subject: [PATCH] Update community/detectors/joomla_cve_2023_23752/src/main/java/com/google/tsunami/plugins/detectors/cves/cve202323752/Cve202323752VulnDetector.java Co-authored-by: Savio Sisco <25590129+lokiuox@users.noreply.github.com> --- .../Cve202323752VulnDetector.java | 32 ++++++++++++------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/community/detectors/joomla_cve_2023_23752/src/main/java/com/google/tsunami/plugins/detectors/cves/cve202323752/Cve202323752VulnDetector.java b/community/detectors/joomla_cve_2023_23752/src/main/java/com/google/tsunami/plugins/detectors/cves/cve202323752/Cve202323752VulnDetector.java index 0e67229eb..a7f5bd04d 100644 --- a/community/detectors/joomla_cve_2023_23752/src/main/java/com/google/tsunami/plugins/detectors/cves/cve202323752/Cve202323752VulnDetector.java +++ b/community/detectors/joomla_cve_2023_23752/src/main/java/com/google/tsunami/plugins/detectors/cves/cve202323752/Cve202323752VulnDetector.java @@ -134,19 +134,27 @@ private boolean isServiceVulnerable(NetworkService networkService) { return false; } - // check for body values match our detection rules - if (appConfHttpResponse.bodyString().get().contains("password") - && appConfHttpResponse.bodyString().get().contains("user")) { + // Check if body values match our detection rules + if (!appConfHttpResponse.bodyString().get().contains("password") + || !appConfHttpResponse.bodyString().get().contains("user")) { + return false; + } + + // Check if body is JSON + if (appConfHttpResponse.bodyJson().isEmpty()) { + return false; + } + + JsonObject jsonResponse = appConfHttpResponse.bodyJson().get().getAsJsonObject(); + if (!jsonResponse.has("data")) { + return false; + } - JsonObject jsonResponse = (JsonObject) appConfHttpResponse.bodyJson().get(); - if (jsonResponse.keySet().contains("data")) { - JsonArray jsonArray = jsonResponse.getAsJsonArray("data"); - for (int i = 0; i < jsonArray.size(); i++) { - if (jsonArray.get(i).getAsJsonObject().keySet().contains("attributes")) { - exposedConfig = appConfHttpResponse.bodyString().get(); - return true; - } - } + JsonArray jsonArray = jsonResponse.getAsJsonArray("data"); + for (int i = 0; i < jsonArray.size(); i++) { + if (jsonArray.get(i).getAsJsonObject().has("attributes")) { + exposedConfig = appConfHttpResponse.bodyString().get(); + return true; } } } catch (NoSuchElementException | IllegalStateException | JsonSyntaxException e) {