Proftpd : Unable to build data connection: Invalid argument

Bonjour,

J’essaye d’utiliser proftpd sur ma debian pour un projet, sans succès.
Voici ma version de debian:

~$ uname -a Linux pc1234 3.16.0-4-686-pae #1 SMP Debian 3.16.7-ckt9-3~deb8u1 (2015-04-24) i686 GNU/Linux

Proftp info:

[code]
~$ sudo proftpd -vv
[sudo] password for blackndoor:
ProFTPD Version: 1.3.3d (maint)
Scoreboard Version: 01040003
Built: Mon Mar 28 2011 22:00:23 UTC

Loaded modules:
mod_ifsession/1.0
mod_unique_id/0.1
mod_facl/0.4
mod_sftp_pam/0.1
mod_sftp/0.9.7
mod_site_misc/1.4
mod_ratio/3.3
mod_shaper/0.6.6
mod_exec/0.9.9
mod_vroot/0.8.5
mod_dynmasq/0.3
mod_wrap2_file/1.2
mod_wrap2/2.0.6
mod_ban/0.5.5
mod_load/1.0.1
mod_rewrite/0.8
mod_wrap/1.2.3
mod_quotatab_radius.c
mod_quotatab_file.c
mod_quotatab/1.3.0
mod_radius/0.9.1
mod_tls/2.4.2
mod_ctrls_admin/0.9.6
mod_lang/0.9
mod_ctrls/0.9.4
mod_cap/1.0
mod_readme.c
mod_auth_pam/1.1
mod_ident/1.0
mod_dso/0.5
mod_facts/0.1
mod_delay/0.6
mod_site.c
mod_log.c
mod_ls.c
mod_auth.c
mod_auth_file/0.8.3
mod_auth_unix.c
mod_xfer.c
mod_core.c[/code]

Mon fichier conf de proftp :

[code]

/etc/proftpd/proftpd.conf – This is a basic ProFTPD configuration file.

To really apply changes, reload proftpd after modifications, if

it runs in daemon mode. It is not required in inetd/xinetd mode.

Includes DSO modules

Include /etc/proftpd/modules.conf

Set off to disable IPv6 support which is annoying on IPv4 only boxes.

UseIPv6 off

If set on you can experience a longer connection delay in many cases.

IdentLookups off

ServerName "Debian"
ServerType standalone
DeferWelcome off

MultilineRFC2228 on
DefaultServer on
ShowSymlinks on

TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200

DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions “-l”

DenyFilter *.*/

Use this to jail all users in their homes

DefaultRoot ~

Users require a valid shell listed in /etc/shells to login.

Use this directive to release that constrain.

RequireValidShell on

Port 21 is the standard FTP port.

Port 21

In some cases you have to specify passive ports range to by-pass

firewall limitations. Ephemeral ports can be used for that, but

feel free to use a more narrow range.

PassivePorts 49152 65534

If your host was NATted, this option is useful in order to

allow passive tranfers to work. You have to use your public

address and opening the passive ports used on your firewall as well.

MasqueradeAddress 1.2.3.4

This is useful for masquerading address with dynamic IPs:

refresh any configured MasqueradeAddress directives every 8 hours

# DynMasqRefresh 28800

To prevent DoS attacks, set the maximum number of child processes

to 30. If you need to allow more than 30 concurrent connections

at once, simply increase this value. Note that this ONLY works

in standalone mode, in inetd mode you should use an inetd server

that allows you to limit maximum number of processes per service

(such as xinetd)

MaxInstances 30

Set the user and group that the server normally runs at.

User root
Group root

Umask 022 is a good standard umask to prevent new files and dirs

(second parm) from being group and world writable.

Umask 022 022

Normally, we want files to be overwriteable.

AllowOverwrite on

Uncomment this if you are using NIS or LDAP via NSS to retrieve passwords:

PersistentPasswd off

This is required to use both PAM-based authentication and local passwords

AuthOrder mod_auth_pam.c* mod_auth_unix.c

Be warned: use of this directive impacts CPU average load!

Uncomment this if you like to see progress and transfer rate with ftpwho

in downloads. That is not needed for uploads rates.

UseSendFile off

TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log

In order to keep log file dates consistent after chroot, use timezone info

from /etc/localtime. If this is not set, and proftpd is configured to

chroot (e.g. DefaultRoot or ), it will use the non-daylight

savings timezone regardless of whether DST is in effect.

#SetEnv TZ :/etc/localtime

QuotaEngine off Ratios off

Delay engine reduces impact of the so-called Timing Attack described in

http://security.lss.hr/index.php?page=details&ID=LSS-2004-10-02

