The Rabbit Hole

See you in a couple days

Last Sunday evening, I fell into a rabbit hole. My original plan was to attack another host with a service vulnerability without using a walkthrough. Instead of scanning each host one-by-one, I decided to that running a mass scan against all the IPs would be more efficient. So I started to generate the list.

Unfortunately I have a fatal flaw. I have a hamartia when it comes to tedious tasks: if there is an interface to automate what would normally be done with hundreds of manual actions, I will attempt to automate the task. It's not that I hate clicking buttons; I just can't resist the allure of finding a more efficient way of solving a problem - even if the process of finding it is significantly less efficient. Xkcd's graphic has been a good guide for me to find balance, but sometimes I let loose a little and slide down the rabbit hole. ![is_it_worth_the_time.png](/assets/media/therabbithole/is_it_worth_the_time.png)

I attempted to mine Hack The Box’s website for IPs to scan. I saved the machine list webpage, beautified it, then ran something like grep -E -O '([0-9]{1,3}\.){3}[0-9]{1,3}' machinelist.html

An early attempt to mine target IPs

Easy enuff. But what if one of the machines’ change? Then all that time spent scanning would be wasted without correlating it to a live target. I needed a way to link the IP back its name on the website. Unfortunately, Grep does not like HTML. I explored Sed and followed this guide) halfway before attempting to use Sed for extracting the machine name and IP from the downloaded HTML file.

It turned into something of a clusterfk.

So I tried awk but quickly noped out on this route.

Finally Python saved the day!

playing_with_python2.png

Then Hack The Box updated their machine list page, so I had to dig through the HTML again to find Grepabble patterns. Eventually, Frankenstein’s monster lived: cat machinelist.html | grep -E -B 4 "([0-9]{1,3}[\.]){3}[0-9]{1,3}" | grep -A 4 "Created by" | grep -E "(Created by)|(([0-9]{1,3}[\.]){3}[0-9]{1,3})" | python strip_html.py | grep -E '.+'

But as luck would have it, Hack The Box just updated their VM system to automatically expire. So I lost my window to scan all the boxes. On the bright side, I learned a bit of Bash, Sed, and Python and might be able to shave 20 minutes off on the OSCP exam.

Time to get back to hacking.

*****
Written by Nibs on 03 July 2019