---
description: Pg Practice Sorcerer writeup
---

# Sorcerer

## Nmap

```
sudo nmap 192.168.150.100 -p- -sS -sV                                                                                                                                                                                              1 ⨯

PORT      STATE SERVICE  VERSION
22/tcp    open  ssh      OpenSSH 7.9p1 Debian 10+deb10u2 (protocol 2.0)
80/tcp    open  http     nginx
111/tcp   open  rpcbind  2-4 (RPC #100000)
2049/tcp  open  nfs_acl  3 (RPC #100227)
7742/tcp  open  http     nginx
8080/tcp  open  http     Apache Tomcat 7.0.4
43329/tcp open  nlockmgr 1-4 (RPC #100021)
45519/tcp open  mountd   1-3 (RPC #100005)
54375/tcp open  mountd   1-3 (RPC #100005)
55683/tcp open  mountd   1-3 (RPC #100005)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

## HTTP

We have HTTP running on ports 80,8080 and 7742. I set to work running `feroxbuster` against all three ports before manually browsing to them.

```
./feroxbuster -u http://192.168.150.100:<port> -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
```

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-a4e48957ff37c79be88cb5fa7f6931774f2bf81d%2Fimage.png?alt=media)

Port 80 shows a page with only '404 not found' displayed. Port 8080 takes us to Apache Tomcat/7.04.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-e915b77899710b728650906511587cfc9df26c0f%2Fimage.png?alt=media)

The link for the Manager App did not ask for authentication credentials like it normally does. It does provide us with a Access Denied page and also display the Tomcat default credentials of `tomcat:s3cret`.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-41deb9f4a5fbeff0ff615f6e2dae1f5d75144bc3%2Fimage.png?alt=media)

We can store these later and possibly run these credentials against `nikto` or `gobuster` to see if we can enumerate further directories if required.

Port 7742 takes us to the following logon page which contains no identifying information apart from the name 'SORCERER' in the browser tab.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-1bb69d51aa8aec165d5d34be86d06ddbb552bde3%2Fimage.png?alt=media)

Soon after `feroxbuster` picks up the /zipfiles/ directory. On browsing to this we find the following files.

![http://192.168.150.100:7742/zipfiles/](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-4afca0a7ca5db40de47a5b59f0ceedb4edf8f682%2Fimage.png?alt=media)

I downloaded the zip files which are not encrypted and browsed through each with the GUI. The max.zip folder contained the most interesting information.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-5858e142275c1d22bb73c951dde08cc37e4fda05%2Fimage.png?alt=media)

The Tomcat files contains credentials for Tomcat.

```
  <role rolename="manager-gui"/>
  <user username="tomcat" password="VTUD2XxJjf5LPmu6" roles="manager-gui"/>
</tomcat-users>
```

We also have `SSH` keys for Max.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-d18e2f4e01ea473cb96fa4a11a0fcb91a8e0138a%2Fimage.png?alt=media)

I changed the permissions of the id\_rsa file to 600 so we can use it for SSH.

```
chmod 600 id_rsa 
```

Looking at the authorized keys files we can see that the file scp\_wrapper.sh is being used as a force command when a user connecting to `SSH`.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-aafc0777e95c685f7c751d78892798453c4fbbb6%2Fimage.png?alt=media)

The contents of scp\_wrapper.sh

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-968f23f7c8b395493b829f67e5bcdc61417e9561%2Fimage.png?alt=media)

This means when connect as the user max to SSH we can only execute commands that start with 'scp'. As `SCP` runs over `SSH` we can use use id\_rsa file from Max to connect and overwrite the wrapper file with something more useful such as 'bash' instead of 'scp'.

I edited the scp\_wrapper.sh file to include the command 'bash' and changed the error message for troubleshooting purposes.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-201d97dbe64a4f99ea27a9fb0a8a1e550fd29f04%2Fimage.png?alt=media)

I then moved Max's 'id\_rsa' key into my SSH folder on /home/kali/.ssh/ in preperation for connecting to SCP.

Once completed connect by SCP and transfer over the wrapper file on our desktop.

```
scp /home/kali/Desktop/scp_wrapper.sh max@192.168.196.100:/home/max/scp_wrapper.sh
```

We can then SSH in as max and will have a bash shell.

```
ssh max@192.168.196.100  
```

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-f0cbeacca7fe5eb76c4aa0735392d2997bcc2269%2Fimage.png?alt=media)

Upgrade the shell:

```
/usr/bin/script -qc /bin/bash /dev/null
```

Straight away I uploaded `linpeas.sh` after starting a `Python SimpleHTTPServer` on my attacking machine and executed once downloaded.

`Linpeas` soon picks up the SUID bit being set on /usr/sbin/start-stop-daemon.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-c8342912855aeb18e81d8e621f235d5aae9e87f7%2Fimage.png?alt=media)

A search on[ GTFObins](https://gtfobins.github.io/gtfobins/start-stop-daemon/) shows we can spawn a root shell.

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-c6a524998de05d5cec120c16b0aaa924b939dd76%2Fimage.png?alt=media)

Exploit syntax:

```
/usr/sbin/start-stop-daemon -n $RANDOM -S -x /bin/sh -- -p
```

![](https://1600278159-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MFlgUPYI8q83vG2IJpI%2Fuploads%2Fgit-blob-ab871b417730e8fc085e70233862f25616e75a80%2Fimage.png?alt=media)
