SlideShare a Scribd company logo
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
ARM IoT FIRMWARE
EMULATION WORKSHOP
Saumil Shah
@therealsaumil
12 September 2018
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
# who am i
CEO Net-square.
• Hacker, Speaker, Trainer,
Author.
• M.S. Computer Science
Purdue University.
• LinkedIn: saumilshah
• Twitter: @therealsaumil
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Objective
• Extract the firmware from an IoT device.
• Emulate the firmware in QEMU.
• "Boot up" the virtual device.
• Debugging, Testing and Fuzzing
environment.
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Case Study DLINK DIR-880L
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Setup
• armplayer2.zip - VMware image
• dir880_mtdblocks.zip - firmware blobs
• dir880_minicom.txt - console msgs
• static_arm_bins.zip - fun t00lz
• Extract the VM and start it up.
• You need SSH/SCP on your laptop.
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Lab Virtual Machine
All passwords are "exploitlab" J Yes you may write it down
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
armplayer host
SSH to port 2222
username: exploitlab QEMU ARMv7
SSH to port 22
username: root
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Pentesting Embedded ARM
ARM IoT Devices
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Take a look at an IoT device...
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
CPU and
Hardware
Kernel
Drivers
File System
nvram
User Processes
API
UI
libnvram
JTAG
RS
232
SPI
notaccessible
...it is a special computer...
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
CPU and
Hardware
Kernel
Drivers
File System
nvram
User Processes
API
UI
libnvram
JTAG
RS
232
SPI
notaccessible
Authentication Bypass
Insecure Direct Obj Ref
File Retrieval
Remote Command
Exec
Memory Corruption
Buffer Overflows
Backdoors
Default Passwords
Hidden Paths
Memory Corruption
Buffer Overflows
...with "special" vulnerabilities
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
compressed FS
CPU
Kernel
Boot Loader
mounted
FS
nvram
init
scripts
Services
Apps
libnvram
The IoT Boot Up Process
conf
conf
conf
conf
firmware
Loads Kernel.
Uncompresses FS to ramdisk,
invokes init process.
ramdiskuserland
Reads config from nvram.
Builds system config files on
the fly.
Starts up system services.
Invokes Applications and
Application services.
READY
POWER ON
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Obtaining the Firmware
• Download the firmware files from the
device update website.
– binwalk
• Find the UART pins on the device's
board, solder and connect via serial
console.
– Extract the firmware via shell over serial
console.
• Direct hardware level extraction.
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Serial Console
• Most devices run a privileged shell on
serial console.
• Kernel boot arguments:
• Getting firmware from a shell is easy...
• ...finding the serial port is a challenge :)
root=/dev/mtdblock2 console=ttyS0,115200
init=/sbin/preinit earlyprintk debug
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Discovering the UART pins
• Usually unsoldered.
• Identify candidate pins.
• Test for Vcc (+3.3V) and GND.
• Test for TX, RX.
• Important pins – TX, RX, GND.
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Discovering UART pins
Possible UART pins
False Positive
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Discovering UART pins
Second Possibility
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Testing Voltages
Vcc (+3.3V)
GND
GND
runs
through-
out the
board
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Testing Voltages
Vcc (+3.3V) GND
The other
two pins
have to
be TX, RX.
GND
Verify continuity across GND
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Serial Console
Device
GND
TX
RX
GND
TX
RX
minicom
Serial Port = /dev/ttyUSB0
115200 baud
8N1
Vcc
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Serial Console - working
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Finished Serial Port Projects
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
# cat /proc/partitions
major minor #blocks name
31 0 256 mtdblock0
31 1 64 mtdblock1
31 2 64 mtdblock2
31 3 1472 mtdblock3
31 4 128 mtdblock4
31 5 64 mtdblock5
31 6 2048 mtdblock6
31 7 32768 mtdblock7
31 8 30975 mtdblock8
31 9 131072 mtdblock9
31 10 98304 mtdblock10
Firmware Extraction
# cat /proc/cmdline
root=/dev/mtdblock8 mtdparts=bcmsflash:256k(u-
boot)ro,64k(devconf),64k(devdata),1472k(mydlink),128k(langpack),64k(nvram),
2m@0(flash);nflash:32m(upgrade),32m@0(rootfs)ro,128m@0(nflash);brcmnand:96m
@32m(storage) console=ttyS0,115200 init=/sbin/preinit earlyprintk debug
# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "u-boot"
mtd1: 00010000 00010000 "devconf"
mtd2: 00010000 00010000 "devdata"
mtd3: 00170000 00010000 "mydlink"
mtd4: 00020000 00010000 "langpack"
mtd5: 00010000 00010000 "nvram"
mtd6: 00200000 00010000 "flash"
mtd7: 02000000 00020000 "upgrade"
mtd8: 01e3ffa0 00020000 "rootfs"
mtd9: 08000000 00020000 "nflash"
mtd10: 06000000 00020000 "storage"
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
New vs Legacy Memory Layout
Heap
Binary
Stack
Lib
Lib
0x00008000
0xbf000000
0xb6f00000
0xbefdf000
/proc/sys/vm/legacy_va_layout = 0
Heap
Binary
Stack
Lib
Lib
0x00008000
0xbf000000
0x40000000
0xbefdf000
/proc/sys/vm/legacy_va_layout = 1
New Layout Legacy Layout
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
QEMU ARM
Kernel
Emulator Driven Test Bench
proc sys dev etc bin
squashfs-root
chroot
environment
proc sys dev etc bin
init
system services
user processes
nvram
config
(ini file)
nvram shim
gdb
server
multiarch
gdb
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
Extract the rootfs
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
rsync rootfs to ARM QEMU
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
chroot the rootfs in QEMU
Setup commands for binding
/proc, /sys and /dev and
running chroot
kick off the init scripts
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
The virtual router "boots up"
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
SUCCESS!
NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
THANK YOU!
Saumil Shah
@therealsaumil
saumil@net-square.com
LinkedIn: saumilshah
Follow us on Twitter for:
updates
new classes
on-site training
announcements
Blog:
http://blog.exploitlab.net

