Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/base/sessions/hwbridge.rb
Views: 11784
# -*- coding: binary -*-12require 'rex/post/hwbridge'34module Msf5module Sessions67###8#9# This class provides an interactive session with a hardware bridge.10# The hardware bridge must support the current API supported by Metasploit.11#12###13class HWBridge < Rex::Post::HWBridge::Client1415#16# This interface supports basic interaction.17#18include Msf::Session::Basic1920#21# This interface supports interactive commands.22#23include Msf::Session::Interactive24include Msf::Sessions::Scriptable2526#27# Initialize the HWBridge console28#29def initialize(opts={})30super31#32# The module will manage it's alive state33#34self.alive = true3536#37# Initialize the hwbridge client38#39self.init_hwbridge(rstream, opts)4041#42# Create the console instance43#44self.console = Rex::Post::HWBridge::Ui::Console.new(self)45end4647#48# Returns the type of session.49#50def self.type51"hwbridge"52end5354def self.can_cleanup_files55false56end5758#59# Returns the session description.60#61def desc62"Hardware bridge interface"63end6465#66# We could tie this into payload UUID67#68def platform69"hardware"70end7172#73# We could tie this into payload UUID74#75def arch76ARCH_CMD77end7879#80# Session info based on the type of hw bridge we are connected to81# This information comes after connecting to a bridge and pulling status info82#83def info84if exploit85if exploit.hw_specialty86info = ""87exploit.hw_specialty.each_key do |k|88if exploit.hw_specialty[k] == true89info += "," if info.length > 090info += k91end92end93return info94end95end96end9798##99# :category: Msf::Session::Interactive implementors100#101# Initializes the console's I/O handles.102#103def init_ui(input, output)104self.user_input = input105self.user_output = output106console.init_ui(input, output)107console.set_log_source(log_source)108109super110end111112##113# :category: Msf::Session::Interactive implementors114#115# Resets the console's I/O handles.116#117def reset_ui118console.unset_log_source119console.reset_ui120end121122123##124# :category: Msf::Session::Interactive implementors125#126# Interacts with the hwbridge client at a user interface level.127#128def _interact129framework.events.on_session_interact(self)130# Call the console interaction subsystem of the meterpreter client and131# pass it a block that returns whether or not we should still be132# interacting. This will allow the shell to abort if interaction is133# canceled.134console.interact { self.interacting != true }135136# If the stop flag has been set, then that means the user exited. Raise137# the EOFError so we can drop this handle like a bad habit.138raise EOFError if (console.stopped? == true)139end140141def alive?142self.alive143end144145#146# Calls the class method.147#148def type149self.class.type150end151152#153# Loads the automotive extension154#155def load_automotive156original = console.disable_output157console.disable_output = true158console.run_single('load automotive')159console.disable_output = original160end161162#163# Loads the zigbee extension164#165def load_zigbee166original = console.disable_output167console.disable_output = true168console.run_single('load zigbee')169console.disable_output = original170end171172#173# Loads the rftransceiver extension174#175def load_rftransceiver176original = console.disable_output177console.disable_output = true178console.run_single('load rftransceiver')179console.disable_output = original180end181182#183# Load custom methods provided by the hardware184#185def load_custom_methods186original = console.disable_output187console.disable_output = true188console.run_single('load_custom_methods')189console.disable_output = original190end191192#193# The shell will have been initialized by default.194#195def shell_init196return true197end198199attr_accessor :console # :nodoc:200attr_accessor :alive # :nodoc:201attr_accessor :api_version202attr_accessor :fw_version203attr_accessor :hw_version204attr_accessor :device_name205private206attr_accessor :rstream # :nodoc:207208end209210end211end212213214