2010-03-31 4 views
0

libnet 및 libpcap을 사용하여 C에 프로그램을 작성하여 RSH 클라이언트로 가장하고 RSHD를 실행하는 서버 시스템에 자체 명령을 주입합니다."ACK"패킷 내에서 RSH 데몬에 쉘 명령을 전달

알다시피, 명령은 ACK 패킷의 '페이로드'에 있어야하지만 형식에서는 RSHD가이를 쉘에 전달합니다. 이를 달성하기 위해

어떻게 패킷을 조립해야합니까?

답변

1

일반 rsh 클라이언트에서 네트워크 패킷 덤프 (tcpdump, tshark 등)를 시도하십시오. 누구에게 관심이 있습니다

+0

나는 그것을했다.하지만 내 문제는 정상적인 rsh 클라이언트 세션을 시뮬레이트하고 싶지 않다. 서버와의 TCP 핸드 셰이크 중에 명령을 ack 패킷에 포함하고 싶다. – Hippopotamus

+0

tcpdump에서 얻을 수있는 패킷 페이로드의 형식. ACK는 패킷 헤더의 플래그 일뿐입니다. – osgx

0

.

rsh를 통해 연결 (syn-syn, ack-ack)을 설정하면 연결이 ESTABLISH 상태가되고 모든 요청이 다른 포트로 이동하므로 rshd가 더 많은 연결을 처리 할 수 ​​있습니다.

내 문제는 마지막으로 "ACK"패킷에 명령을 전달하는 방법이었다. "ack"패킷 자체는 데이터 패킷이므로 "페이로드"필드에서 명령을 전송할 수 있습니다.

"사람은 rshd"인용의 비트 :

 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 바이트까지의 첫 번째 문자가 보조 연결의 포트 번호로 해석됩니다. 하지만 보조 연결이 필요하지 않으므로 명령 시작 부분에 "0 \ 0"을 넣습니다. 다음 # 5, # 6에 의해 분리 NUL의 클라이언트 컴퓨터와 서버 컴퓨터의 사용자 이름을 지정. 그래서 나는 널이 "0 \ 0username1 \ 0username2 \ 0command \ 0"그래서 결국 내 명령이고, 명령이 될 수있을 종료 있다고한다 "0 \ 0username1 0username1 \ 0 \"그리고 # 7에 넣어.