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

BountyHunter HackTheBox Walkthrough

lehanfayaz

Meme Strategist
L Rep
0
0
0
Rep
0
L Vouches
0
0
0
Vouches
0
Posts
120
Likes
122
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
Bounty hunter is a CTF Linux machine with an Easy difficulty rating on the Hack the Box platform. So let’s get started and take a deep dive into disassembling this machine utilizing the methods outlined below.

Pentesting Methodology

Port Scanning and Enumeration

  • nmap
  • abusing http
  • dirb

Exploitation

  • burp suite

Privilege Escalation

  • ssh
  • user flag
  • ticket validator
  • root flag

Level: Easy

Port Scanning and Enumeration

To begin, we’ll perform nmap scan to look for open ports. As can be seen, two ports are open:

  • Running the ssh service on port 22.
  • Port 80 is used to run the http service.

Code:
nmap -sC -sV 10.129.95.166

AVvXsEith68kLW358XBWg8QjhKOraOLIH2tCQ6rFJ1gsgkC6k3K5JoPp1nJ5f3vlOYq91hnrOquofbHcH5fybdBQ7G1bFaikcEt8m2nqgC8_qSiz3wjz9ndxEqfA42hGRkTO8cWMi72lZFzYSLxn0rqdCTBEHuU5UDSna5yIQ9FYWAaa4iqzHW6PJA14Bcqqyg=s16000


Let’s take a look at the IP address in a browser. Nothing appears to be of interest on the main page. As a result, we examined its subdirectory “portal.”

AVvXsEjm2btimJULuEreB7LIBz6bMYUGNUuTFiw6Xsx9fMXGVSE5_iMrr_5CYow45I5dboQm11pjIn-1EyilBVwwotLISIaehs72ZfHvOOCyLZNwbVruW-rfxs8wvJh55Z8JbJFLy1ApjFjQ234iRxF3_12MMfGvhgEH0QXaSqtGYGiiP4vgaoYAEUmP-gMMFQ=s16000


When we examined the portal subdirectory. It notes that it is still in the development phase and provides a URL to test this lab environment.

AVvXsEgbmQSQgFHFRKNtS1hXSZa3vyCA-gX7p8TJOl8eqO_d4Y5XO4BiyeqM6RElUzs5pwBvqj8Pe60ufB8b--zOffmR0JhiwvnGElssWGqQ023GDdfT9vHxgUbHkWVZ-6rcZv3Ro-uKotwVJ72aJzoJl_POXtpiu_4QgAV_mdtL0RpaMRZf98wfzWhxcYcMhw=s16000


It is still in development, which means there is a good chance it will be vulnerable.

We discovered a form where we may enter a value and the data will be saved elsewhere. However, it eventually appears to be a beta version report submission system.

AVvXsEhZDfsf8MmoMdTaBcxVolcYfHSvBc4MbZRHwC7_A7yXhtp15i2UpASZ4o5JuzCnFBJd-_WZAVC0dGOrhfExiPsocXezUwEXZq_lLpXjrIOdXXHbrARyAGPVxAlqwwOdhX0XDUnaRSV4mTGUbWtMKfudtL39kdS5zOgn8L8mS7ZQuBhTZnUOs6HwpkiSvg=s16000


Except for the bounty logs in javascript, it appears to be a standard html page script. So, in order to progress in this machine, we verified this page.

AVvXsEjNcQtVzAXX6EJypXl2ItAGR-jhWLlhJv9eGwrCko-jzZE9jwFAHq1f6CSPb-591-H3b-7o4wrJxdsRlFNo8ch9p9P3eMdbsZ-mS7YPxO3qJ0bjRuCiY0KUrfN8A4dwDCcPwqkd0bRK0qvZ2QUDL32RBDUGzM2hRZ3lWRSuMMZeV9fC9DCLme5xVaMLtA=s16000


We discovered a form where we may enter a value and the data will be saved elsewhere. When we look at the page source, we can see that the website is built with XML.

As a result, we may conclude that this webpage is susceptible to XXE (XML external entity).

