Skip to content

Instantly share code, notes, and snippets.

@aravindkumarsvg
Last active May 27, 2024 10:31
Show Gist options
  • Save aravindkumarsvg/67b05d15f29501efce6948319ad6874d to your computer and use it in GitHub Desktop.
Save aravindkumarsvg/67b05d15f29501efce6948319ad6874d to your computer and use it in GitHub Desktop.
Stabilize a reverse shell for linux target

Pre-requisites

  • Get the reverse shell in netcat
  • check python support in the target system
which python

Shell Stablization

  1. If your terminal is using zsh, then you need to switch to bash
exec bash --login
ps -p $$ # check whether bash is the current shell for the terminal
  1. spawn bash using python
python -c 'import pty;pty.spawn("/bin/bash")'
  1. background the netcat listener using CTRL+Z
  2. GET the terminal of host
echo $TERM
  1. Get the dimensions of host terminal and note down the rows,columns length
stty -a
  1. Type the following command in host terminal
stty raw -echo
fg # which gets the netcat listener to foreground
reset # might be you'll be asked to enter terminal type, input will be from step 3
  1. In the netcat listener psuedo terminal, enter the commands
stty rows <rows_length_from_step_4> columns <columns_length_from_step_4>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment