Lucene search
K

Module to Probe Different Data Points in a CAN Packet

🗓️ 02 May 2017 21:19:29Reported by Craig SmithType 
metasploit
 metasploit
🔗 www.rapid7.com👁 37 Views

Module to Probe Different Data Points in a CAN Packet. Scans between two CAN IDs and writes data at each byte position. Does not check for responses and is a simple blind fuzzer

Code
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Post

  def initialize(info = {})
    super(
      update_info(
        info,
        'Name' => 'Module to Probe Different Data Points in a CAN Packet',
        'Description' => %q{
          Scans between two CAN IDs and writes data at each byte position. It will
          either write a set byte value (Default 0xFF) or iterate through all possible values
          of that byte position (takes much longer). Does not check for responses and is
          basically a simple blind fuzzer.
        },
        'License' => MSF_LICENSE,
        'Author' => ['Craig Smith'],
        'Platform' => ['hardware'],
        'SessionTypes' => ['hwbridge']
      )
    )
    register_options([
      OptInt.new('STARTID', [false, 'CAN ID to start scan', 0x300]),
      OptInt.new('STOPID', [false, 'CAN ID to stop scan', nil]),
      OptInt.new('PROBEVALUE', [false, 'Value to inject in the data stream', 0xFF]),
      OptInt.new('PADDING', [false, 'If a value is given a full 8 bytes will be used and padded with this value', nil]),
      OptBool.new('FUZZ', [false, 'If true interates through all possible values for each data position', false]),
      OptString.new('CANBUS', [false, 'CAN Bus to perform scan on, defaults to connected bus', nil])
    ])
  end

  def run
    unless client.automotive
      print_error('The hwbridge requires a functional automotive extention')
      return
    end
    stopid = datastore['STARTID']
    stopid = datastore['STOPID'] unless datastore['STOPID'].nil?
    data = '%02X' % datastore['PROBEVALUE']
    (datastore['STARTID']..stopid).each do |id|
      print_status("Probing 0x#{id.to_s(16)}...")
      8.times do |pos|
        padding = '00' * pos
        endpadding = ''
        endpadding = ('%02X' % datastore['PADDING']) * (7 - pos) if !datastore['PADDING'].nil?
        if datastore['FUZZ']
          256.times do |fuzzdata|
            client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + ('%02X' % fuzzdata) + endpadding)
          end
        else
          client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + data + endpadding)
        end
      end
    end
    print_status('Probe Complete')
  end
end

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation