请教:这个反弹shell为啥无法使用Ctrl+C

sh/bash/dash/ksh/zsh等Shell脚本
回复
头像
jiandan23
帖子: 94
注册时间: 2010-12-17 22:31
系统: Mint 19.2

请教:这个反弹shell为啥无法使用Ctrl+C

#1

帖子 jiandan23 » 2024-07-24 8:55

========Server端=========

代码: 全选

[root@server ~]# socat TCP-LISTEN:5566 EXEC:/bin/bash,stderr,pty,ctty

========Client端=========

代码: 全选

[root@client ~]# stty raw -echo && nc server 5566
bash: no job control in this shell
[root@client ~]# sleep 10m
^C^C^C^C

这个反弹shell可以使用↑↓键查看历史命令,但是无法使用Ctrl+C杀掉进程。我用strace跟踪socat,可以看到socat已经收到了<Ctrl+C>按键:

[root@server ~]# strace -e trace=read,write -p $(pidof socat)
strace: Process 25253 attached
read(6, "\3", 8192) = 1
write(5, "\3", 1) = 1
read(5, "^C", 8192) = 2
write(6, "^C", 2) = 2

请教在此反弹shell中,为啥Ctrl+C无法杀掉前台进程,有解决办法没?
头像
astolia
论坛版主
帖子: 6703
注册时间: 2008-09-18 13:11

Re: 请教:这个反弹shell为啥无法使用Ctrl+C

#2

帖子 astolia » 2024-07-24 9:36

jiandan23 写了: 2024-07-24 8:55 请教在此反弹shell中,为啥Ctrl+C无法杀掉前台进程
因为这个
jiandan23 写了: 2024-07-24 8:55 bash: no job control in this shell

jiandan23 写了: 2024-07-24 8:55 有解决办法没?

代码: 全选

socat TCP-LISTEN:5566 EXEC:/bin/bash,stderr,pty,ctty,setsid
头像
jiandan23
帖子: 94
注册时间: 2010-12-17 22:31
系统: Mint 19.2

Re: 请教:这个反弹shell为啥无法使用Ctrl+C

#3

帖子 jiandan23 » 2024-07-25 8:26

Perfect,感谢大佬再次解决了我的问题!
头像
yq-ysy
论坛版主
帖子: 4643
注册时间: 2008-07-19 12:44
来自: 广西(桂)南宁(邕)

Re: 请教:这个反弹shell为啥无法使用Ctrl+C

#4

帖子 yq-ysy » 2024-07-25 11:21

jiandan23 写了: 2024-07-25 8:26 Perfect,感谢大佬次解决了我的问题!
这个“”字是重点。 :Smile
回复