FTP connect with no username and password?

Ben Beri

Hello I have connected to the FTP using URLConnection with just the IP address with not specifing the login credentials.

URLConnection conn = new URLConnection(new URL("ftp://222.101.102.1/etc"));

It works, with no credentials because the server probably allows annonymous connection.

But for practice I wanted to make an ftp connection from scratch with Socket client, and I created a new socket connection to that IP:

Socket socket = new Socket("222.101.102.1", 21);
if (socket != null) {
    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    String version = reader.readLine();
    System.out.println(version);
}

This prints 220 vsFTPd (2.0.5)

but when I try to do command like LS \r\n

I get 530 Please login with USER and PASS

Why is it asking me for login if with URLConnection it did not?

This code was not compiled because it was memorized from my other computer so let me know if you notice something wrong and I'll edit right away.

Ben Beri

I managed to figure it out.

URL.openConnection() basically returns a class that implements URLStreamHandler based on the protocol. So in this case the protocol is ftpand it returns FtpURLConnection.

So there is a check that if the username is null (not specified in the URL), and if it is so it sets it to anonymous and uses a password of the java version with @

e.g Java1.8.0@ not sure for what purpose, maybe for login history. But you can use any password to login with anonymous unless it's configured for something else I think.

        if(this.user == null) {
            this.user = "anonymous";
            String var11 = (String)AccessController.doPrivileged(new GetPropertyAction("java.version"));
            this.password = (String)AccessController.doPrivileged(new GetPropertyAction("ftp.protocol.user", "Java" + var11 + "@"));
        }

So I basically logged in with Anonymous and no password.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to specify username password for ftp

Connect to OPCUA server with username and password

How to connect LDAP With username and password?

connect to openvpn using username and password

orientdb connect invalid password and username

How to specify username and password in ftp command?

FTP required username and password in opencart on localhost (windows)

Using JSoup to connect to a website with username/password

How to connect to MongoDB 3.2 in Java with username and password?

Connect to TFS GIT domain\username + password

How to connect mongodb(mongoose) with username and password?

Delphi/Rdp check username and password before connect

How to connect with an API that requires username and password

Use windows explorer to connect to a server with username and password

How to connect with coreNLP server with username password?

FTP: Connect as local user with different password

how to set username and password of ftp-srv in nodejs?

python paho mqtt can not connect to mqtts with username and password

Java - Connect to MySQL without specifying username and password inside the code

Python connect to API using username, password and API key

How to configure MongoDB to be able to connect using username and password?

How to use username and password (no SSL) in Java client to connect to Elasticsearch?

What are the options for connect username/password@sid in a sql script for jdbc

What password and username do I use for mysql_connect()?

How to automatically enter username and password when prompted to connect to a remote server

Connect to the LDAP Active Directory in Java without username and password

How to connect to an ActiveMQ server by setting the username and password programmatically?

Visual Studio 2017 cannot connect to WSL says Username and Password are wrong

PEAP profile connect without manually entering username and password