Vulnerable API App
Target Details
Target IP: 10.10.149.135
Service Discovery
Scan Open ports using nmap
Services Found:
SSH
22
OpenSSH 8.2p1
nginx HTTP
80
/1.18.0
Web Service
5000
Unknown
Answer the Task questions
Content Discovery
Visit the web application in browser
Common endpoints are /api or api.domain.com,
/api worked!
We can find other endpoints by manually by crawling through the web application with burpsuite proxy running
On inspecting the html, the admin has left a message in webpage comment for the hacker!
from comment we can make conclusion that, we cannot directly sign up from the login page, we need to find api endpoint to sign up. admin has also provided hint to the endpoint for users sign up
On visiting
/api/users
endpoint, we get json response, providing information about other users!!We got user details names, user Id and their role while using the application
In most of the cases, endpoint supports various http methods, let's verify it using
OPTIONS
method. Let's visit the same users enpoint and send the request to repeater this time, and change HTTP method fromGET
toPOST
On visiting
dmdhrumilmistry
GitHub Profile repos, Vulnerable-API-App app.py file, we can retrieve all the endpoints from the file. The useful ones for now are listed below.Endpoints Discovered using burpsuite
/api/users/
DELETE, HEAD, OPTIONS, GET
/api/users
POST, OPTIONS, HEAD, GET
Exploit Endpoints
from
/api/user/<userid:int>
endpoint we can get user details, from/api/users
endpoint we can retrieve admin user id and try to get their account details. For my case admin id is27
.admin id will vary
Send Burp Request to
/api/user/27
, we'll receive json response asUsing first question hint, we know that we need to send
Hide-Info
header in the HTTP request.Burp Request
Burp Json Response
Now we've received token
We can add token in BurpSuite every request using Custom Header Extension, Refer docs for installation and usage, then add authorization token to extension.
Now, Add
http://10.10.149.135:5000
, and capture in scope requests only.configure Custom Header extension to add header while using proxy using
Project Options
Sessions
From Session Handling rules click on add button
provide description
Click on Add button from Rule Actions
Choose
Invoke Burp Extension
Set extension handler to
Add Custom Header
Click on OK
From Scope tab, click on Proxy checkbox to add headers while using proxy. Also set URL scope to set Suite Scope
Click on OK
Visit HomePage
http://10.10.149.135:5000
Get Target Machine Shell
Visit HomePage, with login admin auth token
From HomePage, visit Admin Controls tab, from where we can run bash commands
Using GTFObins Bash Reverse Shell get access to reverse shell
Start Netcat on attacker's machine
Enter below command in command input field
On Execution of command, we get a reverse shell on the attacker machine
Get User Flag
Read User Flag
Privilege Escalation
Checking if
vulnadmin
has sudo permissionsvulnadmin
has sudo permission, but first we need to find its password to run sudo commandOn Listing Files in
vulnadmin
home directory, we find abackup.txt
fileOn Reading file, it seems to be encoded in base64 format
Decode backup.txt file
It's password for
vulnadmin
accountTo run sudo command we need to spawn terminal first, since the deployed application is running flask which is a python framework, python must be installed which can be verified using
Get Interactive Shell
List commands which can be run as with root privileges by
vulnadmin
Get Root Flag
We've successfully Rooted the machine!!
Last updated