Microsoft FTP.exe - Passive Mode Does Not Work

Need help with FileZilla Server? Something does not work as expected? In this forum you may find an answer.

Moderator: Project members

Post Reply
Message
Author
User avatar
MoonUnitZappa
550 Permission denied
Posts: 27
Joined: 2013-03-28 01:36
Contact:

Microsoft FTP.exe - Passive Mode Does Not Work

#1 Post by MoonUnitZappa » 2013-03-28 02:57

Hello FileZilla Forums :)

Simple problem:

All PCs [client and server] in use are inside my LAN [10.2.101.0/24]
I use MS-WXP-SP3 + FTP.exe as Client
and MS-WXP-SP3 + FZ 0.9.41 as Server.

Command in use on client is: FTP -s:ftp.txt [Use FTP with script file ftp.txt]

ftp.txt:

Code: Select all

open x.x.x.104
/username/
/password/
literal pasv
put file.txt
quit
When I run this simple script I find that the data channel is initiated by the Server not the Client.

This is the traffic I see:

Code: Select all


Control channel
Client               Server
x.x.x.173:1234  ->>  x.x.x.104:21   [Syn packet TO the Server]

Data Channel
Client               Server
x.x.x.173:1236  <<-  x.x.x.104:20   [Syn packet FROM the Server]

Using passive mode I was expecting to see all TCP connections being initiated by the Client and none by the Server.

I have captured the packets and FZ logfile but I have not posted them as the problem is so easy to replicate I thought I would just let you try it for yourselves but I will post the files if required.

The packet capture clearly shows the SYN packet sent from the server initiating the data channel and the FZ log shows that the transfer took place in passive mode.

However, even though I have specified PASV it has not done what I was expecting.

Please forgive me if I have misunderstood this, am I doing something wrong or have I forgotten something :?:

Thanks
Last edited by MoonUnitZappa on 2013-03-28 12:24, edited 1 time in total.
Definition: Politics -- Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers
Power .. Cutting a long cable short.

User avatar
boco
Contributor
Posts: 25241
Joined: 2006-05-01 03:28
Location: Germany

Re: FZ Server 0.9.41 Beta - Passive Mode Does Not Work

#2 Post by boco » 2013-03-28 04:48

Yes, you fell for a myth.

The FTP.exe included in Windows does NOT support Passive mode and never has. These 'quote PASV' or 'literal PASV' commands are dummy, they actually don't do anything.

The reason is simple: Sending PASV is only the first step. Then the client would have to interpret the PASV response from the server to get IP and port and build a data connection.
It doesn't do for two reasons.
1. FTP.exe doesn't know how to handle PASV and PASV responses at all.
2. Replies to commands sent via literal or quote are generally ignored.

But FTP.exe does something completely different. As soon as you send dir, get, put (translate to LIST, RETR, STOR), it sends a PORT command. PORT switches the server back to Active mode.


If you want to check yourself type debug at the FTP.exe prompt. It will then show all actual FTP commands it sends.
### BEGIN SIGNATURE BLOCK ###
No support requests per PM! You will NOT get any reply!!!
FTP connection problems? Do yourself a favor and read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
### END SIGNATURE BLOCK ###

User avatar
MoonUnitZappa
550 Permission denied
Posts: 27
Joined: 2013-03-28 01:36
Contact:

Re: Microsoft FTP,exe - Passive Mode Does Not Work

#3 Post by MoonUnitZappa » 2013-03-28 12:24

Thanks for your reply boco - and "what" a reply !

After all these years Microsoft still manages to disappoint me ! :evil:


Topic amended to reflect the real culprit :D

Having seen my requirement , can FZ Client do a scripted background run ?



Thanks
(Donation on the way)
Definition: Politics -- Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers
Power .. Cutting a long cable short.

User avatar
MoonUnitZappa
550 Permission denied
Posts: 27
Joined: 2013-03-28 01:36
Contact:

Re: Microsoft FTP,exe - Passive Mode Does Not Work

#4 Post by MoonUnitZappa » 2013-03-28 13:59

MoonUnitZappa wrote: Having seen my requirement , can FZ Client do a scripted background run ?
Read in another thread:
boco wrote:No, such a ''watchdog'' feature is not implemented. FileZilla is intended to be used interactively and thus doesn't contain advanced automation features.
OK .. Thanks
Definition: Politics -- Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers
Power .. Cutting a long cable short.

User avatar
boco
Contributor
Posts: 25241
Joined: 2006-05-01 03:28
Location: Germany

Re: Microsoft FTP.exe - Passive Mode Does Not Work

#5 Post by boco » 2013-03-29 01:23

Maybe you should take a look at lftp.

