SlideShare uma empresa Scribd logo
1 de 50
Baixar para ler offline
Hacking The TomTom Runner Part 2
Vulnerability Research and Exploitation of an IoT Device
Luis Grangeia | @lgrangeia
October 2015
Confraria de Segurança da Informação
Overview
• Disclaimer
• Brag
• From Vulnerability to Exploit:
• Controlling execution
• Exfiltrating data
• Bootloader
• Firmware encryption
• Firmware validation
• Risk Assessment + Recommendations
Disclaimer
“I’m not a lawyer”
Disclaimer
1. Security research should not be illegal
2. TomTom has been contacted and has full
details of vulnerabilities
3. TomTom has mitigated the vulnerability in
a recent firmware version
(though it does not completely prevent the problem…)
Brag
“Mom, I did it.”
Brag
• I found and took advantage of a memory
corruption vulnerability,
• And used it to gain control of a closed
embedded system running proprietary software
• A few security hurdles had to be crossed
• Fellow hackers helped
• hello pmsac and poupas!
• No screwdriver or hardware hacking tricks were
used
Starting Point
•One TomTom Runner GPS
Watch
•Encrypted Firmware
updates
Finish Line
•Ability to modify existing
firmware and flash it on the
watch
•Fun ideas for the future:
• Implement phone
notifications on watch
• Use watch as a hacking
platform
(wrist worn ubertooth!)
From Vulnerability to Exploit
“opening” the device
• Atmel ATSAM4S8C
• Main “CPU” (MCU):
• Micron N25Q032A13ESC40F
• Serial flash memory (4MB)
• Texas Instruments CC2541:
• Bluetooth Module
• CSR SiRF starV 5e GNSS
• GPS Module (off screen)
• Main Firmware file
• Firmware for the GPS Module
• Language resource files (eng / ger/
por / etc.)
• Manifest files (configuration
settings)
• Firmware for the BLE Module
EEPROM File structure
• Device contains 4MB EEPROM with a primitive filesystem
• Each file can be read or written to via USB (and
bluetooth)
• Name structure is 32 bit values
• Coincident with firmware files
EEPROM File structure
Firmware Upgrade
MCU Atmel
EEPROM
PC
(Via USB)
1
Internal
Flash
2
3
1. Put firmware file on the EEPROM memory
2. Bootloader verifies presence of new firmware
on EEPROM, verifies if it’s valid
3. Bootloader decrypts firmware and writes it on
internal flash
Vulnerability
•Ability to crash the watch with a large
language file
•Got to control execution
• How?
Language Files
• List of NUL terminated
ASCII strings
• First 4 bytes: length of all
strings inc. nulls (little
endian)
• Next 4 bytes: number of
strings (little endian)
Big language file
• String buffer
over 6000
bytes
• Result: Crash!
Language files
• Device resets (interesting)…
• A mistery file appears (0x00013000)…
First crash!
Address Space
• Collected a LOT of crash dumps
• Read (and must read more) ARM documentation
• Note:
• This is an ARM Cortex M4 CPU
• Works in ARM Thumb-32 mode exclusively
• No ASLR (predictable)
• Not many memory controls (SRAM is executable)
• LR [R14] =
0x00426a75
subroutine call return
address
• PC [R15] =
0x2001bf54 program
counter
• We’re in SRAM (heap
or stack)
• Return address is in
Flash region
• Nice.
Google brain implant FTW
http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/
Language Files
After some fiddling...
R0 = 0x00000000
R1 = 0xffffffe3
R2 = 0x00000002
R3 = 0x00000029
R12 = 0x00000000
LR [R14] = 0x00441939 subroutine call return
address
PC [R15] = 0x000000cc program counter
Bedside Reading for the last two months
Masterplan for exploitation
1. Exfiltrate memory regions via loading values
into registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
1. Load Values into registers and crash
.syntax unified
.thumb
// Load VTOR address
ldr r2, =0xE000ED08
ldr r3, [r2]
// add offset to hardfault function ptr
mov r1, #0x04
add r2, r3, r1
// load hardfault address
ldr r3, [r2]
// This crashes always (explain why)
mov r1, #0x00
bx r1
• 0xe000ed08 - Vector Table
Offset Register
• Get address of VTOR
• Get address of hardfault
function (0x0040bfa1 on 1.8.42)
Masterplan for exploitation
1. Exfiltrate memory regions via loading values into
registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
2. Find crash routine and modify it to
improve bandwidth
• Slowly dumped crash handler and sub-routines
• Method: load addresses into registers, crash
• Wrote a script to read crash files and build a binary for
disassembly
2. Find crash routine and modify it to
improve bandwidth
• Crash handler does:
• Read some addresses
• Calls functions
• sprintf()’s the crashlog string to a string in the stack
• calls a fwrite()-like function to dump that string into the
EEPROM
Modified crash function (1/2)
.syntax unified
.thumb
// save lr, resize stack
push {r0-r12, lr}
sub.w sp, sp, #616
bl fillup
// Arguments for write()
mov.w r1, #512
add r0, sp, #100
// call write()
ldr r7, =0x00410e39
blx r7
/* shrink back stack */
add.w sp, sp, #616
pop {r0-r12, lr}
bx lr
• Rewritten crash function
• Does not crash 
• Dumps 372 bytes of memory
per call
Modified crash function (2/2)
fillup:
add r4, sp, #100
// “Crashlog” string
ldr r7, =0x73617243
str r7, [r4], #4
ldr r7, =0x676f6c68
str r7, [r4], #4
// Base address of ROM read:
ldr r7, =0x00408706
add r4, sp, #108
mov r3, #94
lp1:
ldr r8, [r7], #4
str r8, [r4], #4
sub r3, #1
cbz r3, end
b lp1
end:
bx lr
• Rewritten crash function
• Does not crash 
• Dumps 372 bytes of memory
per call
Other fun payloads written
• Wrote another payload to find ASCII strings on the
flash address space and dump that region
• (too big to fit in a slide)
Masterplan for exploitation
1. Exfiltrate memory regions via loading values into
registers and crashing
• Very little bandwidth (~24 bytes per crash)
2. Find crash routine and modify it to improve
bandwidth
3. Dump the bootloader to extract AES keys
Dump the bootloader to extract AES keys
• Dumped the entire Bootloader section
• 0x00400000 - 0x00408000
• Took around 90 device reboots (32kb)
• Bootloader has to:
• Initialize device
• Check for presence of new firmware file
• Validate, decrypt, and flash new firmware
• Boot into main firmware
• AES key must be present!
Dump the bootloader to extract AES keys
• Loaded bootloader.bin into IDA PRO
• Found interesting data structures:
• AES S-Boxes
• MD5 Init functions and data structures
• Firmware upgrade function
Firmware upgrade function
• This is the graph of the firmware
upgrade function
• Two different MD5 checks
• AES decryption
Finding the AES key
• AES protocol “expands” the original key into a number of
separate round keys. AES 128 produces 11 round keys on
this process.
• I found the AES key expansion function expanding a key
from RAM.
• Later I found the key was loaded into RAM from flash
earlier in the exec flow.
• The key from flash is not the correct key!
• What sort of magic is this?
Finding the AES key – QEMU Debugging
• Used QEMU + IDA to “step through” the execution of the
bootloader
• Lots of problems here: QEMU does not cleanly emulate
this MCU – Had to change some addresses/registers
while debugging
• Stepped through:
• The key loading from Flash
• Jumped to the AES key expansion function
Finding the AES key – QEMU Debugging
• Turns out that the AES key expansion function was
modifying a single byte of the original key from flash
• Firmware key obtained from memory
• Eureka moment right here 
• This defeats bruteforcing through the bootloader’s
bytestream for the AES key
• Clever move by TomTom that increased attack cost by
several nights worth of sleep 
Firmware key
• We can now decrypt the firmware files from
download.tomtom.com
• AES 128 / ECB mode, as predicted 
• Still not totally clean: Some sort of “glitch” on first byte
of every 16 byte block:
• pmsac cracked this! (explain how!)
Firmware deobfuscation
Firmware deobfuscation
Firmware validation
• Firmware file is validated before flashing
• MD5 is used here, twice:
• An outter MD5 (cyphertext+AESKey)
• Poor man’s HMAC
• An inner MD5: MD5(plaintextfirmware)
• Poupas helped a lot on this
Risk Assessment
Vulnerability
• Firmware upgrade path is compromised
• Can flash any watch with modded firmware /
backdoor with physical access to it
• Can remotely implant a backdoor by doing a
MiTM attack to ‘download.tomtom.com’
• Can enable hidden functions on cheaper devices
(ie. Turn a TomTom Runner into a Multisport)
Risk
•Risk to users is fairly low
•Risk to TomTom is unknown:
• hardware can be used to run “homebrew”
firmware
• Might actually be good for sales
Recommendation
•Use SSL for download.tomtom.com!
•Use RSA / assymetric crypto to sign firmware
•Prevent firmware downgrades
•Must upgrade bootloader in the field
• quite a bit risky, but can be done
Reward to hackers
Thanks!
Questions?
Luis Grangeia | @lgrangeia
October 2015
Confraria de Segurança da Informação

