Loose Ends

no funny business

At 14:02 today, I received my PWK/OSCP course email. It contained a 400 page PDF, 800MB of videos, and a connection pack for the lab VPN. After connecting to the lab environment, the first step was clear: use Nmap. It took a while…

Fortunately, this long task could not have happened at a better time. It was like support Shen ulting top while his ADC safely froze the wave at t2. I had to clean up my blog and wrap up the post about my most recent machines (this). In addition, I woke up this morning unprepared for battle because of poor choices last night. I made the proactive decision to invest my fatigued day into completing backlogged/administrative work, knocking out subnet enumeration, and recovering mentally/physically.

So let’s tie up loose ends. Starting tomorrow, I’m pouring 110% into mastering the PWK lab environment. Today, I’m applying my limited brainpower into the last HTB boxes I’ll be looking at for a while.


Granny

Granny was the same thing as Grandpa. Just ran the same 2 exploits,iis_webdav_scstoragepathfromurl and ms10_015.

Bank

Bank was a brainblast for me: it was completely unfamiliar but not hard enough to leave me in the dust. As a n00b Windows admin, I’d never used Linux before the Cyber Shoot. It’s a rapidly shrinking weakness of mine, but I’m almost clueless about exploiting the operating system.

Bank introduced me to exploiting PHP and SETUID special permissions. I also got experience with SSH and DNS chasing rabbits. Unfortunately, Bank was very unfamiliar and CTFy; I didn’t have the experience to complete it without walkthrough clues.

The Nmap scan came back with several red herrings that I greedily chased.

As a n00b, I go for known machine/service exploits first because web exploits take some exploration and creativity to find.

Nothing promising for Apache 2.4.7 that I could figure out. Same with ISC BIND 9.9.5. OpenSSH did have a user enumeration exploit that I played with.

But I found out that Linux doesn’t have default passwords; SSH for these accounts are automatically disabled.

So I played with DNS.

Still nothing. The HTTP website served on http://10.10.10.29 was nothing but a default page. The interesting things were all forbidden.

CLUE 1: bank.htb

At this point, I couldn’t squeeze into any attack surface given to me. I peeked into Infosec’s walkthrough and found that the server served a different site when accessed through its domain name, bank.htb. This was a surprise - I thought that host names were just for translation to IP.

Upon inspection of the packets, I found that the HTTP responses were wildy different:

In retrospect, the different is the Host variable in the HTTP GET request. I’m still communicating the same way over TCP with an IP, but the HTTP layer notably specifies the hostname.

Running Dirbuster against the newly exposed site discovered many pages.

balance-transfer was extremely interesting. It reminded me of the exposed databases in the PicoCTF challenge I did in middle school.

There were hundreds of these in the http://bank.htb/balance-transfer! I pulled them all with Wget then did a bunch of Greping and Googling to see if I could break into one of the accounts.

But this turned out to be a wet, flopping red herring because. Then I tried to exploit these PHP files.

CLUE 2: HTTP 302

I got pretty stuck here because of an information gap. The PHP files would redirect me to the login page because I wasn’t authenticated. I checked Infosec’s walkthrough again for this next step. The PHP pages redirected me to the login pagewith HTTP 302’s, but they still served their pages in the content. I manually edited the response with Burp to prevent the redirection.

After a while of trying to upload a reverse PHP shell through crafted HTTP packets in Burp…

CLUE 3: Read the source code comments

I realized I skipped over an incredibly easy exploit that was in the HTML comments. It basically tells us to upload a PHP shell with .htb extension.

Whoot! User shell! Normally, I would try my best to take it from here but it was late and I had no idea what to do now.

CLUE 4: Look for SUID binaries

I don’t know why I’m calling the walkthrough assists “clues” when I’m basically following steps :/. Anyways, certain binaries have the SETUID permission to allow normal users to execute at that privilege.

Lucky us! Free root shell!

Popcorn (Medium!)

Popcorn was my first Medium solve! This morning, 3 hours before my OSCP course start, I logged into HTB and saw Popcorn pop up with the default machine filter. I usually filter for Incomplete Easy boxes but Popcorn turned out to be a piece of cake!

I have a process now for every new box I tackle. Set up box folder:

Run nmap (don’t have screenshots but it was similar to Bank). Then Dirbuster with some interesting results.

And found a neat Torrent Hoster site in /torrent:

Dirbusting this directory…

My first thought for a PHP site is ‘can I upload and execute a PHP file?’ Turns out yes! I booted up Burp and tried:

Accessed denied :(. I spent a while tinkering with PHP uploads until I went back to the front page and, you guessed it… signed up for an account. Then upload.php worked.

But I couldn’t upload anything except actual torrent files. I tried messing around with a legitimate .torrent file’s exif data to potentially run remote code but didn’t get anywhere with that. Changing the content-type also didn’t provide fruits because the website probably validates file content.

I got kind of stuck here. Learned a lot about basic file upload exploit strategies but nothing that worked.

Clue: Upload malicious file through the torrent’s Submit Screenshot feature.

Interestingly, editting the torrent’s website profile exposed another upload feature for its screenshot:

It worked! I got Msfvenom PHP code onto the server then found its path by refreshing to see the new screenshot.

Conveniently, Popcorn hosted a /rename/ page that offered directions on how to rename local files :P. I followed it.

We’re in boiiiissss

I couldn’t find any exploitable SETUID files so I started trying stuff from Exploit DB that might work. I got lucky with 15285.c.

Popcorn was awesome because it showed that I was getting e1337er; it built on Bank and heavily reinforced my PHP and Linux. I’m proud to have this Medium box in my trophy drawer.


Note: Picking up this blog post after four days of OSCP. Writing about a past event relative to a past moment in present tense for continuity is weird.

My plan for OSCP is to prioritize balance. If I keep my room clean, body fueled, and mind clear, I’ll be able to absorb all the hard trying by just throwing hours into the course material. Happy hack1ng.

*****
Written by Nibs on 20 July 2019