ftp://gd.tuwien.ac.at/gnu/gnu-win32/release/lftp/

lftp-4.4.4-1.tar.bz2 is the one you want.

It is in an unusual (for Windows) archiving style (.tar.gz), but it contains a Windows executable. That one is a full blown scriptable command line FTP. It may not use the same syntax like FTP.exe, however.

You could also search for ncFTP, but I'm not allowed to link this here as it is commercial (though Freeware).
### BEGIN SIGNATURE BLOCK ###
No support requests per PM! You will NOT get any reply!!!
FTP connection problems? Do yourself a favor and read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
### END SIGNATURE BLOCK ###

User avatar
MoonUnitZappa
550 Permission denied
Posts: 27
Joined: 2013-03-28 01:36
Contact:

Re: Microsoft FTP.exe - Passive Mode Does Not Work

#6 Post by MoonUnitZappa » 2013-03-29 14:35

Great - thanks for your help :)
Definition: Politics -- Latin, from poly meaning many and tics meaning blood sucking parasites -- Tom Smothers
Power .. Cutting a long cable short.

xscream100
500 Command not understood
Posts: 2
Joined: 2015-10-06 23:52
First name: Dick
Last name: Ranger

Re: Microsoft FTP.exe - Passive Mode Does Not Work

#7 Post by xscream100 » 2015-10-07 00:03

In Windows 10 (and from what I've read, Windows 7+), the native FTP client will work with a passive FTP server. I tested this using a FileZilla FTP server configured to allow a slight variation in IP addresses: FileZilla Server Options ==> Security settings ==> Relaxed IP match. The more secure setting will cause problems. In the Windows FTP client, you need to issue the command QUOTE PASV after logging into the server but before issuing any commands like ls, get, or put although cd will work without QUOTE PASV. So, whether Windows FTP will work with all the passive FTP servers out there depends on how restrictive those FTP servers are when it comes to IP matching.

However, NCFTP for Windows is much better than the Windows FTP client.

User avatar
boco
Contributor
Posts: 25241
Joined: 2006-05-01 03:28
Location: Germany

Re: Microsoft FTP.exe - Passive Mode Does Not Work

#8 Post by boco » 2015-10-07 01:16

ftp> debug
Debugging On .
ftp> help
Commands may be abbreviated. Commands are:

! delete literal prompt send
? debug ls put status
append dir mdelete pwd trace
ascii disconnect mdir quit type
bell get mget quote user
binary glob mkdir recv verbose
bye hash mls remotehelp
cd help mput rename
close lcd open rmdir
ftp> open 10.0.0.1 2121
Connected to 10.0.0.1.
220-FileZilla Server 0.9.53 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220-Please visit http://sourceforge.net/projects/filezilla/
220 IPv6 connections are enabled on this server.
---> OPTS UTF8 ON
202 UTF8 mode is always enabled. No need to send this command.
User (10.0.0.1:(none)): boco
---> USER boco
331 Password required for boco
Password:
---> PASS *******
230 Logged on
ftp> quote PASV
---> PASV
227 Entering Passive Mode (10,0,0,1,173,237)

ftp> dir
---> PORT 10,0,0,108,194,106
200 Port command successful
---> LIST
150 Opening data channel for directory listing of "/"
<snip>
226 Successfully transferred "/"
ftp: 1578 bytes received in 0.19Seconds 8.53Kbytes/sec.

ftp> _
Re-checked with Windows 10 ftp.exe (Build 10558).
See the red part first. Here's that mystic "quote PASV" ("literal PASV" does the same) command sent, the server transmits the PASV response, which is completely ignored.
Now look at the blue part. The user-issued "dir" command sends an FTP PORT command and switches back to Active Mode. The following LIST is using Active Mode entirely.

So it's still the same: No Passive Mode support in ftp.exe. The actual reason why that myth exists is that some routers/firewall change their behavior when they detect a PASV command That's got nothing to do with Passive Mode support, though.
### BEGIN SIGNATURE BLOCK ###
No support requests per PM! You will NOT get any reply!!!
FTP connection problems? Do yourself a favor and read Network Configuration.
FileZilla connection test: https://filezilla-project.org/conntest.php
### END SIGNATURE BLOCK ###

xscream100
500 Command not understood
Posts: 2
Joined: 2015-10-06 23:52
First name: Dick
Last name: Ranger

Re: Microsoft FTP.exe - Passive Mode Does Not Work

#9 Post by xscream100 » 2015-10-07 02:01

I tried Windows FTP with a couple of public FTP servers using QUOTE PASV. Didn't work. So, better to use NCFTP for command line FTP in Windows and avoid the hassle of Windows' ancient FTP client.

Post Reply