|
| 1 | +## Overview |
| 2 | + |
| 3 | +This module connects to any Hardware device that supports the HWBridge API. For details |
| 4 | +on the HWBridge API see [API Reference](http://opengarages.org/hwbridge). On successful connection to a HWBridge a |
| 5 | +HWBridge session will be established. |
| 6 | + |
| 7 | +## Devices |
| 8 | + |
| 9 | +When run on linux you can use the auxiliary/server/local_hwbridge to talk to any device supported by SocketCAN. |
| 10 | +It will work with natively supported devices (can), serial devices (slcan) and even virtual devices (vcan). For |
| 11 | +a list of supported SocketCAN hardware see the [eLinux website](http://elinux.org/CAN_Bus). |
| 12 | + |
| 13 | +Any ELM327 or STN1100 interface will work with the HWBridge. If you pick up any device that uses either of |
| 14 | +these chipsets can can connect via serial (USB or Bluetooth) it will work. These are popular and inexpensive |
| 15 | +devices. They are not as fast as some of the native CAN devices but they are plentiful and cheap. |
| 16 | + |
| 17 | +This module was also tested with the [Particle](https://Particle.io) Photon board. To utilize a Particle.io Photon board you |
| 18 | +will want to add the spark-msf-relay library to your project. See the library examples for details on |
| 19 | +how to extend your project to integrate it with Metasploit. If you are building an automotive project |
| 20 | +and you are using the [Carloop](https://carloop.io) then the spark-msf-relay library also includes an example app for carloop |
| 21 | +that you can simply flash to the device for full support. |
| 22 | + |
| 23 | +2. Generic ELM327: [ebay](http://www.ebay.com/itm/like/221821719820) |
| 24 | + |
| 25 | +## Bluetooth Adapter Connection |
| 26 | + |
| 27 | +Bluetooth HWBridge adapters, depending on the Operating System, may take several additional steps to establish a connection and communications bus. |
| 28 | +The following steps were [recorded during the testing of this module](https://github.com/rapid7/metasploit-framework/pull/7795#issuecomment-274302326) |
| 29 | +on setting up the [BAFX 34t5](https://bafxpro.com/products/obdreader) with Kali Linux 2016.2 (rolling). |
| 30 | + |
| 31 | +1. Ensure no locks on the Bluetooth device via: `rfkill list` (and subsequent `unblock` commands) |
| 32 | +2. Make sure Bluetooth service is started: `/etc/init.d/bluetooth start`, or `bluetoothd` |
| 33 | +3. Start bluetoothctl: `bluetoothctl` |
| 34 | +4. Turn on scanning: `scan on` |
| 35 | +5. Turn on agent: `agent on` |
| 36 | +6. Make sure we can see OBDII: `devices` |
| 37 | +7. Attempt to pair: `[bluetooth]# pair 00:0D:18:AA:AA:AA` |
| 38 | + |
| 39 | + ``` |
| 40 | + Attempting to pair with 00:0D:18:AA:AA:AA |
| 41 | + [CHG] Device 00:0D:18:AA:AA:AA Connected: yes |
| 42 | + ``` |
| 43 | +9. If prompted for pin: `1234` |
| 44 | +10. Trust the device in order to not put in the pin again: `trust 00:0D:18:AA:AA:AA` |
| 45 | +11. Use rfcomm to make the connection and serial interface in a different window (not bluetoothctl): `rfcomm connect /dev/rfcomm1 "00:0D:18:AA:AA:AA"` |
| 46 | + |
| 47 | +## Options |
| 48 | + |
| 49 | + **TARGETURI** |
| 50 | + |
| 51 | + Specifies the base target URI to communicate to the HWBridge API. By default this is '/' but it |
| 52 | + could be things such as '/api' or the randomly generated URI from the local_hwbridge module |
| 53 | + |
| 54 | + **DEBUGJSON** |
| 55 | + |
| 56 | + Prints out all the JSON packets that come from the HWBridge API. Useful for troubleshooting |
| 57 | + a device. |
| 58 | + |
| 59 | + This module also supports all the other HTTP Client options typical to Metaplsoit. |
| 60 | + |
| 61 | +## Sample Connection |
| 62 | + |
| 63 | +For an example, lets say we connect to a HW Bridge that is designed for automotive use |
| 64 | +and has support for multiple CAN buses. The remote device in our example is called 'carhax' |
| 65 | + |
| 66 | +``` |
| 67 | +msf > use auxiliary/client/hwbridge/connect |
| 68 | +msf auxiliary(connect) > set rhost carhax |
| 69 | +rhost => carhax |
| 70 | +msf auxiliary(connect) > run |
| 71 | +
|
| 72 | +[*] Attempting to connect to carhax... |
| 73 | +[*] Hardware bridge interface session 1 opened (127.0.0.1 -> 127.0.0.1) at 2016-12-29 13:49:55 -0800 |
| 74 | +[+] HWBridge session established |
| 75 | +[*] HW Specialty: {"automotive"=>true} Capabilities: {"can"=>true, "custom_methods"=>true} |
| 76 | +[!] NOTICE: You are about to leave the matrix. All actions performed on this hardware bridge |
| 77 | +[!] could have real world consequences. Use this module in a controlled testing |
| 78 | +[!] environment and with equipment you are authorized to perform testing on. |
| 79 | +[*] Auxiliary module execution completed |
| 80 | +``` |
| 81 | + |
| 82 | +On successful connection to a Hardware device you will be prompted with a special notice to |
| 83 | +remind you that any action you take on the HWBridge could have physical affects and consequences. |
| 84 | +Our lawyers asked us to put that there. You can verify the session was created by type 'sessions' |
| 85 | + |
| 86 | +``` |
| 87 | +msf auxiliary(connect) > sessions |
| 88 | +
|
| 89 | +Active sessions |
| 90 | +=============== |
| 91 | +
|
| 92 | + Id Type Information Connection |
| 93 | + -- ---- ----------- ---------- |
| 94 | + 1 hwbridge cmd/hardware automotive 127.0.0.1 -> 127.0.0.1 (10.1.10.21) |
| 95 | +
|
| 96 | +``` |
| 97 | +## Automotive Extension |
| 98 | + |
| 99 | +If a device specifies a hw_specialty then it can load custom extensions. For instance, if |
| 100 | +a defice defines its specialty is automotive then Metasploit will load a custom automotive |
| 101 | +extension that gives you a few generic commands you can use on autotive systems such as the |
| 102 | +ability to send arbitrary CAN packets down the bus. It also allows you to run any |
| 103 | +post/hardware/automotive modules. |
| 104 | + |
| 105 | +For instance you can run post/hardware/automtive/getvinfo to retrieve vehicle information |
| 106 | +via UDS Mode $9 commands. |
| 107 | + |
| 108 | +``` |
| 109 | +hwbridge > run post/hardware/automotive/getvinfo CANBUS=can2 |
| 110 | +
|
| 111 | +[*] Supported PIDS: [2, 4, 6, 8] |
| 112 | +[*] VIN: 1G1ZT53826F109149 |
| 113 | +[*] Calibration ID: x |
| 114 | +[*] PID 6 Response: ["00", "00", "C4", "E9", "00", "00", "17", "33", "00", "00", "00", "00"] |
| 115 | +[*] PID 8 Response: ["00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00", "00"] |
| 116 | +``` |
| 117 | +run 'supported_buses' for a list of available buses provided by your hardware. And as always you can |
| 118 | +type 'help' for a list of available commands and each command should support '-h' to additional |
| 119 | +argument help. |
| 120 | + |
| 121 | +## Custom Method Extension |
| 122 | + |
| 123 | +It is possible for the hardware device to report functionality that Metasploit has no knowledge |
| 124 | +of. For instance, perhaps the device has a unique capability that isn't standard or can be done |
| 125 | +100% in hardware. In order to utilize that functionality the HW device can report that it has |
| 126 | +custom_methods as a capability. At which point Metasploit will then query the custom methods |
| 127 | +and their argument syntax. These methods will become available as command line options |
| 128 | +within the hardware bridge. |
| 129 | + |
| 130 | +For a simple example of a custom method see auxiliary/server/local_hwbridge for a more complete |
| 131 | +list on how to define custom methods see the [API Reference](http://opengarages.org/hwbridge). |
0 commit comments