More Related Content

PDF
Jagan Teki - U-boot from scratch
PPTX
Bootloaders (U-Boot)
PDF
Device Tree for Dummies (ELC 2014)
PPT
Bootstrap process of u boot (NDS32 RISC CPU)
PDF
LCU13: An Introduction to ARM Trusted Firmware
PDF
Configuring wifi in open embedded builds
PDF
Spi drivers
PDF
USB Drivers
Jagan Teki - U-boot from scratch
Bootloaders (U-Boot)
Device Tree for Dummies (ELC 2014)
Bootstrap process of u boot (NDS32 RISC CPU)
LCU13: An Introduction to ARM Trusted Firmware
Configuring wifi in open embedded builds
Spi drivers
USB Drivers

What's hot (20)

PDF
Process Scheduler and Balancer in Linux Kernel
ODP
Introduction to Optee (26 may 2016)
PDF
Board support package_on_linux
PDF
Embedded Android : System Development - Part II (Linux device drivers)
PDF
I2c drivers
PDF
Android Multimedia Framework
PDF
Tuning Android for low RAM
PDF
Kernel Recipes 2018 - Overview of SD/eMMC, their high speed modes and Linux s...
PDF
Kernel Module Programming
PDF
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
PDF
The Linux Kernel Scheduler (For Beginners) - SFO17-421
PDF
Booting Android: bootloaders, fastboot and boot images
PPT
U boot porting guide for SoC
PPT
Linux Booting Steps
PPTX
Linux kernel debugging
PDF
[ko] Kernel Networking Stack 진입 장벽 허물기
PDF
Bootloaders
PDF
Introduction to Modern U-Boot
PPTX
Overview of Android binder IPC implementation
Process Scheduler and Balancer in Linux Kernel
Introduction to Optee (26 may 2016)
Board support package_on_linux
Embedded Android : System Development - Part II (Linux device drivers)
I2c drivers
Android Multimedia Framework
Tuning Android for low RAM
Kernel Recipes 2018 - Overview of SD/eMMC, their high speed modes and Linux s...
Kernel Module Programming
Secure Boot on ARM systems – Building a complete Chain of Trust upon existing...
The Linux Kernel Scheduler (For Beginners) - SFO17-421
Booting Android: bootloaders, fastboot and boot images
U boot porting guide for SoC
Linux Booting Steps
Linux kernel debugging
[ko] Kernel Networking Stack 진입 장벽 허물기
Bootloaders
Introduction to Modern U-Boot
Overview of Android binder IPC implementation
Ad

Similar to ARM IoT Firmware Emulation Workshop (20)