AVvXsEiZg0EBklHzIROgvDbJSFZY27q2eYWHvjpJYao8mQSWyLo0syHPhV30OvCS3OvSlmuK7IeOC5jSxwl8w9qOL_OV3JXCKI-zhI1uYad-4ko6864-AoKe63T49N7Gd2MvvR48BvC8bCLk07a322PPdE-q95iTUOvKKXcxRWLD0fVSeDhU7FB7te59WEc7qQ=s16000


So we used dirb, a directory brute force, to find out more information about this system. Except for the db.php file, nothing intruding was discovered.

Code:
dirb http://10.129.95.166 -X .php

It signifies that there is a database file available in which all of the data will be stored.

AVvXsEg-gmEtQuaEZR55c22e8F75YsuEUed03lPxvsDZ5_EBzFiFlmer50JWn5JZFR1YVnWRG_55XGdrtY8ZUhAx8WOB8HLaKIKyirtqOUwqbaffQGNK8lxaA6yH0MF_J8w-lPTwRW9wbyMdQDeQJC1Ky5BoeC5NvHdL_tn7Yjqai2TTANHIdPC9VZA6WE9d7g=s16000


Exploitation

We will now begin our exploitation procedure with the burp suite. Try to capture its data by submitting a request for a more in-depth investigation. As a result, we used similar strategies on the beta version of the Bounty Report submission page.

I noted in the request that our recorded data appears to be encoded.

AVvXsEhZYBHoY41EteCZZxKvkZHnmLiaXfshEAJdJo9rJGooTvUs-0GmHFIPWhIKJMkHlwNiueDK46FK4I6nfXd8WK_INmiscYh-VOFSEy1xqoeB-GxqrKWhsI9G9butpH-H9CzD57bYnNcyy7QvmQy6uH2eq4ErxYQA4S-d5j5eGNW5Tls328kGxXboyw5VvQ=s16000


To check the encoded technique, we switch the tab to decoder for cracking this encryption. We learned here that it is encoded in base64.

AVvXsEhtC7ZKt6S6oEdc1WaUghb1rHDQ8swXi2JDoTsy424wAIVFDc25fICisAnndIcz0LNX4WxB5gQ40du_-0fwLOonF3NLb5yw0aSYuwNSC49JUt9qDghiefgKIBYbC8yk6Lc42ii63xu9E8XxuEiGxiwRiGQT2EBnOwKzKRR6xD0h-w-Tvxuve3codPRkkw=s16000


We have now transformed this string into a browser-readable format. We dropped that request in order to acquire a response from the destination. As you can see, we received an encoded answer from the target machine.

AVvXsEghQf_nK2sZl-r4Nqeb9bMoy6cMtqHXk-5zmd26sruFacyfzZCF6Ty0mFLvYhR_wwFdI97Gdh08urq6NFEXiJJ01Jjn1zyELsjeiHZQaeT2t16DkG6hKHVjWrV8VaNBQ8So0pbSORxqpR7OxFxYEhKSIkrw8p4ATzeCEICLK0gmJrEkfAgFy_HOrFwvPg=s16000


Again we switched tab to decoder to analyze the response from the target machine. Thankfully we got some valuable information about the database.

Code:
dbserver = "localhost"
dbname = "bounty"
dbusername = "admin"
dbpassword = "m19RoAU0hP41A1sTsq6K"

AVvXsEjInj-7vYOrJo1AqARhb4NB2EjGu-RT4Mno6bkmTSo1YhHe-CReG5sbFI9tmWTxzWFmcy1Pv01pSHzY1KLunoXzeBVoXePHxAyYndd1bWur52vFbE9EL0AFq72QpRcZ2MhgiDiME9eDhSCtC7oBxQ_NtNeeXfoPEbiibjkDkc0-SdYNZ23awnus3YOB8g=s16000


This information was then utilised to log into the system. kaboom!! We successfully logged into the system. We proceed to the decoder tab and attempt to request the /etc/passwd file using this mechanism must obtain its encoded value in order to request this file from the target machine.

AVvXsEj0kHojm2Yp96h6MeS28F0gjAJ_7qxl21CKISOsRDUYGuLdyXYgYpfTk5LKmb0nLxdQhzhXFx_JwqM0Mq6qZ-s6xBx7cRb5VHspPwI5WQJlKYyKBjBRtsurfWfvsNDhPkvpvNIMWGaxjNX0kb0E6OC1o1as5rCAzT-_LTUwaY2wMLqf6jhVve4q84GfKg=s16000


We received a response from the destination machine after forwarding this request. Obviously, it is encoded, thus we must decode it in order to understand it.

AVvXsEi-ltymTzeA2kPNTkNuC1FEQqZdR3HfVMzX4m4pptU_dWEuR5DS-uH6d6hLXmFPsvV0ycl4_rQCcuz1DsFlt1Rjffr1OifYXWqpims27I-paCKBd2YStQzO14NRwiumnugp4cNKB4F7OG03v8uaBvNI3j26LIh9IxA11Ub6Mpi3DKlKbGNd6dyguw4vNg=s16000


We immediately attempt to decode it and received the desired results from that request. After examining, we discovered that we had username: development.

AVvXsEgbcujIbjusir0FNo7z-5o8uOXo1ZnUgEq_9rNG1VguAVNdS8i6FFNfNaBpMjIVsBURrfoh7TiCy-m23hkwDzGn8KmsPU9zgSho232Y3BPBpK7zNv-1nAT8A-Pss2IvEDLVGCs_duYdztfx9glQwc6Ox0abCbpT76k4SKfBWs1xaCahWFK84bWDXg9hbg=s16000


Privilege Escalation

We have credentials, and we know that ssh is operating on port 22. Now is the optimal moment to begin the privilege escalation process using an ssh login with the password which we got earlier.

Code:

We successfully logged into the development and immediately we checked its id to verify its details. Searching for a little bit we found the user flag.

Code:
cat user.txt

AVvXsEi12-lTXyxuz4WFFLIhTt9ZPfyyzDQLT7BjxotbJWcwMckNLR8heq7wSAKK4p5kiZLrzsGvqdE9xQUI3dvEjAre9NNDf0DtcRNgo6dswePFu_2hnngGLlo9W2TgIUGnHK2TfeGxhGeJIvoiSNN-0Mn2G5mI9vz1-eUFbauEmohKC7lylYQrlwxQ9hllaQ=s16000


Following that, we double-checked this user’s permissions. We discovered that we could root this machine by abusing the ticketvalidater.py file.

Code:
sudo -l

So, we reviewed this file to analyse it, and we got some points, but nothing exciting came out of it.

AVvXsEgd4-oS2Hq_JHuXotuftreCRXA73n-bVUmG9lN5hyD0Qp3WD0HJ4KlBesil_guB72FqjBJFXbmAsEnZu_twB57CR6yE-RRNoMizMckjmUSdXnkhoBvyrrLiwo0es2PgOWURWxXrBetJrauM-9B5RPm-R2Rguyf_ICSBeCXEx9vAwTPHqQsZcul5TqDTUA=s16000


We got some aid from here after analysing it for a while. We stressed that the key to root this machine is highlighted by us upwards.

That aided us in understanding that the script first calls load file, which was already defined. This simply checks to see if the file ends with .md and exits if it does not. Next, evaluate is called, which has many checks. Essentially, it goes over it line by line, with a new check for each one.

We created our ticket code using that information and put it in a file (file.md).

Code:
cat file.md

After that, we use sudo to run the ticket validator file, passing it the location to the ticket file (file.md).

Code:
sudo /usr/bin/python3.8 /opt/skytrain_inc/ticketValidator.py
/home/develpment/file.md

Yippee!! We found the root. We immediately went to the root directory and received our well-deserved root flag.

AVvXsEg4-57qknNZOHwiy9jXjdgBD7xWsuWgO7ssnmiYcA72WalkuqTjgCv0Zwv-0yPLmMZn8kKB3VifCDEEnWFaOwUnkPLYf-LswWECGoKTTWtn5W6c30QXicn4D9GDSl7OszAv8iAvRePkiTZc6pYeXOgJf2DBNHG3f0pwraISYrQtZ9sSavtIT4G_ejsiTQ=s16000


There are a few things we should take note of. If you’re familiar with XXE Injection, this is a simple level box to complete, Privilege Escalation was a breeze, and Burp Suite is a true Swiss army knife tool. This box will be very useful to understand these concepts.

Author: Shubham Sharma is a passionate Cybersecurity Researcher, contact LinkedInand Twitter.
 

440,010

316,559

316,568

Top