0

Currently, I am trying to run ftp commands from telnet client. I was successful with USER, PASS, PASV, LIST and when tried PORT vsftp server is throwing 500 Illegal PORT command. I am following the syntax as specified in RFC 959

DATA PORT (PORT)

The argument is a HOST-PORT specification for the data port to be used in data connection. There are defaults for both the user and server data ports, and under normal circumstances this command and its reply are not needed. If this command is used, the argument is the concatenation of a 32-bit internet host address and a 16-bit TCP port address. This address information is broken into 8-bit fields and the value of each field is transmitted as a decimal number (in character string representation). The fields are separated by commas. A port command would be:

PORT h1,h2,h3,h4,p1,p2

where h1 is the high order 8 bits of the internet host address.

I tried to check if it is a problem related to vsftpd configuration file using ftp command. It was working fine with passive mode turn off. So why is it throwing error when I run from telnet client ? Below I attach the screenshot of telnet session, and nc session where I am trying to listen for data connection.

enter image description here

5
  • 2
    asking for port 100, which is reserved as it is less than 2048, is a bad idea. What happens if you ask say "PORT 127,0,0,1,100,0" to ask for port 25600 ? – icarus May 20 '20 at 18:24
  • Yes it works fine ! Thanks. But here we are not asking, we are saying it to which port to connect and transfer data, So why should server be worried about connecting to the restricted ports of the client ? – m0hithreddy May 20 '20 at 18:28
  • 1
    Because using low level ports is probably a way to involve the server in some intrusion attempt. The developpers just prohibited it – A.B May 20 '20 at 19:13
  • @A.B That is an interesting answer ! So RFC wont put any constraints on the data-connection ports, its the developers that put. – m0hithreddy May 20 '20 at 19:29
  • 1
1

In olden days when the world was young, pterodactyls still flew in the sky, a computer that was able to connect to a IP network cost $100,000 (and those were real dollars) and most of the system administrators of those machines knew each other on a first name basis, it was decided to partition the 65535 TCP ports (or is it 65536) into two groups and make the Unix kernel restrict access to the ports below 1024 to "root". Well known ports were allocated in this region.

If you saw an incoming connection which came from such a port you could trust it, because you knew that Dick, or John, or Jane would not allow their machine to be hacked. Likewise only trusted programs on your machine could open such ports.

Now of course you can buy a computer for about the cost of 3 pints of beer (e.g. Raspberry PI) or less this is no longer true.

So the first question from the OP was why he got back an "Invalid port" message, and that is because the daemon is objecting to port number 100, a reserved port.

The followup question in the comments is why is it objecting. The answer here is a bit more nebulous. If you ask the system to send the contents of a fifo then you can send arbitrary sequences of bytes with almost any timing. As @A.B indicates this allows you to use an FTPD as part of an attack.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.