Mais conteúdo relacionado

Mais procurados (13)

DDR2 SDRAM
DDR2 SDRAMDDR2 SDRAM
DDR2 SDRAM
 
Memoria principal
Memoria principalMemoria principal
Memoria principal
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Vhdl 1
Vhdl 1Vhdl 1
Vhdl 1
 
Rtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffsRtl design optimizations and tradeoffs
Rtl design optimizations and tradeoffs
 
Ec8791 lpc2148 timer unit
Ec8791 lpc2148 timer unitEc8791 lpc2148 timer unit
Ec8791 lpc2148 timer unit
 
Risc processors
Risc processorsRisc processors
Risc processors
 
2. block diagram and components of embedded system
2. block diagram and components of embedded system2. block diagram and components of embedded system
2. block diagram and components of embedded system
 
Introduction to Microcontroller
Introduction to MicrocontrollerIntroduction to Microcontroller
Introduction to Microcontroller
 
Aula 07 pino 1 e soquetes
Aula 07 pino 1 e soquetesAula 07 pino 1 e soquetes
Aula 07 pino 1 e soquetes
 
Apresentaçao Avarias e Soluçoes
Apresentaçao Avarias e Soluçoes Apresentaçao Avarias e Soluçoes
Apresentaçao Avarias e Soluçoes
 
