Exploit databaseDownload repository ZIP
GH-2c2e4acaf72fa37a7a64a839f80ffa9d
jonathanstross/cve-2025-31324
Sources for CVE-2025-31324
16 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files8
jonathanstross/cve-2025-31324Revision 9441854805b5
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
scan.py
Suggested starting filePython · 8,463 bytes#!/usr/bin/env python3
"""
SAP CVE-2025-31324 Analyzer
---------------------------
Security scanner for detecting CVE-2025-31324 in SAP Visual Composer systems,
and identifying IOC's.
Version: 1.0.4
"""
import argparse
import csv
import sys
from dataclasses import dataclass
from typing import List, Tuple, Optional
import requests
from urllib3.exceptions import InsecureRequestWarning
# Disable SSL warnings
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# Constants
VULNERABLE_PATH = "/developmentserver/metadatauploader"
DEFAULT_IOCS = ["cache.jsp", "helper.jsp", "nzwcnktc.jsp"]
class Color:
RED = "\033[91m"
GREEN = "\033[92m"
YELLOW = "\033[93m"
ORANGE = "\033[38;5;208m"
GREY = "\033[90m"
RESET = "\033[0m"
ICON = {
"ok": "✅",
"warn": "❗",
"fail": "❌",
"boom": "💥"
}
@dataclass
class TargetHost:
address: str
port: int
ssl: bool
@property
def full_url(self) -> str:
protocol = "https" if self.ssl else "http"
return f"{protocol}://{self.address}:{self.port}"
@property
def label(self) -> str:
return f"{self.address}:{self.port}"
class Scanner:
def __init__(self, host: TargetHost, iocs: List[str], verbose: bool = False):
self.host = host
self.iocs = iocs
self.verbose = verbose
def probe_visual_composer(self) -> Optional[bool]:
url = f"{self.host.full_url}{VULNERABLE_PATH}"
if self.verbose:
print(f"[DEBUG] Checking {url}")
try:
response = requests.head(url, timeout=10, verify=False)
if self.verbose:
print(f"[DEBUG] Received HTTP {response.status_code}")
if response.status_code == 200 and 'Set-Cookie' not in response.headers:
print(f"[!] {url} appears vulnerable.")
return True
elif response.status_code == 404:
if self.verbose:
print(f"[DEBUG] No vulnerable component identified at {url}.")
return False
else:
if self.verbose:
print(f"[DEBUG] Received unexpected status at {url}.")
return False
except requests.RequestException as e:
if self.verbose:
print(f"[ERROR] Connection failed to {url}: {e}")
raise
def scan_for_backdoors(self) -> List[str]:
found = []
for name in self.iocs:
url = f"{self.host.full_url}/irj/{name}"
if self.verbose:
print(f"[DEBUG] Scanning {url}")
try:
resp = requests.get(url, timeout=10, verify=False)
if resp.status_code == 200:
print(f"[!] Potential compromise found: {url}")
found.append(url)
except requests.RequestException as e:
if self.verbose:
print(f"[DEBUG] Skipping {url} due to error: {e}")
return found
def run_scan(self) -> Tuple[bool, List[str], bool]:
try:
vulnerable = self.probe_visual_composer()
except Exception:
return False, [], False # connection issue
if vulnerable is not True:
return False, [], True # online but not vulnerable
backdoors = self.scan_for_backdoors()
return True, backdoors, True
def print_boxed_result(index: int, host: TargetHost, is_vulnerable: bool, backdoors: List[str], online: bool):
print("__________________________________")
if not online:
print(f"{Color.GREY}{ICON['fail']} Target {index} : {host.label}{Color.RESET}")
print(f"Connection: {Color.GREY}Offline{Color.RESET}")
print(f"Status: {Color.GREY}Not Vulnerable{Color.RESET}")
print(f"IOC: {Color.GREY}None detected{Color.RESET}")
elif is_vulnerable and backdoors:
print(f"{Color.RED}{ICON['boom']} Target {index} : {host.label}{Color.RESET}")
print(f"Connection: {Color.GREEN}Online{Color.RESET}")
print(f"Status: {Color.RED}Vulnerable{Color.RESET}")
print(f"IOC: {Color.RED}Potential Signatures found{Color.RESET}")
print("Signatures:")
for b in backdoors:
print(f" - {b}")
elif is_vulnerable:
print(f"{Color.ORANGE}{ICON['warn']} Target {index} : {host.label}{Color.RESET}")
print(f"Connection: {Color.GREEN}Online{Color.RESET}")
print(f"Status: {Color.ORANGE}Vulnerable{Color.RESET}")
print(f"IOC: {Color.GREEN}None detected{Color.RESET}")
else:
print(f"{Color.GREEN}{ICON['ok']} Target {index} : {host.label}{Color.RESET}")
print(f"Connection: {Color.GREEN}Online{Color.RESET}")
print(f"Status: {Color.GREEN}Not Vulnerable{Color.RESET}")
print(f"IOC: {Color.GREEN}None detected{Color.RESET}")
print("__________________________________\n")
def export_csv_aggregate(filename: str, results: List[Tuple[TargetHost, bool, List[str], bool]]):
try:
with open(filename, mode='w', newline='') as csvfile:
writer = csv.writer(csvfile)
writer.writerow(["Target", "Connection", "Status", "IOC", "Signatures"])
for host, is_vulnerable, backdoors, online in results:
status = "Vulnerable" if is_vulnerable else "Not Vulnerable"
ioc = "Potential Signatures found" if backdoors else "None detected"
sigs = " | ".join(backdoors) if backdoors else "N/A"
writer.writerow([
host.label,
"Online" if online else "Offline",
status,
ioc,
sigs
])
print(f"[+] Aggregated report saved to: {filename}")
except IOError as e:
print(f"[ERROR] Could not write report to {filename}: {e}")
def parse_targets_from_file(path: str) -> List[TargetHost]:
targets = []
try:
with open(path, newline='') as csvfile:
reader = csv.reader(csvfile, delimiter=';')
for row in reader:
if len(row) != 3:
print(f"[WARN] Skipping invalid line: {row}")
continue
host, port_str, ssl_str = row
try:
port = int(port_str.strip())
ssl = ssl_str.strip().lower() in ["true", "yes", "1"]
targets.append(TargetHost(host.strip(), port, ssl))
except ValueError:
print(f"[WARN] Invalid port or SSL value in row: {row}")
except IOError as e:
print(f"[ERROR] Could not read input file: {e}")
return targets
def load_ioc_list(path: Optional[str]) -> List[str]:
if not path:
return DEFAULT_IOCS
try:
with open(path, 'r') as f:
return [line.strip() for line in f if line.strip() and not line.startswith("#")]
except IOError as e:
print(f"[ERROR] Failed to read IOC file: {e}")
sys.exit(2)
def main():
parser = argparse.ArgumentParser(
description="CVE-2025-31324 SAP Scanner with IOC detection (multi-target supported)",
formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument("--input", "-i", help="CSV file with targets (host;port;ssl)", required=True)
parser.add_argument("--iocfile", help="Path to file with IOC filenames (one per line)")
parser.add_argument("--verbose", "-v", action="store_true", help="Enable debug output")
parser.add_argument("--output", "-o", help="Output CSV file for aggregated report")
args = parser.parse_args()
targets = parse_targets_from_file(args.input)
if not targets:
print("[ERROR] No valid targets loaded.")
sys.exit(2)
ioc_list = load_ioc_list(args.iocfile)
results = []
for idx, target in enumerate(targets, start=1):
print(f"[INFO] Scanning target: {target.label}")
scanner = Scanner(target, iocs=ioc_list, verbose=args.verbose)
vulnerable, backdoors, online = scanner.run_scan()
print_boxed_result(idx, target, vulnerable, backdoors, online)
results.append((target, vulnerable, backdoors, online))
if args.output:
export_csv_aggregate(args.output, results)
if any(vuln or backs for _, vuln, backs, _ in results):
sys.exit(1)
else:
sys.exit(0)
if __name__ == "__main__":
main()