PDF
Hack.LU 2018 ARM IoT Firmware Emulation Workshop
PDF
Introducing ARM-X
PDF
INSIDE ARM-X Cansecwest 2020
PDF
INSIDE ARM-X - Countermeasure 2019
PDF
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
PPTX
Advanced SOHO Router Exploitation XCON
PDF
HackLU 2018 Make ARM Shellcode Great Again
PPTX
Steelcon 2015 - 0wning the internet of trash
PDF
Announcing ARMX Docker - DC11332
PDF
Develop Your Own Operating Systems using Cheap ARM Boards
PDF
RDMA on ARM
PDF
Adventures in Femtoland: 350 Yuan for Invaluable Fun
PDF
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
PDF
Dec.20.2019, Arduino based on Mbed os
PDF
Embedded Linux
PDF
Make ARM Shellcode Great Again - HITB2018PEK
PDF
PDF
Cloud, Distributed, Embedded: Erlang in the Heterogeneous Computing World
PDF
IoT exploitation: from memory corruption to code execution - Marco Romano - C...
PDF
IoT exploitation: from memory corruption to code execution by Marco Romano
Hack.LU 2018 ARM IoT Firmware Emulation Workshop
Introducing ARM-X
INSIDE ARM-X Cansecwest 2020
INSIDE ARM-X - Countermeasure 2019
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Advanced SOHO Router Exploitation XCON
HackLU 2018 Make ARM Shellcode Great Again
Steelcon 2015 - 0wning the internet of trash
Announcing ARMX Docker - DC11332
Develop Your Own Operating Systems using Cheap ARM Boards
RDMA on ARM
Adventures in Femtoland: 350 Yuan for Invaluable Fun
It's Assembler, Jim, but not as we know it: (ab)using binaries from embedded ...
Dec.20.2019, Arduino based on Mbed os
Embedded Linux
Make ARM Shellcode Great Again - HITB2018PEK
Cloud, Distributed, Embedded: Erlang in the Heterogeneous Computing World
IoT exploitation: from memory corruption to code execution - Marco Romano - C...
IoT exploitation: from memory corruption to code execution by Marco Romano
Ad

More from Saumil Shah (20)

PDF
The Hand That Strikes, Also Blocks
PDF
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS
PDF
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
PDF
Precise Presentations
PDF
Effective Webinars: Presentation Skills for a Virtual Audience
PDF
Cyberspace And Security - India's Decade Ahead
PDF
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
PDF
NSConclave2020 The Decade Behind And The Decade Ahead
PDF
Cybersecurity In India - The Decade Ahead
PDF
The Road To Defendable Systems - Emirates NBD
PDF
The CISO's Dilemma 44CON 2019
PDF
The CISO's Dilemma HITBGSEC2019
PDF
Schrödinger's ARM Assembly
PDF
ARM Polyglot Shellcode - HITB2019AMS
PDF
What Makes a Compelling Photograph
PDF
Make ARM Shellcode Great Again
PDF
Cross Border Cyber Attacks: Impact on Digital Sovereignty
PDF
The Seven Axioms of Security - ITWeb 2017
PDF
Redefining Defense - HITB2017AMS Keynote
PDF
The Seven Axioms Of Security
The Hand That Strikes, Also Blocks
Debugging with EMUX - RIngzer0 BACK2WORKSHOPS
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
Precise Presentations
Effective Webinars: Presentation Skills for a Virtual Audience
Cyberspace And Security - India's Decade Ahead
Cybersecurity And Sovereignty - A Look At Society's Transformation In Cyberspace
NSConclave2020 The Decade Behind And The Decade Ahead
Cybersecurity In India - The Decade Ahead
The Road To Defendable Systems - Emirates NBD
The CISO's Dilemma 44CON 2019
The CISO's Dilemma HITBGSEC2019
Schrödinger's ARM Assembly
ARM Polyglot Shellcode - HITB2019AMS
What Makes a Compelling Photograph
Make ARM Shellcode Great Again
Cross Border Cyber Attacks: Impact on Digital Sovereignty
The Seven Axioms of Security - ITWeb 2017
Redefining Defense - HITB2017AMS Keynote
The Seven Axioms Of Security

Recently uploaded (20)