Introduction to Avr Microcontrollers
Introduction to Avr MicrocontrollersIntroduction to Avr Microcontrollers
Introduction to Avr Microcontrollers
 
7 วิชาสามัญ ภาษาไทย 56
7 วิชาสามัญ ภาษาไทย 567 วิชาสามัญ ภาษาไทย 56
7 วิชาสามัญ ภาษาไทย 56
 

Semelhante a Reverse Engineering the TomTom Runner pt. 2

Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Pythoninfodox
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Alexander Bolshev
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010idsecconf
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CanSecWest
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013midnite_runr
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Priyanka Aash
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010Tsukasa Oi
 
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.Atollic
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devicesYashin Mehaboobe
 
Exploiting the windows kernel
Exploiting the windows kernelExploiting the windows kernel
Exploiting the windows kernelJapneet Singh
 
Demystifying Secure enclave processor
Demystifying Secure enclave processorDemystifying Secure enclave processor
Demystifying Secure enclave processorPriyanka Aash
 
Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4Digital Bond
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...Arti Parab Academics
 
BIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptxBIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptxSamiWhoo
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONLyon Yang
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesScott K. Larson
 
Solnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsecSolnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsecPacSecJP
 
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveDEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveFelipe Prado
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangLyon Yang
 

Semelhante a Reverse Engineering the TomTom Runner pt. 2 (20)

Steelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with PythonSteelcon 2014 - Process Injection with Python
Steelcon 2014 - Process Injection with Python
 
Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...Practical reverse engineering and exploit development for AVR-based Embedded ...
Practical reverse engineering and exploit development for AVR-based Embedded ...
 
Micro control idsecconf2010
Micro control idsecconf2010Micro control idsecconf2010
Micro control idsecconf2010
 
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
 
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
Patching Windows Executables with the Backdoor Factory | DerbyCon 2013
 
Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.Breaking Smart Speakers: We are Listening to You.
Breaking Smart Speakers: We are Listening to You.
 
A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010A New Tracer for Reverse Engineering - PacSec 2010
A New Tracer for Reverse Engineering - PacSec 2010
 
Advanced Windows Exploitation
Advanced Windows ExploitationAdvanced Windows Exploitation
Advanced Windows Exploitation
 
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
Advanced debugging on ARM Cortex devices such as STM32, Kinetis, LPC, etc.
 
