Module: Ronin::Network::Mixins::Telnet
- Includes:
- Mixin
- Defined in:
- lib/ronin/network/mixins/telnet.rb
Overview
Adds Telnet convenience methods and connection parameters to a class.
Defines the following parameters:
host
(String
) - Telnet host.port
(Integer
) - Telnet port.telnet_user
(String
) - Telnet user to login as.telnet_password
(String
) - Telnet password to login with.telnet_proxy
(String
) - Telnet proxy.telnet_ssl
(Boolean
) - Enable Telnet over SSL. Defaults totrue
.
Instance Method Summary collapse
-
#telnet_connect(options = {}) {|connection| ... } ⇒ Net::Telnet
protected
Creates a connection to a Telnet server.
-
#telnet_session(options = {}) {|session| ... } ⇒ Object
protected
Starts a session with a Telnet server.
Methods included from Mixin
Instance Method Details
#telnet_connect(options = {}) {|connection| ... } ⇒ Net::Telnet (protected)
Creates a connection to a Telnet server. The host
, port
,
telnet_user
, telnet_password
, telnet_proxy
and
telnet_ssl
parameters will also be used to connect to the
Telnet server.
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/ronin/network/mixins/telnet.rb', line 144 def telnet_connect(={},&block) [:port] ||= self.port [:user] ||= self.telnet_user [:password] ||= self.telnet_password [:proxy] ||= self.telnet_proxy [:ssl] ||= self.telnet_ssl if self.port print_info "Connecting to #{self.host}:#{self.port} ..." else print_info "Connecting to #{self.host} ..." end return ::Net.telnet_connect(self.host,,&block) end |
#telnet_session(options = {}) {|session| ... } ⇒ Object (protected)
Starts a session with a Telnet server. The host
, port
,
telnet_user
, telnet_password
, telnet_proxy
and
telnet_ssl
parameters will also be used to connect to the
Telnet server.
184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/ronin/network/mixins/telnet.rb', line 184 def telnet_session(={},&block) return telnet_connect() do |sess| yield sess if block_given? sess.close if self.port print_info "Disconnecting to #{self.host}:#{self.port}" else print_info "Disconnecting to #{self.host}" end end end |