PPTX
INFERTILITY (FEMALE FACTORS).pptxgvcghhfcg
PPTX
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
PDF
-DIGITAL-INDIA.pdf one of the most prominent
PPTX
ERP good ERP good ERP good ERP good good ERP good ERP good
PPTX
code of ethics.pptxdvhwbssssSAssscasascc
PPTX
1.pptxsadafqefeqfeqfeffeqfqeqfeqefqfeqfqeffqe
PDF
Layer23-Switch.com The Cisco Catalyst 9300 Series is Cisco’s flagship stackab...
PDF
Cableado de Controladores Logicos Programables
PPTX
Operating System Processes_Scheduler OSS
PPTX
making presentation that do no stick.pptx
PDF
Prescription1 which to be used for periodo
PPTX
quadraticequations-111211090004-phpapp02.pptx
PPTX
Lecture-3-Computer-programming for BS InfoTech
PDF
Dynamic Checkweighers and Automatic Weighing Machine Solutions
PPTX
sdn_based_controller_for_mobile_network_traffic_management1.pptx
PPTX
title _yeOPC_Poisoning_Presentation.pptx
PPTX
KVL KCL ppt electrical electronics eee tiet
PDF
How NGOs Save Costs with Affordable IT Rentals
PPTX
Computers and mobile device: Evaluating options for home and work
PPTX
Fundamentals of Computer.pptx Computer BSC
INFERTILITY (FEMALE FACTORS).pptxgvcghhfcg
PROGRAMMING-QUARTER-2-PYTHON.pptxnsnsndn
-DIGITAL-INDIA.pdf one of the most prominent
ERP good ERP good ERP good ERP good good ERP good ERP good
code of ethics.pptxdvhwbssssSAssscasascc
1.pptxsadafqefeqfeqfeffeqfqeqfeqefqfeqfqeffqe
Layer23-Switch.com The Cisco Catalyst 9300 Series is Cisco’s flagship stackab...
Cableado de Controladores Logicos Programables
Operating System Processes_Scheduler OSS
making presentation that do no stick.pptx
Prescription1 which to be used for periodo
quadraticequations-111211090004-phpapp02.pptx
Lecture-3-Computer-programming for BS InfoTech
Dynamic Checkweighers and Automatic Weighing Machine Solutions
sdn_based_controller_for_mobile_network_traffic_management1.pptx
title _yeOPC_Poisoning_Presentation.pptx
KVL KCL ppt electrical electronics eee tiet
How NGOs Save Costs with Affordable IT Rentals
Computers and mobile device: Evaluating options for home and work
Fundamentals of Computer.pptx Computer BSC

