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/canprobe.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Post67def initialize(info = {})8super(9update_info(10info,11'Name' => 'Module to Probe Different Data Points in a CAN Packet',12'Description' => %q{13Scans between two CAN IDs and writes data at each byte position. It will14either write a set byte value (Default 0xFF) or iterate through all possible values15of that byte position (takes much longer). Does not check for responses and is16basically a simple blind fuzzer.17},18'License' => MSF_LICENSE,19'Author' => ['Craig Smith'],20'Platform' => ['hardware'],21'SessionTypes' => ['hwbridge']22)23)24register_options([25OptInt.new('STARTID', [false, 'CAN ID to start scan', 0x300]),26OptInt.new('STOPID', [false, 'CAN ID to stop scan', nil]),27OptInt.new('PROBEVALUE', [false, 'Value to inject in the data stream', 0xFF]),28OptInt.new('PADDING', [false, 'If a value is given a full 8 bytes will be used and padded with this value', nil]),29OptBool.new('FUZZ', [false, 'If true interates through all possible values for each data position', false]),30OptString.new('CANBUS', [false, 'CAN Bus to perform scan on, defaults to connected bus', nil])31])32end3334def run35unless client.automotive36print_error('The hwbridge requires a functional automotive extention')37return38end39stopid = datastore['STARTID']40stopid = datastore['STOPID'] unless datastore['STOPID'].nil?41data = '%02X' % datastore['PROBEVALUE']42(datastore['STARTID']..stopid).each do |id|43print_status("Probing 0x#{id.to_s(16)}...")448.times do |pos|45padding = '00' * pos46endpadding = ''47endpadding = ('%02X' % datastore['PADDING']) * (7 - pos) if !datastore['PADDING'].nil?48if datastore['FUZZ']49256.times do |fuzzdata|50client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + ('%02X' % fuzzdata) + endpadding)51end52else53client.automotive.cansend(datastore['CANBUS'], id.to_s(16), padding + data + endpadding)54end55end56end57print_status('Probe Complete')58end59end606162