# TryHackMe Blog WriteUp

### Tryhackme Blog Writeup <a href="#tryhackme-blog-writeup" id="tryhackme-blog-writeup"></a>

Hello Again :)

### **Reconnaissance and Enumeration** <a href="#reconnaissance-and-enumeration" id="reconnaissance-and-enumeration"></a>

as usual, we start with scanning the machine

**nmap scan**

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FLC7GaIK0wzqz37qeg5rG%2Fimage.png?alt=media&#x26;token=d36cb73f-fea5-4cb9-8a79-9eff705f5040" alt=""><figcaption></figcaption></figure>

we have 4 ports open, ssh, http, and samba, its a good practice to check ftp, samba or nfs before going to the web server.

**samba enumeration**

i will use `smbclient -L [IP HERE]` to check for avilable shares.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FmD9ijeKR8G27IpakIqtO%2Fimage.png?alt=media&#x26;token=41719a95-3e23-4fc1-9183-0182764118d2" alt=""><figcaption></figcaption></figure>

found BillySMB, we connect to the share.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FIFyloOcqXzWPIaWvBo00%2Fimage.png?alt=media&#x26;token=bd44a982-5c37-4002-b8a4-4106c6c0b43f" alt=""><figcaption></figcaption></figure>

found three files, we can extract them by using `get FILE_NAME`. lets check them!

check-this.png

[![image](https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2F2oSMBtiJDv56Z65PV7Hk%2F1%204.png?alt=media)](https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2F2oSMBtiJDv56Z65PV7Hk%2F1%204.png?alt=media)

if you scan it you will go to this link <https://www.youtube.com/watch?v=eFTLKWw542g> :)

Alice-White-Rabbit.jpg

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FrSR0R7sXsJHQ36iOyLzi%2Fimage.png?alt=media&#x26;token=51ba2838-763f-48d2-adad-bf5263c165ff" alt=""><figcaption></figcaption></figure>

nothing important

tswift.mp4

also nothing important

**web enumeration**

now lets check the webpage

the page is struggling to load which is weird, as in the description “you’ll need to add blog.thm to your /etc/hosts file”

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FmRRA7H6LHVBZe9Yu1r2z%2Fimage.png?alt=media&#x26;token=66c106f2-dfb2-4116-8ecc-c5dd9d32a071" alt=""><figcaption></figcaption></figure>

the flag -a in tee means you append what you pipe into it, without it the file will be wiped.

we find a blog (obviously), its powered by wordpress.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FD4f4eEg2C3s3eTayD72Y%2Fimage.png?alt=media&#x26;token=6786bba6-07b5-43d4-857a-4781f7b7b0e0" alt=""><figcaption></figcaption></figure>

since its powered with wordpress and we can access the admin panel, i will use wpscan to scan for usernames.

the command:

```bash
wpscan --url http://blog.thm/ --enumerate u
```

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FQbgHEAi1mm92Ez3CweW0%2Fimage.png?alt=media&#x26;token=6e7710ed-1f2e-4019-95df-d935213c79e8" alt=""><figcaption></figcaption></figure>

the wordpress version is 5.0, we could use this later or search for a CVE. we found two users: kwheel and bjoel, now its time to get the passwords, i will create a file named “users.txt” with the usernames in it.

the command:

```bash
wpscan -U users.txt -P /usr/share/wordlists/rockyou.txt --url http://blog.thm
```

success!!! we found the password for kwheel

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2Fys7ZF7oooEARFXVcU3vd%2Fimage.png?alt=media&#x26;token=0a3c34e2-7e57-4ce8-957e-c51ff6e455d8" alt=""><figcaption></figcaption></figure>

we try the credentials to access the admin panel and bingo we’re in!

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2F385CBf8u27UACe7HoDmI%2Fimage.png?alt=media&#x26;token=0cae1071-c174-49d3-a70a-927c0b91d129" alt=""><figcaption></figcaption></figure>

***

### **Initial Access:** <a href="#initial-access" id="initial-access"></a>

**CVE-2019-8943**

now lets search for a cve. we know from the wp scan the wp version is 5.0.

we find in exploit db CVE-2019-8943 named Crop-image Shell Upload, which is already has a script for it in metasploit framework!

to access metasploit just type in the terminal:

```bash
msfconsole
```

we edit the options, type exploit, and we are in!!!

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2F0LBFejkbqRP4EtLiwu0t%2Fimage.png?alt=media&#x26;token=272757b3-8878-4d89-8835-1f430d10588d" alt=""><figcaption></figcaption></figure>

to find the user flag i will use the command :

```bash
find / 2>/dev/null | grep user.txt
```

well it’s not the right file.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FLAdlO2Mc2uekIN1lZfg5%2Fimage.png?alt=media&#x26;token=f7495e5d-a36f-4e91-8338-c740fa1fbfb4" alt=""><figcaption></figcaption></figure>

***

### **Privilege Escalation:** <a href="#privilege-escalation" id="privilege-escalation"></a>

instead of looking for the user flag lets look for a way to escalate our privileges. i used this command to search for binary SUID’s.

```
find / -perm -u=s -type f 2>/dev/null
```

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FmKf5zCxUEEoW6A8fox0w%2Fimage.png?alt=media&#x26;token=664f7e45-92f5-49cf-88c9-6801ab1f111e" alt=""><figcaption></figcaption></figure>

alot of these are common, but /usr/sbin/checker is not, lets check it out.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FxALHeAP8ADdDZgdu5JsJ%2Fimage.png?alt=media&#x26;token=c8922d15-fc47-46b3-8052-642d103e7ef0" alt=""><figcaption></figcaption></figure>

the binary checkes whether the user is admin or not.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2F1TFKjmUe33FiJugAWtEF%2Fimage.png?alt=media&#x26;token=2bc64a20-5a28-4635-92c3-4d8a0694ae8d" alt=""><figcaption></figcaption></figure>

to check how this tools works, i will use `ltrace` which captures any library calls and prints it out for us! it seems checkes if the user is admin or not by reading an environment variable named “admin”.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FnSPJYyckPWVjc00BXfoQ%2Fimage.png?alt=media&#x26;token=53b79ca1-e44c-4d0b-90eb-8877d801ea9a" alt=""><figcaption></figcaption></figure>

so we can exploit this if we set an environment variable , export admin=1

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FGSmDRlifQIzsKwYOAjq3%2Fimage.png?alt=media&#x26;token=2bee2f94-e797-4b5f-996a-9629d46ca64a" alt=""><figcaption></figcaption></figure>

**root.txt**

success we are root!

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2Ftff42mtdL0lvxhunXj27%2Fimage.png?alt=media&#x26;token=2345acfd-bf92-4512-8de0-bf9c9bc01289" alt=""><figcaption></figcaption></figure>

**finding user.txt**

we go back to find the user flag, so we search for it again since we own the machine now.

<figure><img src="https://421213191-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfUOAAeVs9eihqxcrtvIC%2Fuploads%2FmrDf34KNwjQLPq8ycsiJ%2Fimage.png?alt=media&#x26;token=c1ee76f6-8fbf-46ba-8093-3dd7ada5a8df" alt=""><figcaption></figcaption></figure>

now the machine is pwned.

happy pwning :)