ARM IoT Firmware Emulation Workshop

  • 1. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 ARM IoT FIRMWARE EMULATION WORKSHOP Saumil Shah @therealsaumil 12 September 2018
  • 2. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 # who am i CEO Net-square. • Hacker, Speaker, Trainer, Author. • M.S. Computer Science Purdue University. • LinkedIn: saumilshah • Twitter: @therealsaumil
  • 3. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Objective • Extract the firmware from an IoT device. • Emulate the firmware in QEMU. • "Boot up" the virtual device. • Debugging, Testing and Fuzzing environment.
  • 4. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Case Study DLINK DIR-880L
  • 5. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Setup • armplayer2.zip - VMware image • dir880_mtdblocks.zip - firmware blobs • dir880_minicom.txt - console msgs • static_arm_bins.zip - fun t00lz • Extract the VM and start it up. • You need SSH/SCP on your laptop.
  • 6. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Lab Virtual Machine All passwords are "exploitlab" J Yes you may write it down
  • 7. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 armplayer host SSH to port 2222 username: exploitlab QEMU ARMv7 SSH to port 22 username: root
  • 8. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Pentesting Embedded ARM ARM IoT Devices
  • 9. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018
  • 10. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Take a look at an IoT device...
  • 11. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 CPU and Hardware Kernel Drivers File System nvram User Processes API UI libnvram JTAG RS 232 SPI notaccessible ...it is a special computer...
  • 12. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 CPU and Hardware Kernel Drivers File System nvram User Processes API UI libnvram JTAG RS 232 SPI notaccessible Authentication Bypass Insecure Direct Obj Ref File Retrieval Remote Command Exec Memory Corruption Buffer Overflows Backdoors Default Passwords Hidden Paths Memory Corruption Buffer Overflows ...with "special" vulnerabilities
  • 13. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 compressed FS CPU Kernel Boot Loader mounted FS nvram init scripts Services Apps libnvram The IoT Boot Up Process conf conf conf conf firmware Loads Kernel. Uncompresses FS to ramdisk, invokes init process. ramdiskuserland Reads config from nvram. Builds system config files on the fly. Starts up system services. Invokes Applications and Application services. READY POWER ON
  • 14. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Obtaining the Firmware • Download the firmware files from the device update website. – binwalk • Find the UART pins on the device's board, solder and connect via serial console. – Extract the firmware via shell over serial console. • Direct hardware level extraction.
  • 15. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Serial Console • Most devices run a privileged shell on serial console. • Kernel boot arguments: • Getting firmware from a shell is easy... • ...finding the serial port is a challenge :) root=/dev/mtdblock2 console=ttyS0,115200 init=/sbin/preinit earlyprintk debug
  • 16. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Discovering the UART pins • Usually unsoldered. • Identify candidate pins. • Test for Vcc (+3.3V) and GND. • Test for TX, RX. • Important pins – TX, RX, GND.
  • 17. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Discovering UART pins Possible UART pins False Positive
  • 18. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Discovering UART pins Second Possibility
  • 19. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Testing Voltages Vcc (+3.3V) GND GND runs through- out the board
  • 20. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Testing Voltages Vcc (+3.3V) GND The other two pins have to be TX, RX. GND Verify continuity across GND
  • 21. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Serial Console Device GND TX RX GND TX RX minicom Serial Port = /dev/ttyUSB0 115200 baud 8N1 Vcc
  • 22. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Serial Console - working
  • 23. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Finished Serial Port Projects
  • 24. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 # cat /proc/partitions major minor #blocks name 31 0 256 mtdblock0 31 1 64 mtdblock1 31 2 64 mtdblock2 31 3 1472 mtdblock3 31 4 128 mtdblock4 31 5 64 mtdblock5 31 6 2048 mtdblock6 31 7 32768 mtdblock7 31 8 30975 mtdblock8 31 9 131072 mtdblock9 31 10 98304 mtdblock10 Firmware Extraction # cat /proc/cmdline root=/dev/mtdblock8 mtdparts=bcmsflash:256k(u- boot)ro,64k(devconf),64k(devdata),1472k(mydlink),128k(langpack),64k(nvram), 2m@0(flash);nflash:32m(upgrade),32m@0(rootfs)ro,128m@0(nflash);brcmnand:96m @32m(storage) console=ttyS0,115200 init=/sbin/preinit earlyprintk debug # cat /proc/mtd dev: size erasesize name mtd0: 00040000 00010000 "u-boot" mtd1: 00010000 00010000 "devconf" mtd2: 00010000 00010000 "devdata" mtd3: 00170000 00010000 "mydlink" mtd4: 00020000 00010000 "langpack" mtd5: 00010000 00010000 "nvram" mtd6: 00200000 00010000 "flash" mtd7: 02000000 00020000 "upgrade" mtd8: 01e3ffa0 00020000 "rootfs" mtd9: 08000000 00020000 "nflash" mtd10: 06000000 00020000 "storage"
  • 25. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 New vs Legacy Memory Layout Heap Binary Stack Lib Lib 0x00008000 0xbf000000 0xb6f00000 0xbefdf000 /proc/sys/vm/legacy_va_layout = 0 Heap Binary Stack Lib Lib 0x00008000 0xbf000000 0x40000000 0xbefdf000 /proc/sys/vm/legacy_va_layout = 1 New Layout Legacy Layout
  • 26. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 QEMU ARM Kernel Emulator Driven Test Bench proc sys dev etc bin squashfs-root chroot environment proc sys dev etc bin init system services user processes nvram config (ini file) nvram shim gdb server multiarch gdb
  • 27. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 Extract the rootfs
  • 28. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 rsync rootfs to ARM QEMU
  • 29. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 chroot the rootfs in QEMU Setup commands for binding /proc, /sys and /dev and running chroot kick off the init scripts
  • 30. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 The virtual router "boots up"
  • 31. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 SUCCESS!
  • 32. NETSQUARE (c) SAUMIL SHAHThe ARM Exploit Laboratory – 44CON 2018 THANK YOU! Saumil Shah @therealsaumil saumil@net-square.com LinkedIn: saumilshah Follow us on Twitter for: updates new classes on-site training announcements Blog: http://blog.exploitlab.net