Hardware Bridge Server - Metasploit


This page contains detailed information about how to use the auxiliary/server/local_hwbridge metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Hardware Bridge Server
Module: auxiliary/server/local_hwbridge
Source code: modules/auxiliary/server/local_hwbridge.rb
Disclosure date: -
Last modification time: 2020-05-12 22:15:21 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module sets up a web server to bridge communications between Metasploit and physically attached hardware. Currently this module supports: automotive

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


msf > use auxiliary/server/local_hwbridge
msf auxiliary(local_hwbridge) > exploit

Knowledge Base


Overview


This is a sample hardware bridge that demonstrates how to connect the HWBridge API to metasploit. It demonstrates some bare minimum capabilities to report back to the hardware connector and establish a hwbridge session. This module provides an example on how to connect any hardware component to Metasploit. It is also a fully functional interface to SocketCAN and will work to create an automotive HW Bridge.

Setup a Test


To experimient with using Metasploit to send automtovie CAN bus packets you can use the SocketCAN capabilities of Linux to create a virtual CAN device. NOTE: If you have a supported CAN sniffer you could also use a real can device.

In order for the local_hwbridge to inteface with SocketCAN you will need:

  • can-utils

Once those are installed you can setup a virtual CAN inteface using:

sudo modprobe can
sudo modprobe vcan
sudo ip link add dev vcan0 type vcan
sudo ip link set up vcan0

Once that is setup you can simply launch the module and it should auto detect any CAN intefaces you have active on the system.

msf > use auxiliary/server/local_hwbridge 
msf auxiliary(local_hwbridge) > run
[*] Auxiliary module execution completed

[*] Using URL: http://0.0.0.0:8080/xaUKu68Va
[*] Local IP: http://10.1.10.21:8080/xaUKu68Va
[*] Server started.

By default it will create a random URI, in this case it's xaUKu68Va.

Connecting to the HWBridge


You will need to use the auxiliary/client/hwbridge/connect to connect to the local_hwbridge. You can either use the same machine or another machine to connect to your local_hwbridge. Just make sure the TARGETURI matches the randomly generated URI

set TARGETURI xaUKu68Va

Then simply type run and you should connect to the HW bridge and a hwbridge session should be established. You can switch to the hwbridge session to interact with this module.

See the documentation for auxiliary/client/hwbridge/connect for more information on the hwbridge sessions.

Go back to menu.

Msfconsole Usage


Here is how the server/local_hwbridge auxiliary module looks in the msfconsole:

msf6 > use auxiliary/server/local_hwbridge

msf6 auxiliary(server/local_hwbridge) > show info

       Name: Hardware Bridge Server
     Module: auxiliary/server/local_hwbridge
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Craig Smith

Available actions:
  Name       Description
  ----       -----------
  WebServer  Run HWBridge web server

Check supported:
  No

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
  SRVPORT  8080             yes       The local port to listen on.
  SSL      false            no        Negotiate SSL for incoming connections
  SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
  URIPATH                   no        The URI to use for this exploit (default is random)

Description:
  This module sets up a web server to bridge communications between 
  Metasploit and physically attached hardware. Currently this module 
  supports: automotive

Module Options


This is a complete list of options available in the server/local_hwbridge auxiliary module:

msf6 auxiliary(server/local_hwbridge) > show options

Module options (auxiliary/server/local_hwbridge):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SRVHOST  0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT  8080             yes       The local port to listen on.
   SSL      false            no        Negotiate SSL for incoming connections
   SSLCert                   no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH                   no        The URI to use for this exploit (default is random)

Auxiliary action:

   Name       Description
   ----       -----------
   WebServer  Run HWBridge web server

Advanced Options


Here is a complete list of advanced options supported by the server/local_hwbridge auxiliary module:

msf6 auxiliary(server/local_hwbridge) > show advanced

Module advanced options (auxiliary/server/local_hwbridge):

   Name            Current Setting  Required  Description
   ----            ---------------  --------  -----------
   ListenerComm                     no        The specific communication channel to use for this service
   SSLCipher                        no        String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
   SSLCompression  false            no        Enable SSL/TLS-level compression
   SendRobots      false            no        Return a robots.txt file if asked for one
   URIHOST                          no        Host to use in URI (useful for tunnels)
   URIPORT                          no        Port to use in URI (useful for tunnels)
   VERBOSE         false            no        Enable detailed status messages
   WORKSPACE                        no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the server/local_hwbridge module can do:

msf6 auxiliary(server/local_hwbridge) > show actions

Auxiliary actions:

   Name       Description
   ----       -----------
   WebServer  Run HWBridge web server

Evasion Options


Here is the full list of possible evasion options supported by the server/local_hwbridge auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(server/local_hwbridge) > show evasion

Module evasion options:

   Name                      Current Setting  Required  Description
   ----                      ---------------  --------  -----------
   HTML::base64              none             no        Enable HTML obfuscation via an embeded base64 html object (IE not supported) (Accepted: none, plain, single_pad, double_pad, random_space_injection)
   HTML::javascript::escape  0                no        Enable HTML obfuscation via HTML escaping (number of iterations)
   HTML::unicode             none             no        Enable HTTP obfuscation via unicode (Accepted: none, utf-16le, utf-16be, utf-16be-marker, utf-32le, utf-32be)
   HTTP::chunked             false            no        Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
   HTTP::compression         none             no        Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
   HTTP::header_folding      false            no        Enable folding of HTTP headers
   HTTP::junk_headers        false            no        Enable insertion of random junk HTTP headers
   HTTP::no_cache            false            no        Disallow the browser to cache HTTP content
   HTTP::server_name         Apache           yes       Configures the Server header of all outgoing replies
   TCP::max_send_size        0                no        Maximum tcp segment size.  (0 = disable)
   TCP::send_delay           0                no        Delays inserted before every send.  (0 = disable)

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

last_10_errors


Here is a relevant code snippet related to the "last_10_errors" error message:

54:	  def get_status
55:	    status = {}
56:	    status["operational"] = @operational_status
57:	    status["hw_specialty"] = {}
58:	    status["hw_capabilities"] = {}
59:	    status["last_10_errors"] = @last_errors # NOTE: no support for this yet
60:	    status["api_version"] = HWBRIDGE_API_VERSION
61:	    status["fw_version"] = "not supported"
62:	    status["hw_version"] = "not supported"
63:	    unless @can_interfaces.empty?
64:	      status["hw_specialty"]["automotive"] = true

Data section can only contain a max of 8 bytes


Here is a relevant code snippet related to the "Data section can only contain a max of 8 bytes" error message:

120:	    result = {}
121:	    result["Success"] = false
122:	    id = id.to_i(16).to_s(16)  # Clean up the HEX
123:	    bytes = data.scan(/../)  # Break up data string into 2 char (byte) chunks
124:	    if bytes.size > 8
125:	      print_error("Data section can only contain a max of 8 bytes")
126:	      return result
127:	    end
128:	    `which cansend`
129:	    unless $?.success?
130:	      print_error("cansend from can-utils not found in path")

cansend from can-utils not found in path


Here is a relevant code snippet related to the "cansend from can-utils not found in path" error message:

125:	      print_error("Data section can only contain a max of 8 bytes")
126:	      return result
127:	    end
128:	    `which cansend`
129:	    unless $?.success?
130:	      print_error("cansend from can-utils not found in path")
131:	      return result
132:	    end
133:	    @can_interfaces.each do |can|
134:	      if can == bus
135:	        system("cansend #{bus} #{id}##{bytes.join}")

Data section currently has to be less than 8 bytes


Here is a relevant code snippet related to the "Data section currently has to be less than 8 bytes" error message:

188:	    maxpkts = opt['MAXPKTS'] if opt.key? 'MAXPKTS'
189:	    padding = opt['PADDING'] if opt.key? 'PADDING'
190:	    flowcontrol = opt['FC'] if opt.key? 'FC'
191:	    bytes = data.scan(/../)
192:	    if bytes.size > 8
193:	      print_error("Data section currently has to be less than 8 bytes")
194:	      return result
195:	    else
196:	      sz = "%02x" % bytes.size
197:	      bytes = sz + bytes.join
198:	    end

cansend from can-utils not found in path


Here is a relevant code snippet related to the "cansend from can-utils not found in path" error message:

201:	      bytes += ([ padding ] * (16 - bytes.size)).join
202:	    end
203:	    # Should we ever require isotpsend for this?
204:	    `which cansend`
205:	    unless $?.success?
206:	      print_error("cansend from can-utils not found in path")
207:	      return result
208:	    end
209:	    @can_interfaces.each do |can|
210:	      if can == bus
211:	        if flowcontrol

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Craig Smith

Version


This page has been produced using Metasploit Framework version 6.1.24-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.