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)
Direct Known Subclasses
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
439 440 441 442 443 444 |
# File 'lib/msf/base/sessions/modem.rb', line 439 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
373 374 375 |
# File 'lib/msf/base/sessions/modem.rb', line 373 def self.can_cleanup_files false end |
.type ⇒ Object
Session identity - subclasses should override desc
353 354 355 |
# File 'lib/msf/base/sessions/modem.rb', line 353 def self.type 'modem' end |
Instance Method Details
#alive? ⇒ Boolean
377 378 379 |
# File 'lib/msf/base/sessions/modem.rb', line 377 def alive? self.alive end |
#arch ⇒ Object
369 370 371 |
# File 'lib/msf/base/sessions/modem.rb', line 369 def arch ARCH_CMD end |
#cleanup ⇒ Object
446 447 448 449 |
# File 'lib/msf/base/sessions/modem.rb', line 446 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.
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'lib/msf/base/sessions/modem.rb', line 413 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)
453 454 455 |
# File 'lib/msf/base/sessions/modem.rb', line 453 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)
457 458 459 |
# File 'lib/msf/base/sessions/modem.rb', line 457 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.
464 465 466 |
# File 'lib/msf/base/sessions/modem.rb', line 464 def create_udp_channel(params) raise NotImplementedError, "#{self.class}#create_udp_channel is not implemented" end |
#desc ⇒ Object
361 362 363 |
# File 'lib/msf/base/sessions/modem.rb', line 361 def desc 'Modem' end |
#interacting ⇒ Object
Modem sessions are never interactively attached to a terminal.
382 383 384 |
# File 'lib/msf/base/sessions/modem.rb', line 382 def interacting false end |
#interactive? ⇒ Boolean
386 387 388 |
# File 'lib/msf/base/sessions/modem.rb', line 386 def interactive? false end |
#platform ⇒ Object
365 366 367 |
# File 'lib/msf/base/sessions/modem.rb', line 365 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.
397 398 399 |
# File 'lib/msf/base/sessions/modem.rb', line 397 def supports_udp? false end |
#type ⇒ Object
357 358 359 |
# File 'lib/msf/base/sessions/modem.rb', line 357 def type self.class.type end |