Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AIS3-Firmware Security Analysis
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
terrynini
July 30, 2019
Technology
1.3k
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
AIS3-Firmware Security Analysis
terrynini
July 30, 2019
More Decks by terrynini
See All by terrynini
2020 交大程式安全:逆向工程上課講義-第二週(第一段)
terrynini
1
630
2020 交大程式安全:逆向工程上課講義-第二週(第二段)
terrynini
0
310
2020 交大程式安全:逆向工程上課講義-第一週(第一段)
terrynini
1
1.3k
2020 交大程式安全:逆向工程上課講義-第一週(第二段)
terrynini
1
680
2020 交大程式安全:逆向工程上課講義-第一週(第三段)
terrynini
3
2.2k
NTUST.pdf
terrynini
0
420
別pwn那裡.pdf
terrynini
0
530
逆逆_忍術_F5_消失之術_.pdf
terrynini
1
1.1k
成功高中講義.pdf
terrynini
0
860
Other Decks in Technology
See All in Technology
[チョークトーク資料]AWS DevOps Agent を使いこなす / AWS Dev Ops Agent Chalk Talk AWS Summit Japan 2026
kinunori
3
630
サイバーエージェントにおけるAI推進戦略と変革への取り組み
shotatsuge
0
250
20260619 私の日常業務での生成 AI 活用
masaruogura
1
230
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
160
人材育成分科会.pdf
_awache
4
300
PostgreSQL 19 新機能概要 OSC Hokkaido 2026
nori_shinoda
0
190
AIAU_UMEMOGU_ninomiya_slide
ninomiya_ii
0
240
Lightning近況報告
kozy4324
0
210
OTel × Datadog で 「AI活用」を計測し、改善に繋げる
shihochan
2
460
SONiCのLinuxベースを活かしたZabbix監視
sonic
0
240
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
130
AIのReact習熟度を測る
uhyo
2
660
Featured
See All Featured
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Prompt Engineering for Job Search
mfonobong
0
350
HDC tutorial
michielstock
2
720
Build your cross-platform service in a week with App Engine
jlugia
234
18k
Automating Front-end Workflow
addyosmani
1370
210k
Statistics for Hackers
jakevdp
799
230k
Unsuck your backbone
ammeep
672
58k
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Into the Great Unknown - MozCon
thekraken
41
2.6k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
Transcript
Firmware Security Analysis 李倫銓 Alan, NiNi
About Linkit7697 LinkIt7697 是一塊針對物聯網應用的開發版,基於 MT7697 系統單晶片, 具有含浮點運算的 ARM Cortex-M4 微控制器,
並整合了 802.11b/g/n WiFi 無線網路與 Bluetooth 4.2 低功耗藍牙。
What is firmware ROM EPROM flash memory firmware firmware firmware
Firmware is a piece of code stored in ROM, EPROM, flash memory. It may provide some functions to software to control hardware. Or, it may be the only program that will run on the embedded system.
Before starting…. 先把 firmware 燒上去
UART UART 1 UART 2 Tx Rx Tx Rx
UART UART 1 UART 2 Tx Rx 1 0 1
1 1 0 1
PC RAM BIOS Hard Disk MBR boot loader Boot loader
PC RAM BIOS Hard Disk MBR boot loader Boot loader
BIOS 抓
PC RAM BIOS Hard Disk boot loader MBR Boot loader
MBR BIOS 抓完
Boot loader PC RAM Hard Disk boot loader MBR MBR
MBR 抓
Boot loader PC RAM Hard Disk boot loader MBR MBR
Boot MBR 抓沒完
Boot loader PC RAM Hard Disk boot loader MBR MBR
Boot MBR 再抓
Boot loader PC RAM Hard Disk boot loader MBR MBR
Boot loader Boot loader完成載入
Boot loader DEMO
ARM ARM 架構有需多版本, 從最早的 ARMv1 到現在的 ARMv8 每個版本都有引入一些新的特色。
ARM ARM不賣晶片,而是靠授權架構賺錢, 實作則是由購買的公司進行(一般不能改架構), CPU 名字跟架構版本沒有關係, 如 ARM7EJ 對應 ARMv5,ARM11 對應
ARMv6。
ARM 但 ARM11 之後改變了命名的方式,改為 Cortex-A Application profile Cortex-R Real-time profile
Cortex-M Microcontroller profile
ARM ARM 有兩個模式 一個 ARM,一個 Thumb Thumb 是 ARM 的子集,
ARM 一條指令需要 4Byte 的編碼 , Thumb 則是 2 or 4 byte
ARM 00010400 <main>: 10400: b580 push {r7, lr} 10402: af00
add r7, sp, #0 10404: 4b03 ldr r3, [pc, #12] ; (10414 <main+0x14>) 10406: 0018 movs r0, r3 10408: f7ff ff68 bl 102dc <puts@plt> 1040c: 2300 movs r3, #0 1040e: 0018 movs r0, r3 10410: 46bd mov sp, r7 10412: bd80 pop {r7, pc} 000103fc <main>: 103fc: e92d4800 push {fp, lr} 10400: e28db004 add fp, sp, #4 10404: e59f000c ldr r0, [pc, #12] ; 10418 <main+0x1c> 10408: ebffffb3 bl 102dc <puts@plt> 1040c: e3a03000 mov r3, #0 10410: e1a00003 mov r0, r3 10414: e8bd8800 pop {fp, pc}
ARM 後來則增強為 Thumb2 ,code density 與 Thumb 接近 但有類似 ARM
的性能
ARM 快問快答
ARM http://infocenter.arm.com/help/topic/com.arm.doc.dui0553b/DUI0553.pdf http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001m/QRC0001_UAL.pdf Cortex-M4 Manual ARM Thumb2 cheatsheet
ARM 暫存器 R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 2.1.3 Core registers
ARM 基本運算 opcode Rd, Rn opcode Rd, Rn, Op2
ARM MOV R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0x0000FA05 MOV R1, #0xFA05 3.5.6 MOV and MVN
ARM R0 R1 R2 R3 R4 R5 R6 R7 R8
R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0x0000FA05 0x00000100 MOV R1, #0xFA05 MOV R5, #256 MOV 3.5.6 MOV and MVN
ARM R0 R1 R2 R3 R4 R5 R6 R7 R8
R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0x0000FA05 0x0000BEEF 0x00000100 MOV R1, #0xFA05 MOV R5, #256 MOVW R3, #0xBEEF MOV 3.5.6 MOV and MVN
ARM R0 R1 R2 R3 R4 R5 R6 R7 R8
R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0x0000FA05 0xDEADBEEF 0x00000100 MOV R1, #0xFA05 MOV R5, #256 MOVW R3, #0xBEEF MOVT R3, #0xDEAD MOV 3.5.6 MOV and MVN
ARM R0 R1 R2 R3 R4 R5 R6 R7 R8
R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0x0000FA05 0xFFFFFFF0 0xDEADBEEF 0x00000100 MOV R1, #0xFA05 MOV R5, #256 MOVW R3, #0xBEEF MOVT R3, #0xDEAD MVN R2, #0xF MOV 3.5.6 MOV and MVN
ARM LDR/STR 只有 ldr 跟 str 可以存取記憶體 其他 opcode 的運算子都不能存取記憶體
3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xFFFFFFF0 0xDEADBEEF 0x00000100 0x100 0x104 0xfaceb00c 0xdeadbeef LDR R1, [R5] 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xFFFFFFF0 0xDEADBEEF 0x00000100 LDR R1, [R5] 0x100 0x104 0xfaceb00c 0xdeadbeef 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xFFFFFFF0 0xDEADBEEF 0x00000100 LDR R1, [R5] STR R2, [R5,#4] 0x100 0x104 0xfaceb00c 0xdeadbeef 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xFFFFFFF0 0xDEADBEEF 0x00000100 0x100 0x104 0xfaceb00c 0xFFFFFFF0 LDR R1, [R5] STR R2, [R5,#4] 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xFFFFFFF0 0xDEADBEEF 0x00000100 0x100 0x104 0xfaceb00c 0xFFFFFFF0 LDR R1, [R5] STR R2, [R5,#4] LDR R2, [R5],#4 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xfaceb00c 0xDEADBEEF 0x00000104 0x100 0x104 0x108 0xfaceb00c 0xFFFFFFF0 LDR R1, [R5] STR R2, [R5,#4] LDR R2, [R5],#4 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xfaceb00c 0xDEADBEEF 0x00000104 0x100 0x104 0x108 0xfaceb00c 0xFFFFFFF0 LDR R1, [R5] STR R2, [R5,#4] LDR R2, [R5],#4 STR R2, [R5,#4]! 3.4 Memory access instructions
ARM LDR/STR R0 R1 R2 R3 R4 R5 R6 R7
R8 R9 R10 R11 R12 SP(R13) LR(R14) PC(R15) 0xfaceb00c 0xfaceb00c 0xDEADBEEF 0x00000108 0x100 0x104 0x108 0xfaceb00c 0xFFFFFFF0 0xfaceb00c LDR R1, [R5] STR R2, [R5,#4] LDR R2, [R5],#4 STR R2, [R5,#4]! 3.4 Memory access instructions
ARM 單位 10101010 10101010 10101010 10101010 10101010 10101010 10101010 1
BYTE 1 Half Word 1 Word LDR LDRH, LDRSH LDRB, LDRBH
ARM condition execution N -> negative Z -> zero C
-> carry V -> overflow CMP R1, #3 LDREQ R1, [R5] 3.3.7 Condition execution
ARM condition execution N -> negative Z -> zero C
-> carry V -> overflow if( r1 == 3 ) r1 = *r5 3.3.7 Condition execution
ARM condition execution CMP R1, #3 IT EQ LDREQ R1,
[R5] N -> negative Z -> zero C -> carry V -> overflow 3.3.7 Condition execution
ARM condition execution N -> negative Z -> zero C
-> carry V -> overflow if( r1 == 3 ) r1 = *r5 3.3.7 Condition execution
ARM condition execution CMP R1, #3 ITT EQ LDREQ R1,
[R5] LDREQ R2, [R5] N -> negative Z -> zero C -> carry V -> overflow 3.3.7 Condition execution
ARM condition execution N -> negative Z -> zero C
-> carry V -> overflow if( r1 == 3 ){ r1 = *r5 r2 = *r5 } 3.3.7 Condition execution
ARM condition execution CMP R1, #3 ITTE EQ LDREQ R1,
[R5] LDREQ R2, [R5] ADDNE R1, #1 N -> negative Z -> zero C -> carry V -> overflow 3.3.7 Condition execution
ARM condition execution N -> negative Z -> zero C
-> carry V -> overflow if( r1 == 3 ){ r1 = *r5 r2 = *r5 }else{ r1 += 1 } 3.3.7 Condition execution
ARM B{cond} lable 跳轉 BL{cond} lable 跳轉,把 return address 放進
LR BX{cond} Rm 跳轉 BXL{cond} Rm 跳轉,把 return address 放進 LR 3.10 Branch and control instructions
Find the main Literal Pool
Find the main
BONUS TIME
Secure Boot
Secure Boot 所以在 Bootloader 執行時 我們要確保即將掛載的 firmware 不是修改過的
Secure Boot Reset ROM Bootloader Bootloader input Signed? yes no
Bootloader firmware input Signed? yes no Stop or Recover
Secure Boot Bootloader hash ##### encrypt flash memory key
Secure Boot Bootloader hash ##### encrypt flash memory key burn
eFuse
Secure Boot Firmware digital signature hash ##### private key (on
your PC) signature algorithm
Secure Boot Firmware digital signature hash ##### public key (in
bootloader) signature algorithm Same?
Secure Boot But this is not the end……
Secure Boot Tegra X1
Secure Boot Tegra X1 USB Recovery Mode https://http.download.nvidia.com/tegra-public-appnotes/tegra-boot-flow.html#_error_handling_and_recovery_mode
Secure Boot Fusée Gelée:https://github.com/Qyriad/fusee-launcher ShofEL2:https://fail0verflow.com/blog/2018/shofel2/