conpot.protocols.ftp package¶
Submodules¶
conpot.protocols.ftp.ftp_base_handler module¶
-
class
conpot.protocols.ftp.ftp_base_handler.
FTPHandlerBase
(request, client_address, server)¶ Bases:
socketserver.BaseRequestHandler
Base class for a full duplex connection
-
authentication_ok
(user_pass)¶ Verifies authentication and sets the username of the currently connected client. Returns True or False Checks user names and passwords pairs. Sets the current user and uid.
-
config
= None¶
-
class
false_request
¶ Bases:
object
-
finish
()¶ End this client session
-
ftp_path
(path)¶ Clean and sanitize ftp paths relative fs instance it is hosted in.
-
handle
()¶ Actual FTP service to which the user has connected.
-
handle_cmd_channel
()¶ Read data from the socket and add it to the _command_channel_input_q for processing
-
handle_data_channel
()¶
-
host
= None¶
-
port
= None¶
-
process_ftp_command
()¶
-
push_data
(data)¶ Handy utility to push some data using the data channel
-
recv_file
(_file, _file_pos=0, cmd='STOR')¶ Receive a file - to be used with STOR, REST and APPE. A copy would be made on the _data_fs. :param _file: File Name to the file that would be written to fs. :param _file_pos: Seek file to position before receiving. :param cmd: Command used for receiving file.
-
respond
(response)¶ Send processed command/data as reply to the client
-
send_file
(file_name)¶ Handy utility to send a file using the data channel
-
setup
()¶ Connect incoming connection to a FTP session
-
start_data_channel
(send_recv='send')¶ Starts the data channel. To be called from the command process greenlet. :param send_recv: Whether the event is a send event or recv event. When set to ‘send’ data channel’s socket writes data in the output queues else when set to ‘read’ data channel’s socket reads data into the input queue. :type send_recv: str
-
stop_data_channel
(abort=False, purge=False, reason=None)¶
-
classmethod
stream_server_handle
(sock, address)¶ Translate this class for use in a StreamServer
-
conpot.protocols.ftp.ftp_handler module¶
-
class
conpot.protocols.ftp.ftp_handler.
FTPCommandChannel
(request, client_address, server)¶ Bases:
conpot.protocols.ftp.ftp_base_handler.FTPHandlerBase
FTP Command Responder. Implementation of RFC 959.
-
do_ABOR
(arg)¶ Aborts a file transfer currently in progress.
-
do_ALLO
(arg)¶ Allocate bytes for storage (noop).
-
do_APPE
(file)¶ Append data to an existing file on the server. On success return the file path, else None.
-
do_BYE
(arg)¶
-
do_CDUP
(arg)¶ Change into the parent directory. On success return the new directory, else None.
-
do_CWD
(path)¶ Change the current working directory.
-
do_DELE
(path)¶ Delete the specified file.
-
do_HELP
(arg)¶ Return help text to the client.
-
do_LIST
(path)¶
-
do_MDTM
(path)¶ Return last modification time of file to the client as an ISO 3307 style timestamp (YYYYMMDDHHMMSS) as defined in RFC-3659. On success return the file path, else None.
-
do_MKD
(path)¶ Create the specified directory. On success return the directory path, else None.
-
do_MODE
(line)¶ Set data transfer mode (“S” is the only one supported (noop)).
-
do_NLST
(path)¶ Return a list of files in the specified directory in a compact form to the client.
-
do_NOOP
(arg)¶ Do nothing. No params required. No auth required and no permissions required.
-
do_PASS
(arg)¶
-
do_PASV
(arg)¶ Starts a Passive Data Channel using IPv4. We don’t actually need to start the full duplex connection here. Just need to figure the host ip and the port. The DTP connection would start in each command.
-
do_PORT
(arg)¶ Starts an active data channel by using IPv4. We don’t actually need to start the full duplex connection here. Just need to figure the host ip and the port. The DTP connection would start in each command.
-
do_PWD
(arg)¶ Return the name of the current working directory to the client.
-
do_QUIT
(arg)¶
-
do_REIN
(arg)¶ Reinitialize user’s current session.
-
do_REST
(line)¶ Restart a file transfer from a previous mark.
-
do_RETR
(arg)¶ Fetch and send a file. :param arg: Filename that is to be retrieved
-
do_RMD
(path)¶ Remove the specified directory. On success return the directory path, else None.
-
do_RNFR
(path)¶ Rename the specified (only the source name is specified here, see RNTO command)
-
do_RNTO
(dst_path)¶ Rename file (destination name only, source is specified with RNFR).
-
do_SITE_CHMOD
(path, mode)¶ Change file mode. On success return a (file_path, mode) tuple.
-
do_SITE_HELP
(line)¶ Return help text to the client for a given SITE command.
-
do_SIZE
(path)¶ Return size of file in a format suitable for using with RESTart as defined in RFC-3659.
-
do_STAT
(path)¶ If invoked without parameters, returns general status information about the FTP server process. If a parameter is given, acts like the LIST command, except that data is sent over the command channel (no PORT or PASV command is required).
-
do_STOR
(file, mode='w')¶ Store a file (transfer from the client to the server).
-
do_STOU
(line)¶ Store a file on the server with a unique name.
-
do_STRU
(line)¶ Set file structure (“F” is the only one supported (noop)).
-
do_SYST
(arg)¶ Return system type (always returns UNIX type: L8).
-
do_TYPE
(line)¶ Set current type data type to binary/ascii
-
do_USER
(arg)¶ USER FTP command. If the user is already logged in, return 530 else 331 for the PASS command :param arg: username specified by the client/attacker
-
do_XCUP
(arg)¶ Change into the parent directory. On success return the new directory, else None.
-
do_XCWD
(path)¶ Change the current working directory.
-
do_XMKD
(path)¶ Create the specified directory. On success return the directory path, else None.
-
do_XPWD
(arg)¶ Return the name of the current working directory to the client.
-
do_XRMD
(path)¶ Remove the specified directory. On success return the directory path, else None.
-
process_ftp_command
()¶ Handle an incoming handle request - pick and item from the input_q, reads the contents of the message and dispatch contents to the appropriate do_* method. :param: (bytes) line - incoming request :return: (bytes) response - reply in respect to the request
-
conpot.protocols.ftp.ftp_server module¶
conpot.protocols.ftp.ftp_utils module¶
-
exception
conpot.protocols.ftp.ftp_utils.
FTPException
¶ Bases:
Exception
General FTP related exceptions.
-
exception
conpot.protocols.ftp.ftp_utils.
FTPMaxLoginAttemptsExceeded
¶
-
exception
conpot.protocols.ftp.ftp_utils.
FTPPrivilegeException
¶
-
conpot.protocols.ftp.ftp_utils.
get_data_from_iter
(iterator)¶ This utility function generates data from iterators and returns them as string