Stabilize Shell in netcat

netcat is a computer networking utility for reading from and writing to network connections using TCP or UDP. We can use netcat to get the reverse shell from the remote machine. 


A reverse shell is a shell session established on a connection that is initiated from a remote machine, not from the localhost.


A bind shell is a type of shell in which the target machine opens up a communication port or a listener on the victim machine and waits for an incoming connection.

Netcat is a very good tool to receive connections and enumerate further. After connecting to a device, netcat does not provide a lot of shell commands like shell history or shortcuts. To use those commands and stabilize the connection, follow the below steps;


  •  Connecting to the remote shell.
nc <IP> <PORTt>
  • Spawn a remote pseduoterminal.
python -c "import pty; pty.spawn('/bin/bash')"
  • Background your raw shell.
C-z (Ctrl + Z)
  • Set local terminal to raw mode.
stty raw -echo
  • Foreground your remote shell. 

fg


This will give you a full terminal that will not exit on C-c

The added steps to get a reverse shell is repetitive after a while. There is also a danger of losing your remote shell by accidentally pressing “C-c” prior to gaining raw access. 

Pwncat rectifies the problem by running a script on the target machine, which contains all the commands soon after it starts a connection.


CLICK HERE TO KNOW MORE ABOUT PWNCAT


We hope this helps. If any suggestions or doubts you can add a comment and we will reply as soon as possible.

No comments:

Post a Comment