Class: Msf::Sessions::HWBridge

Inherits:
Rex::Post::HWBridge::Client show all
Includes:
Msf::Session::Basic, Msf::Session::Interactive, Scriptable
Defined in:
lib/msf/base/sessions/hwbridge.rb

Overview

This class provides an interactive session with a hardware bridge. The hardware bridge must support the current API supported by Metasploit.

Instance Attribute Summary collapse

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #next_session, #on_command_proc, #on_print_proc, #on_run_command_error_proc, #orig_suspend, #orig_usr1, #orig_winch

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Attributes included from Msf::Session

#db_record, #exploit, #exploit_datastore, #exploit_task, #exploit_uuid, #framework, #machine_id, #payload_uuid, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #via, #workspace

Attributes included from Framework::Offspring

#framework

Attributes inherited from Rex::Post::HWBridge::Client

#commands, #ext, #ext_aliases, #sock

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Scriptable

#execute_file, #execute_script, included, #legacy_script_to_post_module

Methods included from Msf::Session::Interactive

#_interact_complete, #_interrupt, #_suspend, #_usr1, #abort_foreground, #abort_foreground_supported, #cleanup, #comm_channel, #interactive?, #kill, #run_cmd, #tunnel_local, #tunnel_peer, #user_want_abort?

Methods included from Rex::Ui::Interactive

#_interact_complete, #_interrupt, #_local_fd, #_remote_fd, #_stream_read_local_write_remote, #_stream_read_remote_write_local, #_suspend, #_winch, #detach, #handle_suspend, #handle_usr1, #handle_winch, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1, #restore_winch

Methods included from Rex::Ui::Subscriber

#copy_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

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 Msf::Session

#cleanup, #comm_channel, #dead?, #inspect, #interactive?, #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

Methods inherited from Rex::Post::HWBridge::Client

#add_extension, check_ext_hash, #deregister_extension, #deregister_extension_alias, #dump_extension_tree, #each_extension, #get_custom_methods, #get_statistics, #get_status, #init_hwbridge, #method_missing, #reboot, #register_extension_alias, #register_extension_aliases, #reset, #send_request, set_ext_hash, #unicode_filter_decode, #unicode_filter_encode

Constructor Details

#initialize(opts = {}) ⇒ HWBridge

Initialize the HWBridge console



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/msf/base/sessions/hwbridge.rb', line 30

def initialize(opts={})
  super
  #
  #  The module will manage it's alive state
  #
  self.alive = true

  #
  # Initialize the hwbridge client
  #
  self.init_hwbridge(rstream, opts)

  #
  # Create the console instance
  #
  self.console = Rex::Post::HWBridge::Ui::Console.new(self)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Rex::Post::HWBridge::Client

Instance Attribute Details

#aliveObject

:nodoc:



201
202
203
# File 'lib/msf/base/sessions/hwbridge.rb', line 201

def alive
  @alive
end

#api_versionObject

Returns the value of attribute api_version.



202
203
204
# File 'lib/msf/base/sessions/hwbridge.rb', line 202

def api_version
  @api_version
end

#consoleObject

:nodoc:



200
201
202
# File 'lib/msf/base/sessions/hwbridge.rb', line 200

def console
  @console
end

#device_nameObject

Returns the value of attribute device_name.



205
206
207
# File 'lib/msf/base/sessions/hwbridge.rb', line 205

def device_name
  @device_name
end

#fw_versionObject

Returns the value of attribute fw_version.



203
204
205
# File 'lib/msf/base/sessions/hwbridge.rb', line 203

def fw_version
  @fw_version
end

#hw_versionObject

Returns the value of attribute hw_version.



204
205
206
# File 'lib/msf/base/sessions/hwbridge.rb', line 204

def hw_version
  @hw_version
end

Class Method Details

.can_cleanup_filesObject



55
56
57
# File 'lib/msf/base/sessions/hwbridge.rb', line 55

def self.can_cleanup_files
  false
end

.typeObject

Returns the type of session.



51
52
53
# File 'lib/msf/base/sessions/hwbridge.rb', line 51