Making and breaking security in embedded devices
Making and breaking security in embedded devicesMaking and breaking security in embedded devices
Making and breaking security in embedded devices
 
Exploiting the windows kernel
Exploiting the windows kernelExploiting the windows kernel
Exploiting the windows kernel
 
Demystifying Secure enclave processor
Demystifying Secure enclave processorDemystifying Secure enclave processor
Demystifying Secure enclave processor
 
Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4Project Basecamp: News From Camp 4
Project Basecamp: News From Camp 4
 
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV  Designing Embedded System with 8051...
SYBSC IT SEM IV EMBEDDED SYSTEMS UNIT IV Designing Embedded System with 8051...
 
BIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptxBIOS__Power-On-Self-Test.pptx
BIOS__Power-On-Self-Test.pptx
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniquesLarson Macaulay apt_malware_past_present_future_out_of_band_techniques
Larson Macaulay apt_malware_past_present_future_out_of_band_techniques
 
Solnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsecSolnik secure enclaveprocessor-pacsec
Solnik secure enclaveprocessor-pacsec
 
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't driveDEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
DEF CON 27 - JESSE MICHAEL - get off the kernel if you can't drive
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 

Mais de Luis Grangeia

Inteligência Artificial: Breve Introdução
Inteligência Artificial: Breve IntroduçãoInteligência Artificial: Breve Introdução
Inteligência Artificial: Breve IntroduçãoLuis Grangeia
 
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find ThemBSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find ThemLuis Grangeia
 
Heartbleed && Wireless
Heartbleed && WirelessHeartbleed && Wireless
Heartbleed && WirelessLuis Grangeia
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Luis Grangeia
 
RSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do InfosecRSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do InfosecLuis Grangeia
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and FutureLuis Grangeia
 
IBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointIBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointLuis Grangeia
 
Confraria Security And IT - End Point Security
Confraria Security And IT - End Point SecurityConfraria Security And IT - End Point Security
Confraria Security And IT - End Point SecurityLuis Grangeia
 

Mais de Luis Grangeia (9)

Inteligência Artificial: Breve Introdução
Inteligência Artificial: Breve IntroduçãoInteligência Artificial: Breve Introdução
Inteligência Artificial: Breve Introdução
 
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find ThemBSides Lisbon 2017 - Fantastic Signals and Where to Find Them
BSides Lisbon 2017 - Fantastic Signals and Where to Find Them
 
Computer Forensics
Computer ForensicsComputer Forensics
Computer Forensics
 
Heartbleed && Wireless
Heartbleed && WirelessHeartbleed && Wireless
Heartbleed && Wireless
 
Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...Man vs Internet - Current challenges and future tendencies of establishing tr...
Man vs Internet - Current challenges and future tendencies of establishing tr...
 
RSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do InfosecRSA, A Vaca Sagrada do Infosec
RSA, A Vaca Sagrada do Infosec
 
SSL: Past, Present and Future
SSL: Past, Present and FutureSSL: Past, Present and Future
SSL: Past, Present and Future
 
IBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's StandpointIBWAS 2010: Web Security From an Auditor's Standpoint
IBWAS 2010: Web Security From an Auditor's Standpoint
 
Confraria Security And IT - End Point Security
Confraria Security And IT - End Point SecurityConfraria Security And IT - End Point Security
Confraria Security And IT - End Point Security
 

Último

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniquesugginaramesh
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxPurva Nikam
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfAsst.prof M.Gokilavani
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfme23b1001
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 

Último (20)

Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Comparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization TechniquesComparative Analysis of Text Summarization Techniques
Comparative Analysis of Text Summarization Techniques
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
An introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptxAn introduction to Semiconductor and its types.pptx
An introduction to Semiconductor and its types.pptx
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdfCCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
CCS355 Neural Networks & Deep Learning Unit 1 PDF notes with Question bank .pdf
 
Electronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdfElectronically Controlled suspensions system .pdf
Electronically Controlled suspensions system .pdf
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 

