SSH 跳过袜子(4/5)代理链。主机 -> 袜子代理 -> 袜子代理 -> 目的地

mnm*_*mnc 6 ssh ssh-tunneling socks netcat

之前关于通过位于AMachineC上的 Socks 代理从 Machine 连接到 Machine 的问题得到了很好的答案B

说 Machine B Ip is218.62.97.105并且它正在侦听端口 1080

为此的命令:

ssh -o ProxyCommand='socat - socks:218.62.97.105:HOST_C:21,socksport=1080'

我想知道是否有可能从袜子代理制作一条链。

考虑场景:机器 A->机器 B(Socks 代理 1)->机器 C(Socks 代理 2)->机器 D(目的地)

机器B IP:218.62.97.105端口1080

机器 C IP:11.11.11.11端口3128

机器 D IP:55.55.55.55端口8080

我希望有人对 socat 或任何其他工具有经验,因为此时对我来说似乎很复杂。

+100 给任何可以给我工作答案的人。


socat 1 命令的调试:

2012/10/02 20:45:00 socat[15641] D read -> 8
2012/10/02 20:45:00 socat[15641] D received socks4 reply data (offset 0): 00 5c 00 50 c1 6b 90 17
2012/10/02 20:45:00 socat[15641] D received all 8 bytes
2012/10/02 20:45:00 socat[15641] I received socks reply VN=0 CD=92 DSTPORT=80 DSTIP=193.107.144.23
2012/10/02 20:45:00 socat[15641] E socks: ident refused by client
2012/10/02 20:45:00 socat[15641] N exit(1)
2012/10/02 20:45:00 socat[15641] I shutdown(4, 2)
2012/10/02 20:45:00 socat[15641] D shutdown()  -> 0
2012/10/02 20:45:00 socat[15641] I shutdown(3, 2)
2012/10/02 20:45:00 socat[15641] D shutdown()  -> 0
2012/10/02 20:45:00 socat[15638] I childdied(signum=17)
2012/10/02 20:45:00 socat[15638] D waitpid(-1, 0xbfbea3fc, 1)
2012/10/02 20:45:00 socat[15638] D waitpid(, {256}, ) -> 15641
2012/10/02 20:45:00 socat[15638] I childdied(17): cannot identify child 15641
2012/10/02 20:45:00 socat[15638] D saving pid in diedunknown1
2012/10/02 20:45:00 socat[15638] W waitpid(): child 15641 exited with status 1
2012/10/02 20:45:00 socat[15638] D waitpid(-1, 0xbfbea3fc, 1)
2012/10/02 20:45:00 socat[15638] D waitpid(, {256}, ) -> -1
2012/10/02 20:45:00 socat[15638] I waitpid(-1, {}, WNOHANG): No child processes
2012/10/02 20:45:00 socat[15638] I childdied() finished
Run Code Online (Sandbox Code Playgroud)

socat 第二个命令:

2012/10/02 20:44:38 socat[15640] D socket(2, 1, 6)
2012/10/02 20:44:38 socat[15640] I socket(2, 1, 6) -> 3
2012/10/02 20:44:38 socat[15640] D fcntl(3, 2, 1)
2012/10/02 20:44:38 socat[15640] D fcntl() -> 0
2012/10/02 20:44:38 socat[15640] D connect(3, {2,AF=2 127.0.0.1:22222}, 16)
2012/10/02 20:44:38 socat[15640] D connect() -> 0
2012/10/02 20:44:38 socat[15640] D getsockname(3, 0xbf8111cc, 0xbf811058{112})
2012/10/02 20:44:38 socat[15640] D getsockname(, {AF=2 127.0.0.1:40843}, {16}) -> 0
2012/10/02 20:44:38 socat[15640] N successfully connected from local address AF=2 127.0.0.1:40843
2012/10/02 20:44:38 socat[15640] I sending socks4 request VN=4 DC=1 DSTPORT=21 DSTIP=xx.xxx.xxx.xxx USERID=mnmnc
2012/10/02 20:44:38 socat[15640] D malloc(42)
2012/10/02 20:44:38 socat[15640] D malloc() -> 0x8f1ec80
2012/10/02 20:44:38 socat[15640] D sending socks4(a) request data 04 01 00 15 3e f4 9f 9a 6d 6e 6d 6e 63 00
2012/10/02 20:44:38 socat[15640] D write(3, 0xbf811304, 14)
2012/10/02 20:44:38 socat[15640] D write -> 14
2012/10/02 20:44:38 socat[15640] I waiting for socks reply
2012/10/02 20:44:38 socat[15640] D read(3, 0xbf811234, 8)
2012/10/02 20:45:00 socat[15640] D read -> 0
2012/10/02 20:45:00 socat[15640] E read(): EOF during read of socks reply, peer might not be a socks4 server
2012/10/02 20:45:00 socat[15640] N exit(1)
2012/10/02 20:45:00 socat[15640] I shutdown(3, 2)
2012/10/02 20:45:00 socat[15640] D shutdown()  -> 0
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)

Sté*_*las 5

和:

socat tcp-listen:12345,reuseaddr,fork,bind=127.1 socks:218.62.97.105:11.11.11.11:3128,socksport=1080
Run Code Online (Sandbox Code Playgroud)

您将有一个 socat 在环回接口上的端口 12345 上等待 TCP 连接,并通过 218.62.97.105:1080 上的袜子服务器将它们转发到 11.11.11.11:3128

然后您可以使用它连接到 D:

ssh -o ProxyCommand='socat - socks:127.1:%h:%p,socksport=12345' -p 8080 55.55.55.55
Run Code Online (Sandbox Code Playgroud)

(未经测试)