Creds >>

TryHackMe – https://tryhackme.com/p/TheSysRat

HackTheBox (aka TheSysRat)

Recon >>>

nmap >>

Web site >>

We can find DNS record to http://site.empman.thm/ (/etc/hosts …)

If is there subdomain “site” we can probably found another.

Subdomain – Vhosts >>>

And we can found one other backup so let’s try it.

And we found ImageMagic.zip file, after unzip ne can found note NEWS.txt.

In the notes is accord release version 7.0.7-17. So it is exploitable? And yes.

So what is using ImageMagic, basicly that program is used for manipulation with pictures. Let’s look around and focuse on web site.

So we can create new account >>

And we can edit account and change avatar so that could be a way.

Exploitation >>>

For easier usage I found a script to make LFI.

https://github.com/Sybil-Scan/imagemagick-lfi-poc

Long story short, basicly we send a poisoned image, that image is containe lfi address, after processing image (probably resize), we can download output image, read and decode to our exploitation. So let’s do it.

Check with exiftool >>

And upload to server >>

And there is our output >>

So let’s check if output is correct >>

And YES, in the end of output is hex dump >>

After decode there is our file /etc/passwd >>

And we can found there a user emp, so we can try if a user have a ssh.

And yes, we can found it >>

So let’s try ssh connection >>

User flag is done !!


Root path >>

After running linpeas.sh and sudo -l we can found this interesting thing >

So look on script >>

There is a library cbackup and really interesting is a PYTHONPATH set to /dev/shm. So let’s hijack python library >>

Prepare >>

And after minute there is a root shell >>

So docker root flag is done!


So can we escape from docker container?

Enumeration >>

For enumeration I used great deepce tool >>

https://github.com/stealthcopter/deepce

So there is a way and it is Groups …. root ! We can escape to real machine via reverse shell >>

So we need run listener on port what you wont.

And we can upload and run escape script >>

More information about this escape from docker container >>

https://0xdf.gitlab.io/2021/05/17/digging-into-cgroups.html

After that we will get a vagrant user shell and we escape from docker!

Last flag was found!

Happy hacking!!

Leave a Reply

Your email address will not be published. Required fields are marked *