def self.type
  "hwbridge"
end

Instance Method Details

#_interactObject

:category: Msf::Session::Interactive implementors

Interacts with the hwbridge client at a user interface level.

Raises:

  • (EOFError)


129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/msf/base/sessions/hwbridge.rb', line 129

def _interact
  framework.events.on_session_interact(self)
  # Call the console interaction subsystem of the meterpreter client and
  # pass it a block that returns whether or not we should still be
  # interacting.  This will allow the shell to abort if interaction is
  # canceled.
  console.interact { self.interacting != true }

  # If the stop flag has been set, then that means the user exited.  Raise
  # the EOFError so we can drop this handle like a bad habit.
  raise EOFError if (console.stopped? == true)
end

#alive?Boolean

Returns:

  • (Boolean)


142
143
144
# File 'lib/msf/base/sessions/hwbridge.rb', line 142

def alive?
  self.alive
end

#archObject

We could tie this into payload UUID



76
77
78
# File 'lib/msf/base/sessions/hwbridge.rb', line 76

def arch
  ARCH_CMD
end

#descObject

Returns the session description.



62
63
64
# File 'lib/msf/base/sessions/hwbridge.rb', line 62

def desc
  "Hardware bridge interface"
end

#infoObject

Session info based on the type of hw bridge we are connected to This information comes after connecting to a bridge and pulling status info



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/msf/base/sessions/hwbridge.rb', line 84

def info
 if exploit
   if exploit.hw_specialty
     info = ""
     exploit.hw_specialty.each_key do |k|
       if exploit.hw_specialty[k] == true
         info += "," if info.length > 0
         info += k
       end
     end
     return info
   end
 end
end

#init_ui(input, output) ⇒ Object

:category: Msf::Session::Interactive implementors

Initializes the console’s I/O handles.



104
105
106
107
108
109
110
111
# File 'lib/msf/base/sessions/hwbridge.rb', line 104

def init_ui(input, output)
  self.user_input = input
  self.user_output = output
  console.init_ui(input, output)
  console.set_log_source(log_source)

  super
end

#load_automotiveObject

Loads the automotive extension



156
157
158
159
160
161
# File 'lib/msf/base/sessions/hwbridge.rb', line 156

def load_automotive
  original = console.disable_output
  console.disable_output = true
  console.run_single('load automotive')
  console.disable_output = original
end

#load_custom_methodsObject

Load custom methods provided by the hardware



186
187
188
189
190
191
# File 'lib/msf/base/sessions/hwbridge.rb', line 186

def load_custom_methods
  original = console.disable_output
  console.disable_output = true
  console.run_single('load_custom_methods')
  console.disable_output = original
end

#load_rftransceiverObject

Loads the rftransceiver extension



176
177
178
179
180
181
# File 'lib/msf/base/sessions/hwbridge.rb', line 176

def load_rftransceiver
  original = console.disable_output
  console.disable_output = true
  console.run_single('load rftransceiver')
  console.disable_output = original
end

#load_zigbeeObject

Loads the zigbee extension



166
167
168
169
170
171
# File 'lib/msf/base/sessions/hwbridge.rb', line 166

def load_zigbee
  original = console.disable_output
  console.disable_output = true
  console.run_single('load zigbee')
  console.disable_output = original
end

#platformObject

We could tie this into payload UUID



69
70
71
# File 'lib/msf/base/sessions/hwbridge.rb', line 69

def platform
  "hardware"
end

#reset_uiObject

:category: Msf::Session::Interactive implementors

Resets the console’s I/O handles.



118
119
120
121
# File 'lib/msf/base/sessions/hwbridge.rb', line 118

def reset_ui
  console.unset_log_source
  console.reset_ui
end

#shell_initObject

The shell will have been initialized by default.



196
197
198
# File 'lib/msf/base/sessions/hwbridge.rb', line 196

def shell_init
  return true
end

#typeObject

Calls the class method.



149
150
151
# File 'lib/msf/base/sessions/hwbridge.rb', line 149

def type
  self.class.type
end