Created
November 5, 2020 18:02
-
-
Save kezzyhko/857339ed00f583419d93e5756ab984f0 to your computer and use it in GitHub Desktop.
Bruteforce profile ids on your moodle to find them all
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
set_time_limit(0); | |
define('COOKIES', [ | |
'MoodleSession' => 'lz7udac381k24ot9i6d7e7zdmf' //of course, you need to change this to you auth token | |
]); | |
define('URL', 'https://moodle.example.com/user/profile.php?id=%d'); //and change this to your moodle address | |
$context = stream_context_create(['http' => [ | |
'method' => 'GET', | |
'header' => 'Accept-language: en' . PHP_EOL . | |
'Cookie: ' . http_build_query(COOKIES, '', '; ') . PHP_EOL . | |
'' | |
]]); | |
echo '<pre>'; | |
for ($i = 0; $i < 1000; $i++) { | |
$url = sprintf(URL, $i); | |
$html = file_get_contents($url, false, $context); | |
$matches = []; | |
preg_match('/<title>(.*)<\/title>/', $html, $matches); | |
printf('%5d | <a href="%s">%s</a><br>', $i, $url, $matches[1]); | |
//htmlspecialchars($html) | |
flush(); | |
} | |
echo '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment