Skip to main content

Instant Walkthrough(Hack The Box)

·499 words·3 mins·
Medium Linux Hack the Box Hacking Web Android Walkthrough
Table of Contents

Reconnaissance
#

  • During the initial scan, we identified two open ports:

Port 80 (HTTP) - Web Server

Port 22 (SSH) - Secure Shell

Pasted image 20241222223503.png

  • Upon accessing the web application, we noticed an option to download a mobile app, which was available in two places on the site.
    Pasted image 20241222223731.png
  • Clicking on the button initiated a download for an application named instant.apk.
    Pasted image 20241222223929.png

Enumeration
#

  • To analyze the Android application, I downloaded and used jadx to decompile the Java code.
    Pasted image 20241222224706.png
  • While recursive grepping the files grep -r "instant" I got admin jwt token
    Pasted image 20241222222123.png
  • Additionally, I found multiple API endpoints, including a Swagger API documentation page. Definition Swagger UI transforms JSON or YAML files into interactive interfaces that simplify the navigation and testing of endpoints. Its advantages include: Enhanced Interactivity: Allows developers to test methods (GET, POST, PUT, DELETE) and view parameters in real time.

Pasted image 20241222224908.png

  • when I access it I can see all beautiful endpoints.
    beautiful
  • Upon accessing the Swagger UI, I could see all the available API endpoints. One particularly interesting endpoint allowed reading system logs. Exploiting this, I was able to read /etc/passwd and retrieve system user information.
    Pasted image 20241222231821.png

Exploitation
#

  • By leveraging the API vulnerability, I requested access to shirohige’s private SSH key stored at:
/home/shirohige/.ssh/id_rsa
  • After cleaning the key, I used it to log in via SSH:
ssh -i id_rsa -vl shirohige instant.htb 

Pasted image 20241222233027.png

  • Got the
    User flag
    Pasted image 20241222233106.png

Privilege Escalation
#

  • While exploring the system, I discovered an SQLite database file named instant.db in:
/projects/mywallet/Instant-Api/mywallet/instance
  • Upon inspecting the database, I found a table containing usernames and hashed passwords.

  • The hashes were generated using Werkzeug hashing.

  • I started cracking the hashes to retrieve plaintext passwords.

  • Additionally, I found backup files of Putty sessions stored in the /opt directory. These session files contained encoded credentials. By using the SolarPuttyDecrypt tool, I was able to decrypt the stored credentials.

Pasted image 20241223021105.png

  • With the retrieved password, I gained root access.
  • Got the
    Root flag
    Pasted image 20241223021213.png

Summary
#

Initially, my reconnaissance revealed two open ports: 80 (HTTP) and 22 (SSH). Accessing the web server presented an option to download a mobile application, instant.apk. During enumeration, I decompiled the Android application using jadx. By recursively grepping the decompiled code, I uncovered an admin JWT token and several API endpoints, including a Swagger API endpoint. One particularly interesting endpoint allowed reading logs, which I used to view /etc/passwd and identify users. Moving to exploitation, I leveraged the log reading capability to request and obtain the SSH private key for the user shirohige. After some cleaning, I successfully logged in via SSH using this private key and obtained the user flag. For privilege escalation, I discovered an SQLite database file named instant.db in the application’s instance directory. This database contained usernames and Werkzeug-hashed passwords. I proceeded to crack these hashes. Furthermore, I found backups of Putty sessions in the /opt directory. Using the correct password with a tool like SolarPuttyDecrypt, I was able to decode the root password from these session backups. This allowed me to log in as root and retrieve the root flag.

end

Related

Blurry Walkthrough(Hack The Box)
·497 words·3 mins
Medium Linux Hack the Box Hacking Web Walkthrough
Union Walkthrough(Hack The Box)
·934 words·5 mins
Medium Linux Hack the Box Hacking Web Walkthrough
Jarmis Walkthrough(Hack The Box)
·3421 words·17 mins
Hard Linux Hack the Box Hacking Web Walkthrough