🛠️FTP
Theory
The File Transfer Protocol (FTP) is a standard network protocol used for the transfer of files between a client and server. It usually runs on ports 21/tcp or 2121/tcp.
Basic usage
Standard UNIX-like commands, like cd
, ls
, mkdir
, rm
can be used. Here is a short list of some specific commands.
Command
Description
help
display local help information
get
download file from remote server
put
upload file on the remote server
ascii
set the transfer type to "ASCII"
binary
set the transfer type to "Binary"
close
terminate FTP session
bye
terminate ftp session and exit
When downloading files, users should set the FTP client to "Binary" (binary
command) in order to prevent files from becoming corrupted during transit.
Regular text file can be downloaded in the other mode : "ASCII" (ascii
command)
Hidden files can be listed with ls -a
Enumeration
Banner grabbing
Useful to get basic information about the FTP server such as its type and version.
Accepted commands
The HELP
and FEAT
commands could give information about the FTP server such as the recognized commands and the extended features the server supports.
🛠️ Files
https://www.howtoforge.com/using-wget-with-ftp-to-download-move-web-sites-recursively
Connection
Anonymous login
Some FTP servers are configured to let users connect anonymously and thus give them access to files on the servers without authentication.
Attacks
Brute force
FTP sniffing
If the FTP communications are not encrypted and if the attacker is on the same network of the client or the server he can sniff the data packet traveling between the client and the server in order to retrieve credential.
Several tools like Wireshark
could be used to sniff TCP packets.
FTP Bounce attacks
FTP Bounce attacks let an attacker requests access to ports by using the FTP command PORT
. It's mostly used to make a port-scan without being detected (as you are not the one doing it, but the FTP server for you), for D.o.S. attacks, or to download files from another FTP server.
To check if the FTP server is vulnerable to Bounce attacks it is possible to use the tool NMAP
.
Scan the victim's network
If a FTP server is vulnerable to Bounce attacks, an attacker could use it to scan its network without being detected.
Download file/folder
If an attacker has access to a bounce FTP server, he can make it request files of other FTP server and download that file to his own server.
Requirements:
Valid credentials in the FTP intermediate server
Valid credentials in target FTP server
Both servers accept the PORT command
Write permissions in the intermediate server
Attacker's FTP server supports passive mode
Steps
Connect to your own FTP server and make the connection passive to make it listen in a directory where the victim service will send the file.
Create the file to send to the intermediate server with the commands that the targeted server will have to execute. Let's call this file
instrs
.
The extra nulls at the end of the command file are to fill up the TCP windows and ensure that the command connection stays open long enough for the whole session to be executed.
Upload this file on the intermediate server, then upload it from the intermediate server to the targeted server and __make the targeted machine execute this file.
The attacker should have received on his server the file 'file.tar.Z' renamed as 'dump'.
Resources
Last updated
Was this helpful?