Class: Msf::Sessions::Modem
- Inherits:
-
Object
- Object
- Msf::Sessions::Modem
- Defined in:
- lib/msf/base/sessions/modem.rb,
lib/msf/base/sessions/modem/quectel.rb
Overview
Quectel modem session - concrete Msf::Sessions::Modem subclass backed by the Driver / Connection AT-command serial driver defined here.
Routing capability:
TCP client - AT+QIOPEN "TCP" (create_tcp_client_channel)
UDP client - AT+QIOPEN "UDP" (create_udp_channel)
TCP server - not supported (create_tcp_server_channel raises)
Defined Under Namespace
Modules: ChannelSocketInterface Classes: ChannelBase, Quectel, TcpClientChannel, UdpChannel
Instance Attribute Summary
Attributes included from Rex::Ui::Subscriber::Input
Attributes included from Rex::Ui::Subscriber::Output
Attributes included from Rex::Post::Channel::Container
Attributes included from Msf::Session
#alive, #db_record, #exploit, #exploit_datastore, #exploit_task, #exploit_uuid, #framework, #info, #machine_id, #payload_uuid, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #via, #workspace
Attributes included from Framework::Offspring
Class Method Summary collapse
- .can_cleanup_files ⇒ Object
-
.type ⇒ Object
----------------------------------------------------------------------- Session identity - subclasses should override desc -----------------------------------------------------------------------.
Instance Method Summary collapse
- #alive? ⇒ Boolean
- #arch ⇒ Object
- #cleanup ⇒ Object
-
#create(params) ⇒ Socket-like
Called by Rex::Socket::SwitchBoard to open a new socket through this session.
- #create_tcp_client_channel(_params) ⇒ Object protected
- #create_tcp_server_channel(_params) ⇒ Object protected
-
#create_udp_channel(params) ⇒ Object
protected
Base UDP fallback: delegate to the local system comm.
- #desc ⇒ Object
-
#initialize(opts = {}) ⇒ Modem
constructor
----------------------------------------------------------------------- Lifecycle -----------------------------------------------------------------------.
-
#interacting ⇒ Object
Modem sessions are never interactively attached to a terminal.
- #interactive? ⇒ Boolean
- #platform ⇒ Object
-
#supports_udp? ⇒ Boolean
Base implementation: modem sessions cannot natively tunnel UDP in the general case.
- #type ⇒ Object
Methods included from Rex::Ui::Subscriber
Methods included from Rex::Ui::Subscriber::Input
Methods included from Rex::Ui::Subscriber::Output
#flush, #print, #print_blank_line, #print_error, #print_good, #print_line, #print_status, #print_warning
Methods included from Rex::Post::Channel::Container
#add_channel, #find_channel, #initialize_channels, #remove_channel
Methods included from Msf::Session
#comm_channel, #dead?, #inspect, #kill, #log_file_name, #log_source, #name, #name=, #register?, #session_host, #session_host=, #session_port, #session_port=, #session_type, #set_from_exploit, #set_via, #tunnel_local, #tunnel_peer, #tunnel_to_s, #via_exploit, #via_payload
Constructor Details
#initialize(opts = {}) ⇒ Modem
Lifecycle
438 439 440 441 442 443 |
# File 'lib/msf/base/sessions/modem.rb', line 438 def initialize(opts = {}) super() # Msf::Session#initialize: sets alive, uuid, routes @channel_ticker = 0 initialize_channels # Rex::Post::Channel::Container self.alive = true end |
Class Method Details
.can_cleanup_files ⇒ Object
372 373 374 |
# File 'lib/msf/base/sessions/modem.rb', line 372 def self.can_cleanup_files false end |
.type ⇒ Object
Session identity - subclasses should override desc
352 353 354 |
# File 'lib/msf/base/sessions/modem.rb', line 352 def self.type 'modem' end |
Instance Method Details
#alive? ⇒ Boolean
376 377 378 |
# File 'lib/msf/base/sessions/modem.rb', line 376 def alive? self.alive end |
#arch ⇒ Object
368 369 370 |
# File 'lib/msf/base/sessions/modem.rb', line 368 def arch ARCH_CMD end |
#cleanup ⇒ Object
445 446 447 448 |
# File 'lib/msf/base/sessions/modem.rb', line 445 def cleanup channels.dup.each_value(&:close) super end |
#create(params) ⇒ Socket-like
Called by Rex::Socket::SwitchBoard to open a new socket through this session. Dispatches to the appropriate protected hook method.
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
# File 'lib/msf/base/sessions/modem.rb', line 412 def create(params) notify_before_socket_create(self, params) sock = case params.proto when 'udp' create_udp_channel(params) when 'tcp' if params.server create_tcp_server_channel(params) else create_tcp_client_channel(params) end else raise ::Rex::ConnectionError.new(params.peerhost, params.peerport, reason: "Unsupported socket protocol: #{params.proto}") end raise ::Rex::ConnectionError unless sock notify_socket_created(self, sock, params) sock end |
#create_tcp_client_channel(_params) ⇒ Object (protected)
452 453 454 |
# File 'lib/msf/base/sessions/modem.rb', line 452 def create_tcp_client_channel(_params) raise NotImplementedError, "#{self.class}#create_tcp_client_channel is not implemented" end |
#create_tcp_server_channel(_params) ⇒ Object (protected)
456 457 458 |
# File 'lib/msf/base/sessions/modem.rb', line 456 def create_tcp_server_channel(_params) raise NotImplementedError, "#{self.class}#create_tcp_server_channel is not implemented" end |
#create_udp_channel(params) ⇒ Object (protected)
Base UDP fallback: delegate to the local system comm.
463 464 465 |
# File 'lib/msf/base/sessions/modem.rb', line 463 def create_udp_channel(params) raise NotImplementedError, "#{self.class}#create_udp_channel is not implemented" end |
#desc ⇒ Object
360 361 362 |
# File 'lib/msf/base/sessions/modem.rb', line 360 def desc 'Modem' end |
#interacting ⇒ Object
Modem sessions are never interactively attached to a terminal.
381 382 383 |
# File 'lib/msf/base/sessions/modem.rb', line 381 def interacting false end |
#interactive? ⇒ Boolean
385 386 387 |
# File 'lib/msf/base/sessions/modem.rb', line 385 def interactive? false end |
#platform ⇒ Object
364 365 366 |
# File 'lib/msf/base/sessions/modem.rb', line 364 def platform 'hardware' end |
#supports_udp? ⇒ Boolean
Base implementation: modem sessions cannot natively tunnel UDP in the general case.
Note: returning false here causes the framework's DNS resolver to fall back to TCP-DNS, which would route through the modem and add significant latency. Subclasses that override this to true must also implement create_udp_channel so DNS and UDP traffic route correctly.
396 397 398 |
# File 'lib/msf/base/sessions/modem.rb', line 396 def supports_udp? false end |
#type ⇒ Object
356 357 358 |
# File 'lib/msf/base/sessions/modem.rb', line 356 def type self.class.type end |