Spawning Interactive Reverse Shell

hidepatidar
3 min readAug 3, 2021

--

first using this command and check which languge installed on system

if you have python or python3 so continue with python or python3 if you have install perl so continue with perl

this example for python

$ which python

1. python and python3 pty shell……………..

now select command according to installed languge i am continue with python

python -c 'import pty; pty.spawn("/bin/sh")'python -c 'import pty; pty.spawn("/bin/bash")'python3 -c 'import pty; pty.spawn("/bin/bash")'perl -e 'exec "/bin/sh";'

2. put the shell into background

using ctrl+z put shell on background

Ctrl-Z

3. current terminal and STTY info

echo $TERM
stty -a

4. Set the current STTY to type raw and tell it to echo the input characters

stty raw -echo

5. Foreground the shell with fg and re-open the shell with reset

$ fgreset

6. stty size to match our current window

$ export SHELL=bash$ export TERM=xterm256-color$ stty rows 37 columns 146$ bash -i

7. Set PATH TERM and SHELL if missing

$ 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]\$ '

enjoy now you have fully interactive shell

:)

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response