FTP detection in active or passive mode

In particular, for Twisted, I would like to be able to determine whether the server to which I am connected is active or passive. See the API .

If someone can explain or give an example in the FTP protocol, how can you determine if the server supports active or passive modes.

+3
source share
1 answer

Passive mode is activated by issuing a command to the PASVserver. If after issuing this command it responds with an error code (should be 500 Unknown command), then you know that it is not supported. If he answers with help 227 Entering Passive Mode, then you know that passive is supported.

telnet FTP :

% telnet ftp.mozilla.org 21
Trying 63.245.208.138...
Connected to dm-ftp01.mozilla.org.
Escape character is '^]'.
220-  [greeting omitted]
USER anonymous
331 Please specify the password.
PASS jathanism@
230-  [banner omitted]
230 Login successful.

( ):

PASV
227 Entering Passive Mode (63,245,208,138,202,53)

(500 ):

FART
500 Unknown command.
+4

Source: https://habr.com/ru/post/1761584/


All Articles