Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/post/hardware/automotive/identifymodules.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post6include Msf::Post::Hardware::Automotive::UDS78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Scan CAN Bus for Diagnostic Modules',13'Description' => %q{ Post Module to scan the CAN bus for any modules that can respond to UDS DSC queries},14'License' => MSF_LICENSE,15'Author' => ['Craig Smith'],16'Platform' => ['hardware'],17'SessionTypes' => ['hwbridge']18)19)20register_options([21OptInt.new('STARTID', [true, 'Start scan from this ID', 0x600]),22OptInt.new('ENDID', [true, 'End scan at this ID', 0x7F7]),23OptString.new('CANBUS', [false, 'CAN Bus to perform scan on, defaults to connected bus', nil])24])25@found_id = []26end2728def run29scanned_ids = 030print_line('Starting scan...')31(datastore['STARTID']..datastore['ENDID']).each do |id|32res = set_dsc(datastore['CANBUS'], id, id + 8, 1)33scanned_ids += 134next if res.nil?35next unless res.key? 'Packets'36next unless res['Packets'].empty?3738if (res['Packets'][0].key? 'DATA') && res['Packets'][0]['DATA'].size > 3 && (res['Packets'][0]['DATA'][0].hex == 3 && res['Packets'][0]['DATA'][1].hex == 0x7f && res['Packets'][0]['DATA'][2].hex == 0x10)39print_status("Identified module #{'%3x' % id}")40@found_id << id41end42end43print_line("Scanned #{scanned_ids} IDs and found #{@found_id.size} modules that responded")44@found_id.each do |id|45print_line(" #{'%3x' % id}")46end47end48end495051