Cheatsheet

ActionCommand
NetExecnxc ftp -u '{username}' -p '{password}' -M {modules}
Noauth Loginftp $ipscope
Get all no login available fileswget -m --no-passive ftp://anonymous:anonymous@$ipscope
Nmap FTP Enumnmap $ipscope -sV -p21 -sC -A --script-trace
sFTPopenssl s_client -connect $ipscope -starttls ftp
hydrahydra -L {user list} -P/p {passwordlist/password}

File Transfer Protocol

Distinguish active and passive mode :

Active Client initiate connection and server responds by setting the client side ports. This gets blocked by firewall on clients so passive is the most common. Passive Server indicates which ports he chose to the client, but the latter is now establishing the connection with this information and preventing the firewall to block it.

FTP Command List

TypeCommandWhat it Does
Command!Runs the specified command on the local computer
Command?Displays descriptions for ftp commands
CommandappendAppends a local file to a file on the remote computer
CommandasciiSets the file transfer type to ASCII, the default
CommandbellToggles a bell to ring after each file transfer command is completed (default = OFF)
CommandbinarySets the file transfer type to binary
CommandbyeEnds the FTP session and exits ftp
CommandcdChanges the working directory on the remote computer
CommandcloseEnds the FTP session and returns to the command interpreter
CommanddebugToggles debugging (default = OFF)
CommanddeleteDeletes a single file on a remote computer
CommanddirDisplays a list of a remote directory’s files and subdirectories
CommanddisconnectDisconnects from the remote computer, retaining the ftp prompt
CommandgetCopies a single remote file to the local computer
CommandglobToggles filename globbing (wildcard characters) (default = ON)
CommandhashToggles hash sign (#) printing for each data block transferred (default = OFF)
CommandhelpDisplays descriptions for ftp commands
CommandlcdChanges the working directory on the local computer
CommandliteralSends arguments, verbatim, to the remote FTP server
CommandlsDisplays an abbreviated list of a remote directory’s files and subdirectories
CommandmdeleteDeletes one or more files on a remote computer
CommandmdirDisplays a list of a remote directory’s files and subdirectories
CommandmgetCopies one or more remote files to the local computer
CommandmkdirCreates a remote directory
CommandmlsDisplays an abbreviated list of a remote directory’s files and subdirectories
CommandmputCopies one or more local files to the remote computer
CommandopenConnects to the specified FTP server
CommandpromptToggles prompting (default = ON)
CommandputCopies a single local file to the remote computer
CommandpwdDisplays the current directory on the remote computer (literally, “print working directory”)
CommandquitEnds the FTP session with the remote computer and exits ftp (same as “bye”)
CommandquoteSends arguments, verbatim, to the remote FTP server (same as “literal”)
CommandrecvCopies a remote file to the local computer
CommandremotehelpDisplays help for remote commands
CommandrenameRenames remote files
CommandrmdirDeletes a remote directory
CommandsendCopies a local file to the remote computer (same as “put”)
CommandstatusDisplays the current status of FTP connections
CommandtraceToggles packet tracing (default = OFF)
CommandtypeSets or displays the file transfer type (default = ASCII)
CommanduserSpecifes a user to the remote computer
CommandverboseToggles verbose mode (default = ON)

FTP Command Line

TypeCommandWhat it Does
Command Line-vSuppresses verbose display of remote server responses.
Command Line-nSuppresses auto login
Command Line-iTurns off interactive prompting during multiple file transfers.
Command Line-dEnables debugging, displaying all ftp commands passed between the client and server.
Command Line–gDisables filename globbing, which permits the use of wildcard chracters in local file and path names.
Command Line-s:filenameSpecifies a text file containing ftp commands; the commands will automatically run after ftp starts. No spaces are allowed in this parameter. Use this switch instead of redirection (>).
Command Line-aUse any local interface when binding data connection.
Command Line-w:windowsizeOverrides the default transfer buffer size of 4096.
Command Line-computerSpecifies the computer name or IP address of the remote computer to connect to. The computer, if specified, must be the last parameter on the line.

TFTP

Unlikely to see this protocol as it does not require authent. However if you have a foot on the internal network the chances of finding one increase as they might have “public” shares inside the network.

CommandsDescription
connectSets the remote host, and optionally the port, for file transfers.
getTransfers a file or set of files from the remote host to the local host.
putTransfers a file or set of files from the local host onto the remote host.
quitExits tftp.
statusShows the current status of tftp, including the current transfer mode (ascii or binary), connection status, time-out value, and so on.
verboseTurns verbose mode, which displays additional information during file transfer, on or off.

Different FTP servers

vsFTP

Mostly used on Linux distributions using FTP.

  • Conf is located at /etc/vsftpd.conf
  • Users can be found in /etc/ftpusers

Default settings :

SettingDescription
listen=NORun from inetd or as a standalone daemon?
listen_ipv6=YESListen on IPv6 ?
anonymous_enable=NOEnable Anonymous access?
local_enable=YESAllow local users to login?
dirmessage_enable=YESDisplay active directory messages when users go into certain directories?
use_localtime=YESUse local time?
xferlog_enable=YESActivate logging of uploads/downloads?
connect_from_port_20=YESConnect from port 20?
secure_chroot_dir=/var/run/vsftpd/emptyName of an empty directory
pam_service_name=vsftpdThis string is the name of the PAM service vsftpd will use.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pemThe last three options specify the location of the RSA certificate to use for SSL encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=NO

Dangerous Settings

Optional settings to look for in misconfigured :

SettingDescription
anonymous_enable=YESAllowing anonymous login?
anon_upload_enable=YESAllowing anonymous to upload files?
anon_mkdir_write_enable=YESAllowing anonymous to create new directories?
no_anon_password=YESDo not ask anonymous for password?
anon_root=/home/username/ftpDirectory for anonymous.
write_enable=YESAllow the usage of FTP commands: STOR, DELE, RNFR, RNTO, MKD, RMD, APPE, and SITE?