This is a problem since the reverse shell payload presented earlier, and most other reverse shell payloads, echo the input of the user back to the user. The first was the problem of reading the input data of the user without displaying it twice in the terminal. There were two main challenges which I encountered while writing the code.
![shellshock netcat reverse shell shellshock netcat reverse shell](https://img.wonderhowto.com/img/28/48/63667004357437/0/use-command-injection-pop-reverse-shell-web-server.w1456.jpg)
This enabled me to study the differences between the communication resulting from both listeners and deduce what went wrong when something didn’t work. I would run this reverse shell payload on another host and catch it with either netcat or a python script while capturing the network traffic in Wireshark.
![shellshock netcat reverse shell shellshock netcat reverse shell](https://cyruslab.files.wordpress.com/2020/12/image-38.png)
To debug the script, I used the reverse shell payload below. For instance, the script could be used in a more complex script which starts a listener that catches a reverse shell for a regular user, starts another listener, performs a set of privesc commands and then catches a root shell. For example, if an exploit requries multiple listeners, the user of the exploit won’t need to manually start the listeners.
#Shellshock netcat reverse shell code
The reason why it could be nice to be able to catch reverse shells using code rather than the netcat command ( nc) is that it can facilitate automation. As such, I decided to share the solution in a post.
![shellshock netcat reverse shell shellshock netcat reverse shell](https://www.infosecademy.com/wp-content/uploads/2021/01/image-1.png)
However, it turned out to be a bit more complicated than I thought. At first, I thought it would be a piece of cake and would simply be something like reading the user input for a command, sending the command and retrieving the output of the command. This week I wanted to create a listener in python which functioned like the command nc -lp, which is commonly used to catch reverse shells.