TO MAKE REVERSE SHELL INTERACTIVE
RUN THESE ON THE REVERSE SHELL OBTAINED
which python
# OR
which python3
python3 -c 'import pty;pty.spawn("/bin/bash")'
python -c 'import pty;pty.spawn("/bin/bash")'
PRESS CTRL + Z
(lil bit counter intuitive)(that ctrl z will force the netcat listner to go in background basically the reverseshell window will go behind and your terminal window will come upfront to put the next commands required)
stty raw -echo; fg
PRESS ENTER TWICE TO GET BACK # (your rc will be interative)
command to specify the rows & columns of the reverse shell
export SHELL=bash
stty rows 50 columns 211
or
stty rows 81 columns 87 #(give this command on the reverse shell so obtained)
export TERM=xterm-256color
script -q /dev/null bash
rest everything will be the same
CTRL Z
and then
stty raw -echo; fg
PRESS 'ENTER' TWICE TO GET BACK
Note: don't forget to set environment (if you use script cmd)
export TERM=xterm-256color
pty - fake terminal (get this when take ssh connection)
tty - terminal tag
python3 -c 'import pty;pty.spawn("/bin/bash")'
python -c 'import pty;pty.spawn("/bin/bash")'
Press CTRL + Z
- Print current terminal settings
stty -a | head -n1 | cut -d ';' -f 2-3 | cut -b2- | sed 's/; /\n/'
- Switch to raw mode and resume the shell
stty raw -echo; fg
-
Type 'reset' and press CTRL + D
Setting specific environment variables for SHELL, TERM, and PATH.
export SHELL=bash
export TERM=xterm-256color
- Set terminal rows and columns (Replace and with your terminal dimensions)
stty rows 37 columns 146
- Start an interactive bash shell
bash -i
- Additional environment configurations and PS1 assignment
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export TERM=xterm
export SHELL=bash
cat /etc/profile; cat /etc/bashrc; cat ~/.bash_profile; cat ~/.bashrc; cat ~/.bash_logout; env; set
export PS1='[\u@\h \W]\$ '