Diagnostic State - Metasploit


This page contains detailed information about how to use the post/hardware/automotive/diagnostic_state metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Diagnostic State
Module: post/hardware/automotive/diagnostic_state
Source code: modules/post/hardware/automotive/diagnostic_state.rb
Disclosure date: -
Last modification time: 2021-10-04 07:31:06 +0000
Supported architecture(s): -
Supported platform(s): Hardware
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module will keep the vehicle in a diagnostic state on rounds by sending tester present packet

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.

Stability:

  • crash-safe: Module should not crash the service.

Side Effects:

  • physical-effects: Module may produce physical effects (Examples: the device makes movement or flashes LEDs).

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/hardware/automotive/diagnostic_state

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/hardware/automotive/diagnostic_state
msf post(diagnostic_state) > show options
    ... show and set options ...
msf post(diagnostic_state) > set SESSION session-id
msf post(diagnostic_state) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/hardware/automotive/diagnostic_state")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Introduction


This module will keep the vehicle in a diagnostic state on rounds by sending tester present packet.

Verification Steps


Fire up virtual CAN bus:

  1. sudo modprobe can
  2. sudo modprobe vcan
  3. sudo ip link add dev vcan0 type vcan
  4. sudo ip link set up vcan0

Launch msf:

  1. Start msfconsole
  2. use auxiliary/server/local_hwbridge
  3. set uripath testbus
  4. run
  5. use auxiliary/client/hwbridge/connect
  6. set targeturi testbus

Options


Module options (post/hardware/automotive/diagnostic_state):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ARBID    0x7DF            no        CAN ID to perform Diagnostic State
   CANBUS                    no        CAN Bus to perform scan on, defaults to connected bus
   ROUNDS   500              yes       Number of executed rounds
   SESSION                   yes       The session to run this module on.

Scenarios


You can test this module doing a candump and you should receive a response for each can frame in a loop at 0x7E8 when running UDS Simulator.

msf5 auxiliary(client/hwbridge/connect) > run
[*] Running module against 127.0.0.1

[*] Attempting to connect to 127.0.0.1...
[*] Hardware bridge interface session 1 opened (127.0.0.1 -> 127.0.0.1) at 2019-09-11 04:59:40 -0700
[+] HWBridge session established
[*] HW Specialty: {"automotive"=>true}  Capabilities: {"can"=>true, "custom_methods"=>true}
[!] NOTICE:  You are about to leave the matrix.  All actions performed on this hardware bridge
[!]          could have real world consequences.  Use this module in a controlled testing
[!]          environment and with equipment you are authorized to perform testing on.
[*] Auxiliary module execution completed
msf5 auxiliary(client/hwbridge/connect) > sessions

Active sessions
===============

  Id  Name  Type                   Information  Connection
  --  ----  ----                   -----------  ----------
  1         hwbridge cmd/hardware  automotive   127.0.0.1 -> 127.0.0.1 (127.0.0.1)

msf5 auxiliary(client/hwbridge/connect) > sessions -i 1
[*] Starting interaction with 1...

hwbridge > run post/hardware/automotive/diagnostic_state canbus=vcan0

[*] Putting the vehicle in a diagnostic state...
[*] In order to keep the vehicle in this state, you need to continuously send a packet to let the vehicle know that a diagnostic technician is present.
hwbridge > 

You can use candump to verify the CAN messages being sent:

─$ candump vcan0          
└─$ candump vcan0
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E
  vcan0  7E8   [4]  03 7E 00 00
  vcan0  7DF   [2]  01 3E

-- snippet --

UDS Server Output
└─$ ./uds-server -v -V "PWN3D" vcan0 Using CAN interface vcan0 Fuzz level set to: 0 Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E Pkt: 7DF#01 3E

-- snippet --

Go back to menu.

Msfconsole Usage


Here is how the hardware/automotive/diagnostic_state post exploitation module looks in the msfconsole:

msf6 > use post/hardware/automotive/diagnostic_state

msf6 post(hardware/automotive/diagnostic_state) > show info

       Name: Diagnostic State
     Module: post/hardware/automotive/diagnostic_state
   Platform: Hardware
       Arch: 
       Rank: Normal

Provided by:
  Jay Turla

Module side effects:
 physical-effects

Module stability:
 crash-safe

Compatible session types:
  Hwbridge

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  ARBID    0x7DF            no        CAN ID to perform Diagnostic State
  CANBUS                    no        CAN Bus to perform scan on, defaults to connected bus
  ROUNDS   500              yes       Number of executed rounds
  SESSION                   yes       The session to run this module on.

Description:
  This module will keep the vehicle in a diagnostic state on rounds by 
  sending tester present packet

Module Options


This is a complete list of options available in the hardware/automotive/diagnostic_state post exploitation module:

msf6 post(hardware/automotive/diagnostic_state) > show options

Module options (post/hardware/automotive/diagnostic_state):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   ARBID    0x7DF            no        CAN ID to perform Diagnostic State
   CANBUS                    no        CAN Bus to perform scan on, defaults to connected bus
   ROUNDS   500              yes       Number of executed rounds
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the hardware/automotive/diagnostic_state post exploitation module:

msf6 post(hardware/automotive/diagnostic_state) > show advanced

Module advanced options (post/hardware/automotive/diagnostic_state):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the hardware/automotive/diagnostic_state module can do:

msf6 post(hardware/automotive/diagnostic_state) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the hardware/automotive/diagnostic_state post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(hardware/automotive/diagnostic_state) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

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.

The hwbridge requires a functional automotive extention


Here is a relevant code snippet related to the "The hwbridge requires a functional automotive extention" error message:

28:	    ])
29:	  end
30:	
31:	  def run
32:	    unless client.automotive
33:	      print_error('The hwbridge requires a functional automotive extention')
34:	      return
35:	    end
36:	    print_status('Putting the vehicle in a diagnostic state...')
37:	    print_status('In order to keep the vehicle in this state, you need to continuously send a packet to let the vehicle know that a diagnostic technician is present.')
38:	    datastore['ROUNDS'].times do

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Jay Turla

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.