# 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="/files/4mTVjBC9EFveNKTL9Mzo" 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="/files/l86P5fXZc6bHhzikiQCT" alt=""><figcaption></figcaption></figure>

found BillySMB, we connect to the share.

<figure><img src="/files/sMXmOxfyorM1YgXVGS3R" alt=""><figcaption></figcaption></figure>

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

check-this.png

[![image](/files/1Kx76yyDEE2nE7oeKVEQ)](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="/files/aW57Ugw7bRLVjXxMXbzj" 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="/files/1Uk7IPoUq15SvWIhLahC" 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="/files/k3vmyMX3CjcKHOeS3w1O" 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="/files/vsnW6sGW0xs2f2sXxJ6e" 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="/files/1lf6hSLYthBQKSU3qQE6" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/OpadE87mtY5FKclGTFKa" 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="/files/elHcqSwtpsRdqh7rR60b" 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="/files/hxN3GY4um09IlQpsxOhE" 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="/files/nVrnnWZppO1F1bMlh9Kk" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/pOR89JqyC5NUjD01HjZF" alt=""><figcaption></figcaption></figure>

the binary checkes whether the user is admin or not.

<figure><img src="/files/ktjRj3GRxhybKjntIofK" 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="/files/RzYOvRpW8OBingr4Q91B" alt=""><figcaption></figcaption></figure>

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

<figure><img src="/files/eYinpKrHr6O0lU17h7rq" alt=""><figcaption></figcaption></figure>

**root.txt**

success we are root!

<figure><img src="/files/ELLdeH2hPo2R4Wj935RU" 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="/files/Mf0nDpVgwyhu6L54KbeE" alt=""><figcaption></figcaption></figure>

now the machine is pwned.

happy pwning :)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://h0t.gitbook.io/h0t/boxes/tryhackme/tryhackme-blog-writeup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
