Module: Ronin::Network::Mixins::FTP

Includes:
Mixin, FTP
Defined in:
lib/ronin/network/mixins/ftp.rb

Overview

Adds FTP convenience methods and connection parameters to a class.

Defines the following parameters:

  • host (String) - FTP host.
  • port (Integer) - FTP port.
  • ftp_user (String) - FTP user to login as.
  • ftp_password (String) - FTP password to login with.
  • ftp_account (String) - FTP account information to send.

Since:

  • 0.5.0

Constant Summary

Constants included from FTP

FTP::DEFAULT_PORT, FTP::DEFAULT_USER

Instance Method Summary collapse

Methods included from Mixin

included

Methods included from FTP

default_port, default_port=

Instance Method Details

#ftp_connect(options = {}) {|session| ... } ⇒ Net::FTP (protected)

Creates a connection to the FTP server. The host, port, ftp_user, ftp_password and ftp_account parameters will also be used to connect to the server.

Options Hash (options):

  • :port (Integer) — default: Network::FTP.default_port

    The port to connect to.

  • :user (String)

    The username to authenticate with.

  • :password (String)

    The password to authenticate with.

  • :account (String)

    The account information to send via the FTP ACCT command.

Yields:

  • (session)

    If a block is given, it will be passed an FTP session object.

Yield Parameters:

  • session (Net::FTP)

    The FTP session.

See Also:

Since:

  • 0.5.0


97
98
99
100
101
# File 'lib/ronin/network/mixins/ftp.rb', line 97

def ftp_connect(options={},&block)
  print_info "Connecting to #{host_port} ..."

  return super(self.host,ftp_merge_options(options),&block)
end

#ftp_session(options = {}) {|session| ... } ⇒ Object (protected)

Starts a session with the FTP server. The host, port, ftp_login, ftp_user and ftp_password parameters will also be used to connect to the server.

Yields:

  • (session)

    If a block is given, it will be passed an FTP session object. After the block has returned, the session will be closed.

Yield Parameters:

  • session (Net::FTP)

    The FTP session.

See Also:

Since:

  • 0.5.0


119
120
121
122
123
124
125
126
127
128
# File 'lib/ronin/network/mixins/ftp.rb', line 119

def ftp_session(options={},&block)
  super(ftp_merge_options(options)) do |sess|
    yield sess if block_given?

    print_info "Logging out ..."
  end

  print_info "Disconnected to #{host_port}"
  return nil
end