C.反壳问题

C.反壳问题,c,shell,reverse,scp,C,Shell,Reverse,Scp,我需要设置一个反向外壳,以便连接到通过GPRS调制解调器连接到internet的设备 当特殊情况发生时,我在具有固定ip的公共服务器上启动此命令 nc -l 65535 然后我将运行这段代码(现在我通过电缆直接连接到设备进行测试)(是的,在这种情况下fork是无用的,但在最后的场景中我需要它,所以我保留了它) 另外,我需要使用scp,但消息会不断出现在设备提示上,而不是反向连接的服务器上 反向连接服务器: [root@public-server tmp]# nc -lv 65535 Conne

我需要设置一个反向外壳,以便连接到通过GPRS调制解调器连接到internet的设备

当特殊情况发生时,我在具有固定ip的公共服务器上启动此命令

nc -l 65535
然后我将运行这段代码(现在我通过电缆直接连接到设备进行测试)(是的,在这种情况下fork是无用的,但在最后的场景中我需要它,所以我保留了它)

另外,我需要使用
scp
,但消息会不断出现在设备提示上,而不是反向连接的服务器上

反向连接服务器:

[root@public-server tmp]# nc -lv 65535
Connection from yyy.yyy.yyy.yyy port 65535 [tcp/*] accepted
ls /etc/hosts
/etc/hosts
scp /etc/hosts xxx.xxx.xxx.xxx:/tmp/
Host key verification failed.
lost connection
root@device:/tmp# ./a.out
root@device:/tmp# The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is aa:e6:aa:1d:aa:a5:c2:fd:aa:4c:4f:e7:aa:34:aa:78.
Are you sure you want to continue connecting (yes/no)?
设备提示:

[root@public-server tmp]# nc -lv 65535
Connection from yyy.yyy.yyy.yyy port 65535 [tcp/*] accepted
ls /etc/hosts
/etc/hosts
scp /etc/hosts xxx.xxx.xxx.xxx:/tmp/
Host key verification failed.
lost connection
root@device:/tmp# ./a.out
root@device:/tmp# The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established.
RSA key fingerprint is aa:e6:aa:1d:aa:a5:c2:fd:aa:4c:4f:e7:aa:34:aa:78.
Are you sure you want to continue connecting (yes/no)?

要解决这个问题并获得一个稳定且可用的反向shell,我该怎么做?

问题是您的shell只获得一个普通的文件描述符。这样,它只能像执行脚本一样运行。要以交互方式操作,它需要一个终端,允许它执行所有termios操作。这就是伪终端(
pty
)的用途。一个快速的谷歌搜索出现了,我没有完全阅读它,也许有更好的来源——祝你好运


PS:我没有使用
pty
s的经验,因此这可能是错误的,但我认为在启动shell之前,您应该以某种方式将客户端上的
TERM
环境变量设置为服务器的变量,因此建议您实现自己的服务器(而不是
nc
)在启动shell时使用一点初始化协议。

根本不起作用。已设置连接,但没有输入/输出