Reverse Engineering the TomTom Runner pt. 2

  • 1. Hacking The TomTom Runner Part 2 Vulnerability Research and Exploitation of an IoT Device Luis Grangeia | @lgrangeia October 2015 Confraria de Segurança da Informação
  • 2. Overview • Disclaimer • Brag • From Vulnerability to Exploit: • Controlling execution • Exfiltrating data • Bootloader • Firmware encryption • Firmware validation • Risk Assessment + Recommendations
  • 4. Disclaimer 1. Security research should not be illegal 2. TomTom has been contacted and has full details of vulnerabilities 3. TomTom has mitigated the vulnerability in a recent firmware version (though it does not completely prevent the problem…)
  • 6. Brag • I found and took advantage of a memory corruption vulnerability, • And used it to gain control of a closed embedded system running proprietary software • A few security hurdles had to be crossed • Fellow hackers helped • hello pmsac and poupas! • No screwdriver or hardware hacking tricks were used
  • 7. Starting Point •One TomTom Runner GPS Watch •Encrypted Firmware updates
  • 8. Finish Line •Ability to modify existing firmware and flash it on the watch •Fun ideas for the future: • Implement phone notifications on watch • Use watch as a hacking platform (wrist worn ubertooth!)
  • 10. “opening” the device • Atmel ATSAM4S8C • Main “CPU” (MCU): • Micron N25Q032A13ESC40F • Serial flash memory (4MB) • Texas Instruments CC2541: • Bluetooth Module • CSR SiRF starV 5e GNSS • GPS Module (off screen)
  • 11. • Main Firmware file • Firmware for the GPS Module • Language resource files (eng / ger/ por / etc.) • Manifest files (configuration settings) • Firmware for the BLE Module
  • 12. EEPROM File structure • Device contains 4MB EEPROM with a primitive filesystem • Each file can be read or written to via USB (and bluetooth) • Name structure is 32 bit values • Coincident with firmware files
  • 14. Firmware Upgrade MCU Atmel EEPROM PC (Via USB) 1 Internal Flash 2 3 1. Put firmware file on the EEPROM memory 2. Bootloader verifies presence of new firmware on EEPROM, verifies if it’s valid 3. Bootloader decrypts firmware and writes it on internal flash
  • 15. Vulnerability •Ability to crash the watch with a large language file •Got to control execution • How?
  • 16. Language Files • List of NUL terminated ASCII strings • First 4 bytes: length of all strings inc. nulls (little endian) • Next 4 bytes: number of strings (little endian)
  • 17. Big language file • String buffer over 6000 bytes • Result: Crash!
  • 18. Language files • Device resets (interesting)… • A mistery file appears (0x00013000)…
  • 20. Address Space • Collected a LOT of crash dumps • Read (and must read more) ARM documentation • Note: • This is an ARM Cortex M4 CPU • Works in ARM Thumb-32 mode exclusively • No ASLR (predictable) • Not many memory controls (SRAM is executable)
  • 21. • LR [R14] = 0x00426a75 subroutine call return address • PC [R15] = 0x2001bf54 program counter • We’re in SRAM (heap or stack) • Return address is in Flash region • Nice.
  • 22. Google brain implant FTW http://blog.frankvh.com/2011/12/07/cortex-m3-m4-hard-fault-handler/
  • 24. After some fiddling... R0 = 0x00000000 R1 = 0xffffffe3 R2 = 0x00000002 R3 = 0x00000029 R12 = 0x00000000 LR [R14] = 0x00441939 subroutine call return address PC [R15] = 0x000000cc program counter
  • 25. Bedside Reading for the last two months
  • 26. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 27. 1. Load Values into registers and crash .syntax unified .thumb // Load VTOR address ldr r2, =0xE000ED08 ldr r3, [r2] // add offset to hardfault function ptr mov r1, #0x04 add r2, r3, r1 // load hardfault address ldr r3, [r2] // This crashes always (explain why) mov r1, #0x00 bx r1 • 0xe000ed08 - Vector Table Offset Register • Get address of VTOR • Get address of hardfault function (0x0040bfa1 on 1.8.42)
  • 28. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 29. 2. Find crash routine and modify it to improve bandwidth • Slowly dumped crash handler and sub-routines • Method: load addresses into registers, crash • Wrote a script to read crash files and build a binary for disassembly
  • 30. 2. Find crash routine and modify it to improve bandwidth • Crash handler does: • Read some addresses • Calls functions • sprintf()’s the crashlog string to a string in the stack • calls a fwrite()-like function to dump that string into the EEPROM
  • 31. Modified crash function (1/2) .syntax unified .thumb // save lr, resize stack push {r0-r12, lr} sub.w sp, sp, #616 bl fillup // Arguments for write() mov.w r1, #512 add r0, sp, #100 // call write() ldr r7, =0x00410e39 blx r7 /* shrink back stack */ add.w sp, sp, #616 pop {r0-r12, lr} bx lr • Rewritten crash function • Does not crash  • Dumps 372 bytes of memory per call
  • 32. Modified crash function (2/2) fillup: add r4, sp, #100 // “Crashlog” string ldr r7, =0x73617243 str r7, [r4], #4 ldr r7, =0x676f6c68 str r7, [r4], #4 // Base address of ROM read: ldr r7, =0x00408706 add r4, sp, #108 mov r3, #94 lp1: ldr r8, [r7], #4 str r8, [r4], #4 sub r3, #1 cbz r3, end b lp1 end: bx lr • Rewritten crash function • Does not crash  • Dumps 372 bytes of memory per call
  • 33. Other fun payloads written • Wrote another payload to find ASCII strings on the flash address space and dump that region • (too big to fit in a slide)
  • 34. Masterplan for exploitation 1. Exfiltrate memory regions via loading values into registers and crashing • Very little bandwidth (~24 bytes per crash) 2. Find crash routine and modify it to improve bandwidth 3. Dump the bootloader to extract AES keys
  • 35. Dump the bootloader to extract AES keys • Dumped the entire Bootloader section • 0x00400000 - 0x00408000 • Took around 90 device reboots (32kb) • Bootloader has to: • Initialize device • Check for presence of new firmware file • Validate, decrypt, and flash new firmware • Boot into main firmware • AES key must be present!
  • 36. Dump the bootloader to extract AES keys • Loaded bootloader.bin into IDA PRO • Found interesting data structures: • AES S-Boxes • MD5 Init functions and data structures • Firmware upgrade function
  • 37. Firmware upgrade function • This is the graph of the firmware upgrade function • Two different MD5 checks • AES decryption
  • 38. Finding the AES key • AES protocol “expands” the original key into a number of separate round keys. AES 128 produces 11 round keys on this process. • I found the AES key expansion function expanding a key from RAM. • Later I found the key was loaded into RAM from flash earlier in the exec flow. • The key from flash is not the correct key! • What sort of magic is this?
  • 39. Finding the AES key – QEMU Debugging • Used QEMU + IDA to “step through” the execution of the bootloader • Lots of problems here: QEMU does not cleanly emulate this MCU – Had to change some addresses/registers while debugging • Stepped through: • The key loading from Flash • Jumped to the AES key expansion function
  • 40. Finding the AES key – QEMU Debugging • Turns out that the AES key expansion function was modifying a single byte of the original key from flash • Firmware key obtained from memory • Eureka moment right here  • This defeats bruteforcing through the bootloader’s bytestream for the AES key • Clever move by TomTom that increased attack cost by several nights worth of sleep 
  • 41. Firmware key • We can now decrypt the firmware files from download.tomtom.com • AES 128 / ECB mode, as predicted  • Still not totally clean: Some sort of “glitch” on first byte of every 16 byte block: • pmsac cracked this! (explain how!)
  • 44. Firmware validation • Firmware file is validated before flashing • MD5 is used here, twice: • An outter MD5 (cyphertext+AESKey) • Poor man’s HMAC • An inner MD5: MD5(plaintextfirmware) • Poupas helped a lot on this
  • 46. Vulnerability • Firmware upgrade path is compromised • Can flash any watch with modded firmware / backdoor with physical access to it • Can remotely implant a backdoor by doing a MiTM attack to ‘download.tomtom.com’ • Can enable hidden functions on cheaper devices (ie. Turn a TomTom Runner into a Multisport)
  • 47. Risk •Risk to users is fairly low •Risk to TomTom is unknown: • hardware can be used to run “homebrew” firmware • Might actually be good for sales
  • 48. Recommendation •Use SSL for download.tomtom.com! •Use RSA / assymetric crypto to sign firmware •Prevent firmware downgrades •Must upgrade bootloader in the field • quite a bit risky, but can be done
  • 50. Thanks! Questions? Luis Grangeia | @lgrangeia October 2015 Confraria de Segurança da Informação