It is on by default.

DelayEngine on ControlsEngine off ControlsMaxClients 2 ControlsLog /var/log/proftpd/controls.log ControlsInterval 5 ControlsSocket /var/run/proftpd/proftpd.sock AdminControlsEngine off

Alternative authentication frameworks

#Include /etc/proftpd/ldap.conf
#Include /etc/proftpd/sql.conf

This is used for FTPS connections

#Include /etc/proftpd/tls.conf

Useful to keep VirtualHost/VirtualRoot directives separated

#Include /etc/proftpd/virtuals.con

A basic anonymous configuration, no upload directories.

<Anonymous ~ftp>

User ftp

Group nogroup

# We want clients to be able to login with “anonymous” as well as “ftp”

UserAlias anonymous ftp

# Cosmetic changes, all files belongs to ftp user

DirFakeUser on ftp

DirFakeGroup on ftp

RequireValidShell off

# Limit the maximum number of anonymous logins

MaxClients 10

# We want ‘welcome.msg’ displayed at login, and ‘.message’ displayed

# in each newly chdired directory.

DisplayLogin welcome.msg

DisplayChdir .message

# Limit WRITE everywhere in the anonymous chroot

<Directory *>

DenyAll

# Uncomment this if you’re brave.

#

# # Umask 022 is a good standard umask to prevent new files and dirs

# # (second parm) from being group and world writable.

# Umask 022 022

#

# DenyAll

#

#

# AllowAll

#

#

Include other custom configuration files

Include /etc/proftpd/conf.d/[/code]

Voici là ou je bloque :

~$ nc 127.0.0.1 21 220 ProFTPD 1.3.3d Server (Debian) [127.0.0.1] lang en_US 200 Using language en_US user blackndoor 331 Password required for blackndoor pass mypassword 230 User blackndoor logged in syst 215 UNIX Type: L8 pwd 257 "/home/blackndoor" is the current directory cwd / 250 CWD command successful pwd 257 "/" is the current directory list 425 Unable to build data connection: Invalid argument port 127,0,0,1,192,0 200 PORT command successful list 425 Unable to build data connection: Connection refused quit 221 Goodbye.

Je dois surement passer à côté d’un truc tout simple mais je ne vois pas :frowning:
Quelqu’un ?

Merci

votre proftpd.conf est incohérent et dangereux,vous vous connectez au serveur avec votre propre login et en plus vous n’êtes pas chrooté,votre serveur tourne sous root,pas bon,faites le tourner avec le user nobody appartenant au groupe nogroup.Les utilisateurs qui se connectent au serveur doivent être des utilisateurs régulièrement enregistrés sur votre machine,vous devez donc les créer et les chrooter dans leur home pour qu’ils ne puissent pas remonter dans votre arborescence.Mais vous vous ne devez pas vous connecter avec votre propre login pour des raisons de sécurité.Voir le fichier /etc/ftpusers qui liste les principaux logins interdits de connection et dans ce fichier rajoutez votre propre login.
Cherchez sur la toile de la documentation de base comment configurer proftpd.je vous donne déjà un exemple de configuration de base de proftpd.conf,après vous l’accommodez à votre sauce:

http://www.octetmalin.net/linux/tutoriels/proftpd-fichier-proftpd.conf.php

port 127,0,0,1,192,0 200 PORT command successful list 425 Unable to build data connection: Connection refused
Le port d’écoute client que tu as spécifié dans la commande PORT ne va pas s’ouvrir tout seul. Selon la variante de nc :

nc -l $((192*256+0)) nc -l -p $((192*256+0))
Mais pourquoi ne pas utiliser un vrai client FTP ?

Merci de ta réponse.
J’avais effectivement trouvé cela mais je pensais que la command port l’ouvrait.

Je passe par un script Python pour me connecter et faire des modifes.

Je suppose que tu sais qu’il existe deux modes de transfert FTP ?

Dans le mode “passif” initié par la commande PASV ou EPSV, le serveur ouvre un port en écoute, transmet son numéro au client dans la réponse à la commande et le client s’y connecte lors de la prochaine commande nécessitant une connexion de données (transfert ou listage).

Dans le mode “actif” initié par la commande PORT ou EPRT, le client ouvre un port en écoute, transmet son numéro au serveur dans les arguments de la commande et le serveur s’y connecte lors de la prochaine commande nécessitant une connexion de données.

Si en tant que client tu inities un transfert en mode actif avec PORT en indiquant un numéro de port, c’est à toi d’ouvrir ce port en écoute.

Mais si tu écris un script python, pourquoi ne pas plutôt utiliser la bibliothèque ftplib de python ?