Class: Msf::Sessions::HWBridge

Inherits:
Rex::Post::HWBridge::Client show all
Includes:
Msf::Session::Basic, Msf::Session::Interactive, Msf::Session::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, #orig_suspend, #orig_usr1

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

#execute_file, #execute_script, included, #legacy_script_to_post_module

Methods included from Msf::Session::Interactive

#_interact_complete, #_interrupt, #_suspend, #_usr1, #cleanup, #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, #detach, #handle_suspend, #handle_usr1, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1

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, #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


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

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:


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

def alive
  @alive
end

#api_versionObject

Returns the value of attribute api_version


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

def api_version
  @api_version
end

#consoleObject

:nodoc:


198
199
200
# File 'lib/msf/base/sessions/hwbridge.rb', line 198

def console
  @console
end

#device_nameObject

Returns the value of attribute device_name


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

def device_name
  @device_name
end

#fw_versionObject

Returns the value of attribute fw_version


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

def fw_version
  @fw_version
end

#hw_versionObject

Returns the value of attribute hw_version


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

def hw_version
  @hw_version
end

Class Method Details

.typeObject

Returns the type of session.


53
54
55
# File 'lib/msf/base/sessions/hwbridge.rb', line 53

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)

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

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)

140
141
142
# File 'lib/msf/base/sessions/hwbridge.rb', line 140

def alive?
  self.alive
end

#archObject

We could tie this into payload UUID


74
75
76
# File 'lib/msf/base/sessions/hwbridge.rb', line 74

def arch
  ARCH_CMD
end

#descObject

Returns the session description.


60
61
62
# File 'lib/msf/base/sessions/hwbridge.rb', line 60

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


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

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.


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

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


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

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


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

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


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

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


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

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


67
68
69
# File 'lib/msf/base/sessions/hwbridge.rb', line 67

def platform
  "hardware"
end

#reset_uiObject

:category: Msf::Session::Interactive implementors

Resets the console's I/O handles.


116
117
118
119
# File 'lib/msf/base/sessions/hwbridge.rb', line 116

def reset_ui
  console.unset_log_source
  console.reset_ui
end

#shell_initObject

The shell will have been initialized by default.


194
195
196
# File 'lib/msf/base/sessions/hwbridge.rb', line 194

def shell_init
  return true
end

#typeObject

Calls the class method.


147
148
149
# File 'lib/msf/base/sessions/hwbridge.rb', line 147

def type
  self.class.type
end