C 将shell命令传递给一个";“确认”;小包裹

C 将shell命令传递给一个";“确认”;小包裹,c,libpcap,libnet,rshd,C,Libpcap,Libnet,Rshd,在C上编写一个程序,使用libnet和libpcap模拟RSH客户机,并在运行RSHD的服务器机器上注入我自己的命令 据我所知,该命令应该在ACK数据包的“有效载荷”中,但格式是RSHD将其传递给shell 我应该如何组装数据包来实现这一点?尝试从正常rsh客户端获取网络数据包转储(使用tcpdump、tshark等)。可能与之相关 通过rsh建立连接(syn syn,ack ack)后,连接进入建立状态,所有请求都将移动到另一个端口(因此rshd可以进一步处理更多连接) 我的问题是如何在最后一

在C上编写一个程序,使用libnet和libpcap模拟RSH客户机,并在运行RSHD的服务器机器上注入我自己的命令

据我所知,该命令应该在ACK数据包的“有效载荷”中,但格式是RSHD将其传递给shell


我应该如何组装数据包来实现这一点?

尝试从正常rsh客户端获取网络数据包转储(使用tcpdump、tshark等)。

可能与之相关

通过rsh建立连接(syn syn,ack ack)后,连接进入建立状态,所有请求都将移动到另一个端口(因此rshd可以进一步处理更多连接)

我的问题是如何在最后一个“ack”数据包中传递命令。“ack”数据包本身就是一个数据包,因此可以在“payload”字段中传输命令

《man rshd》中的一段话:

所以。在#3中,据说NUL字节之前的第一个字符被解释为辅助连接的端口号。但是我不需要辅助连接,所以我在命令的开头添加了“0\0”。 接下来#5和#6指定客户端机器和服务器机器的用户名,以NUL分隔。所以我把“0\0username1\0username1\0”
在#7中,据说可以有一个以null结尾的命令,因此我的命令最后是“0\0username1\0username2\0command\0”。

我这样做了,但我的问题是我不想模拟正常的rsh客户端会话-我想将该命令包含在ack数据包中,在与服务器的tcp握手期间。可以从tcpdump获得的数据包有效负载的格式。ACK只是数据包头中的一个标志
      The server reads characters from the socket up to a NUL (`\0') byte.
      The resultant string is interpreted as an ASCII number, base 10.

 3.   If the number received in step 2 is non-zero, it is interpreted as
      the port number of a secondary stream to be used for the stderr.  A
      second connection is then created to the specified port on the
      client's machine.
      ...
 5.   A null terminated user name of at most 16 characters is retrieved on
      the initial socket.  This user name is interpreted as the user iden-
      tity on the client's machine.

 6.   A null terminated user name of at most 16 characters is retrieved on
      the initial socket.  This user name is interpreted as a user iden-
      tity to use on the server's machine.

 7.   A null terminated command to be passed to a shell is retrieved on
      the initial socket.  The length of the command is limited by the
      upper bound on the size of the system's argument list.