brook icon indicating copy to clipboard operation
brook copied to clipboard

socks5 server does not work correctly with ftp

Open cmcm951102 opened this issue 4 years ago • 2 comments

Environment

  • Brook Version:Brook version 20200201
  • Server Operating System: CentOS release 5.5
  • Server Operating System Version: Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
  • Server Operation System Language: en_US.UTF-8
  • Client Operating System:
  • Client Operating System Version:
  • Client Operation System Language:

Expected Behavior

Use ftp client to connect vsftp server through an brook socks5 proxy

Current Behavior

ftp client can not List folder

Steps to Reproduce

1.start a vsFTPd 3.0.2 server on A 2.start an brook raw sock5 server on B 3.use Xftp client to connect vsFTPd server through sock5 server on B 4.it will fail when listing folder

Detailed Description

brook socks5 server works well most of the time but ftp. I have tried some other socks server, it work correctly! so I thought that maybe brook socks5 server has some problem when process ftp tranffic.

Here's some logs for Xftp: STATUS:> Session started... STATUS:> Connecting to the server '192.168.6.15' (proxy : 172.16.6.10-2)... 220 (vsFTPd 3.0.2) STATUS:> Authenticating for 'admin'... COMMAND:> USER admin 331 Please specify the password. COMMAND:> PASS **** 230 Login successful. COMMAND:> PWD 257 "/home/uftp" STATUS:> Listing folder '/home/uftp'... COMMAND:> CWD /home/uftp 250 Directory successfully changed. COMMAND:> PWD 257 "/home/uftp" COMMAND:> TYPE A 200 Switching to ASCII mode. COMMAND:> PASV 227 Entering Passive Mode (192,168,6,15,203,222). COMMAND:> LIST 150 Here comes the directory listing. 226 Directory send OK. 421 Timeout. ERROR:> Listing folder failed. STATUS:> Listing folder '/home/uftp'... COMMAND:> CWD /home/uftp ERROR:> Listing folder failed. STATUS:> Changing to the folder '/home/uftp'... COMMAND:> CWD /home/uftp STATUS:> Current connection closed.

Here's some debug info for brook: brook_linux_386 -d socks5 -l :9999 -i 172.16.6.10 2020/04/29 22:23:37 Got NegotiationRequest: 0x5 0x1 []byte{0x0} 2020/04/29 22:23:37 Sent NegotiationReply: 0x5 0x0 2020/04/29 22:23:37 Got Request: 0x5 0x1 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xf} []byte{0x0, 0x15} 2020/04/29 22:23:37 Call: 192.168.6.15:21 2020/04/29 22:23:37 Sent Reply: 0x5 0x0 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xa} []byte{0xd0, 0x94} 2020/04/29 22:23:37 Got NegotiationRequest: 0x5 0x1 []byte{0x0} 2020/04/29 22:23:37 Sent NegotiationReply: 0x5 0x0 2020/04/29 22:23:37 Got Request: 0x5 0x1 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xf} []byte{0x74, 0xa} 2020/04/29 22:23:37 Call: 192.168.6.15:29706 2020/04/29 22:23:37 Sent Reply: 0x5 0x0 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xa} []byte{0xb5, 0x9b} 2020/04/29 22:24:23 Got NegotiationRequest: 0x5 0x1 []byte{0x0} 2020/04/29 22:24:23 Sent NegotiationReply: 0x5 0x0 2020/04/29 22:24:23 Got Request: 0x5 0x1 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xf} []byte{0x0, 0x15} 2020/04/29 22:24:23 Call: 192.168.6.15:21 2020/04/29 22:24:23 Sent Reply: 0x5 0x0 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xa} []byte{0xd0, 0x96} 2020/04/29 22:24:33 Got NegotiationRequest: 0x5 0x1 []byte{0x0} 2020/04/29 22:24:33 Sent NegotiationReply: 0x5 0x0 2020/04/29 22:24:33 Got Request: 0x5 0x1 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xf} []byte{0xcb, 0xde} 2020/04/29 22:24:33 Call: 192.168.6.15:52190 2020/04/29 22:24:33 Sent Reply: 0x5 0x0 0x0 0x1 []byte{0xc0, 0xa8, 0x6, 0xa} []byte{0xd2, 0xaa}

I also captured some traffic, I'll send it to you if necessery.Thanks. :)

Possible Solution

cmcm951102 avatar Apr 30 '20 08:04 cmcm951102

Good format issue, socks5 has three command, CONNECT, UDP, BIND. ftp need socks5 supports BIND, this command is todo status now

The socks5 library finished CONNECT and UDP, but BIND is not finished. https://github.com/txthinking/socks5/blob/master/bind.go

txthinking avatar May 01 '20 02:05 txthinking

Good format issue, socks5 has three command, CONNECT, UDP, BIND. ftp need socks5 supports BIND, this command is todo status now

The socks5 library finished CONNECT and UDP, but BIND is not finished. https://github.com/txthinking/socks5/blob/master/bind.go

Got it~ I hope you complete it soon. Thanks for your great work!

cmcm951102 avatar May 01 '20 02:05 cmcm951102

No activity for a prolonged period, temporarily closed. Still accepting commits or pull requests.

txthinking avatar Jan 14 '24 11:01 txthinking