githubEdit

FTP (File Transfer Protocol) Pentesting

FTP (File Transfer Protocol) Pentesting

FTP is a standard communication protocol used for the transfer of computer files from a server to a client on a computer network. Default ports are 20 (for data), 21 (for control).

Enumeration

nmap --script ftp-anon -p 21 <target-ip>
nmap --script ftp-vuln* -p 21 <target-ip>
nmap --script ftp-* -p 21 <target-ip>

Brute Force Credentials

hydra -l username -P passwords.txt <target-ip> ftp
hydra -L username.txt -p password <target-ip> ftp

hydra -l username -P passwords.txt ftp://<target-ip>
hydra -L usernames.txt -p password ftp://<target-ip>

Investigation

nc <target-ip> 21

Using OpenSSL

First off, open listener.

Then run the command below.

Configuration Files

Connect

Using ftp

Sometimes we might be able to the anonymous login. Not likely, but worth a try.

Using lftp

lftp is the enhanced version of ftp. It's more easier to use than ftp.

Commands in FTP

After connecting FTP, we can search directories and files, then download them to your local machine, and put local files to the target system. The FTP commands are almost the same as Linux commands.

Download Files

To download files to local machine,

Upload Files

Reverse Shell over Website

If the target website allows users to access the ftp directory, we can upload the exploit for the reverse shell and get a shell.

  1. Download the Payload

    Get the payload for the reverse shell from this repositoryarrow-up-right.

  2. Upload the Payload to FTP Directory

    Connect to FTP and upload the payload.

  3. Get a Shell

    At first, w need to open listener in your local machine.

    In a web browser, access to "http://vulnerable.com/path/to/ftp/shell.php". We should get a target shell.

Start FTP Server

1. Install vsftpd

To check the config file for vsftpd, run the following command.

2. Start FTP Server

Below are commands for starting FTP server and checking the status.

If you’ve updated the config file, you need to restart vsftpd.

Last updated