0

C でプログラムを作成し、libnet と libpcap を使用して RSH クライアントになりすまし、RSHD を実行しているサーバー マシンに独自のコマンドを挿入します。

私が理解したように、コマンドは ACK パケットの「ペイロード」にある必要がありますが、RSHD がそれをシェルに渡す形式になっています。

これを達成するには、どのようにパケットを組み立てるべきですか?

4

2 に答える 2

1

通常の rsh クライアントから (tcpdump、tshark などを使用して) ネットワーク パケットのダンプを取得してみてください。

于 2010-03-31T22:39:11.470 に答える
0

ご担当者様。

rshを介して接続(syn-syn、ack-ack)を確立した後、接続はESTABLISH状態になり、すべての要求は別のポートに移動されます(したがって、rshdはさらに多くの接続を処理できます)。

私の問題は、最後の「ack」パケットでコマンドを渡す方法にありました。「ack」パケットはそれ自体がデータパケットであるため、コマンドを「payload」フィールドで転送できます。

「manrshd」からの引用:

      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.

それで。#3では、NULバイトまでの最初の文字が2次接続のポート番号として解釈されると言われています。しかし、セカンダリ接続は必要なかったので、コマンドの先頭に「0\0」を入れました。次の#5と#6は、クライアントのマシンとサーバーのマシンのユーザー名をNULで区切って指定します。だから私は"0\ 0username1 \ 0username1 \ 0"を入れましたそして#7にはnullで終了するコマンドがあると言われているので、最後の私のコマンドは "0 \ 0username1 \ 0username2 \ 0command\0"でした。

于 2010-04-02T11:19:27.710 に答える