Module: Ronin::Network::FTP
- Included in:
- Mixins::FTP, Support
- Defined in:
- lib/ronin/network/ftp.rb
Overview
Provides helper methods for communicating with FTP servers.
Constant Summary collapse
- DEFAULT_PORT =
Default FTP port
21
- DEFAULT_USER =
Default FTP user
'anonymous'
Class Method Summary collapse
-
.default_port ⇒ Integer
Default port used by FTP.
-
.default_port=(new_port) ⇒ Object
Sets the default port used by FTP.
Instance Method Summary collapse
-
#ftp_connect(host, options = {}) {|session| ... } ⇒ Net::FTP
Creates a connection to the FTP server.
-
#ftp_session(host, options = {}) {|session| ... } ⇒ Object
Starts a session with the FTP server.
Class Method Details
.default_port ⇒ Integer
Default port used by Ronin::Network::FTP.
44 45 46 |
# File 'lib/ronin/network/ftp.rb', line 44 def self.default_port @default_port ||= DEFAULT_PORT end |
.default_port=(new_port) ⇒ Object
Sets the default port used by Ronin::Network::FTP.
56 57 58 |
# File 'lib/ronin/network/ftp.rb', line 56 def self.default_port=(new_port) @default_port = new_port end |
Instance Method Details
#ftp_connect(host, options = {}) {|session| ... } ⇒ Net::FTP
Creates a connection to the FTP server.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/ronin/network/ftp.rb', line 98 def ftp_connect(host,={}) host = host.to_s port = ([:port] || FTP.default_port) user = ([:user] || DEFAULT_USER) password = [:password] acct = [:account] session = Net::FTP.new session.connect(host,port) session.login(user,password,acct) session.passive = .fetch(:passive,true) yield session if block_given? return session end |
#ftp_session(host, options = {}) {|session| ... } ⇒ Object
Starts a session with the FTP server.
139 140 141 142 143 144 145 146 |
# File 'lib/ronin/network/ftp.rb', line 139 def ftp_session(host,={}) ftp = ftp_connect(host,) yield ftp if block_given? ftp.close return nil end |