SlideShare a Scribd company logo
@therealsaumil
@_ringzer0
debugging WITH EMUX
SAUMIL SHAH
@therealsaumil
7 JULY 2022
< BACK2
workshops`
ringzer¿
@therealsaumil
@_ringzer0
# WHO AM I
Saumil Shah
@therealsaumil
educating, entertaining
and exasperating
audiences since 1999
@therealsaumil
@_ringzer0
WHAT IS
ARM + MIPS IoT Emulation Framework
emux.exploitlab.net
@therealsaumil
@_ringzer0
What Is This Workshop About
An Introduction to debugging binaries on emulated targets
Using GDB + gdbserver for remote debugging
Hands-on examples
How EMUX makes the debugging process easy
@therealsaumil
@_ringzer0
EMUX docker container
HOST
EMUX DOCKER
launcher
EMULATED
TARGET ON
QEMU
emux-docker-shell
workspace
(shared
directory)
nweb
(target binary)
192.168.100.2
192.168.100.1
socat
80
20080
RINGZER0 HACKME
@therealsaumil
@_ringzer0
Concepts Covered
Functions of a Debugger
How does Remote Debugging work
EMUX's debugger wrappers
Advantages of using GEF
Debugging a webserver binary
Crash Dump Analysis
@therealsaumil
@_ringzer0
Functions of a Debugger
Inspect the target
Inspect the CPU state
Examine Memory
Control Process Execution
Analyse Crashes and Exceptions
Luxuries: Plugins, Macros, Logging
@therealsaumil
@_ringzer0
Remote Debugging - how it works
GDB multiarch
nweb
(target binary)
192.168.100.1
gdbserver :5000
--attach <PID>
(gdb) target remote 192.168.100.2:5000
(gdb) set sysroot target:/path/to/rootfs
(gdb) continue
REMOTE HOST
192.168.100.2
@therealsaumil
@_ringzer0
Remote Debugging - emuxgdb
emux-docker-shell
nweb
(target binary)
REMOTE HOST
192.168.100.1
gdbserver
$ emuxgdb nweb
(gdb)
" Automatically looks up the PID of the target
" Launches gdbserver on the remote host
" Launches gdb-multiarch locally
" Connects to remote gdbserver
" Sets sysroot
" Ready to debug!
192.168.100.2
@therealsaumil
@_ringzer0
Plain ol GDB -vs- new & shiny GEF
@therealsaumil
@_ringzer0
A few GDB/GEF commands
RECONNAISSANCE
vmmap [GEF] Display the process' memory layout
info target Information about the target being debugged (ELF binary)
info sharedlibrary Shared Libraries that are loaded with the binary
info functions List of functions that belong to the target binary
PROCESS EXECUTION
break Set a breakpoint
continue Resume process execution
rbreak Set multiple breakpoints using regular expressions
stepi / nexti Step Into / Next Instruction
CPU AND MEMORY
context [GEF] Better view of registers, stack, code, call stack, etc.
x Examine memory (many variations)
hexdump [GEF] When you want characters and bytes side by side
backtrace Display the call stack
info frame Inspect stack frames
disassemble Disassemble code
printf Formatted printing
LUXURIES
set logging Enable / Disable logging and redirect log output to a file
commands Execute multiple commands in sequence every time a breakpoint is reached
@therealsaumil
@_ringzer0
EMUX utilities
emuxps List processes running in the emulated device
emuxkill Terminate a process inside the emulated device
emuxmaps Remote process virtual memory layout
emuxgdb Attach gdb to a remote process in the emulated device
emuxnetstat Remote netstat
emuxhalt Shut down the emulated device
monitor Attach to QEMU monitor
@therealsaumil
@_ringzer0
SETTING UP!
@therealsaumil
@_ringzer0
Start EMUX
./run-emux-docker
:
:
[+] Setting up forwarded ports 20080:80,20443:443,28080:8080,24433:4433,9999:9999
[+] mapping port 20080 -> 192.168.100.2:80
[+] mapping port 20443 -> 192.168.100.2:443
[+] mapping port 28080 -> 192.168.100.2:8080
[+] mapping port 24433 -> 192.168.100.2:4433
[+] mapping port 9999 -> 192.168.100.2:9999
___ __ __ _ __ __
/ __| / | | | / / by Saumil Shah | The Exploit Laboratory
| __| |/| | |_| ) ( @therealsaumil | emux.exploitlab.net
___|_| |_____/_/_
[EMUX-DOCKER !] ~$
1. Start the EMUX Docker Container
@therealsaumil
@_ringzer0
Launch the target
2. Run launcher and boot into Damn Vulnerable ARM Router
[EMUX-DOCKER !] ~$ launcher
@therealsaumil
@_ringzer0
Start Userspace
./emux-docker-shell
[emux-docker !] ~$
3. Open a new terminal window and attach to emux-docker-shell
[emux-docker !] ~$ userspace
4. Run userspace
@therealsaumil
@_ringzer0
Enter the DVAR Console
5. Select "Enter the Damn Vulnerable ARM Router CONSOLE" option
@therealsaumil
@_ringzer0
Start nweb (our target binary)
Entering Damn Vulnerable ARM Router CONSOLE (/bin/sh)
[+] Logging enabled
[+] EMUX Debug log - /home/r0/workspace/logs/emuxdebug.log
[+] QEMU Console log - qemuconsole.log
[+] chroot /emux/DV-ARM/rootfs-arm /.emux/emuxshell
Script started, output log file is '/home/r0/workspace/logs/emuxdebug.log'.
BusyBox v1.23.2 (2021-10-14 18:26:48 IST) built-in shell (ash)
/ # nweb 80 /www/nweb/
6. Manually start the nweb web server from the Busybox prompt
./emux-docker-shell
[emux-docker !] ~$ curl http://192.168.100.2
<h1>Ringzer0 Hackme</h1>
7. Start another emux-docker-shell and test nweb
@therealsaumil
@_ringzer0
Grab the attack scripts!
[emux-docker !] ~$ cd workspace
[emux-docker !] ~/workspace$ wget https://saumil.net/tmp/attack1.py
--2022-07-07 14:12:48-- https://saumil.net/tmp/attack1.py
Resolving saumil.net (saumil.net)... 208.113.163.5
Connecting to saumil.net (saumil.net)|208.113.163.5|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 535 [text/plain]
Saving to: 'attack1.py'
attack1.py 100%[=======================>] 535 --.-KB/s in 0s
2022-07-07 14:12:50 (58.9 MB/s) - 'attack1.py' saved [535/535]
[emux-docker !] ~/workspace$ chmod +x attack1.py
8. From the emux-docker-shell grab the following attack scripts
@therealsaumil
@_ringzer0
HANDS ON
EMUXGDB
@therealsaumil
@_ringzer0
HERE BE THE GOODS
CODE: https://github.com/therealsaumil/emux
!-
ANNOUNCEMENTS: @therealsaumil
DOCS: https://emux.exploitlab.net/
@therealsaumil
@_ringzer0
ringzer¿
AUGUST 6-9
REGISTRATIONS OPEN
www.ringzer¿.training
THE ARM IoT
EXPLOIT LABORATORY
@therealsaumil
@_ringzer0
THANK YOU!
SAUMIL SHAH
@therealsaumil
7 JULY 2022
< BACK2
workshops`
ringzer¿

More Related Content

PDF
Introducing ARM-X
PDF
MiniSPA2022_Build_and_Test_Cloud_Infrastructure_using_Terraform_Modules.pdf
KEY
避けては通れないバイナリ地獄 - NDEFってなんだろう -
PDF
「Docker +VLAN 環境」アプリケーション実行環境の構築
PDF
Deep Dive into Docker Swarm Mode
PDF
Linux Bash Shell Cheat Sheet for Beginners
PDF
FreeBSD jail+vnetと戯れた話
PDF
猿でもわかる Helm
Introducing ARM-X
MiniSPA2022_Build_and_Test_Cloud_Infrastructure_using_Terraform_Modules.pdf
避けては通れないバイナリ地獄 - NDEFってなんだろう -
「Docker +VLAN 環境」アプリケーション実行環境の構築
Deep Dive into Docker Swarm Mode
Linux Bash Shell Cheat Sheet for Beginners
FreeBSD jail+vnetと戯れた話
猿でもわかる Helm

What's hot (10)

PDF
20240201_大規模通信制御信号 ETLシステムにおける 大幅なコスト削減・意識改革の取り組み.pdf
PPTX
Storage Area Network(SAN)
PDF
無線LANデバイスについて(kernelレベル)
PDF
はじめてのDNS
PDF
S104878 nvme-revolution-jburg-v1809b
PDF
google dork.pdf
DOCX
Quize on scripting shell
PDF
DNS High-Availability Tools - Open-Source Load Balancing Solutions
PDF
http2 最速実装 v2
PPTX
DDDモデリングハンズオン - レガシーをぶっつぶせ。現場でDDD!2nd
20240201_大規模通信制御信号 ETLシステムにおける 大幅なコスト削減・意識改革の取り組み.pdf
Storage Area Network(SAN)
無線LANデバイスについて(kernelレベル)
はじめてのDNS
S104878 nvme-revolution-jburg-v1809b
google dork.pdf
Quize on scripting shell
DNS High-Availability Tools - Open-Source Load Balancing Solutions
http2 最速実装 v2
DDDモデリングハンズオン - レガシーをぶっつぶせ。現場でDDD!2nd
Ad

Similar to Debugging with EMUX - RIngzer0 BACK2WORKSHOPS (20)

PDF
Docker Introduction.pdf
PDF
Docker, c'est bonheur !
DOCX
Docker Compose user guide
PDF
Docker for (Java) Developers
PDF
Getting started docker notes
PDF
kubernetes - minikube - getting started
PDF
From zero to Docker
PDF
Infrastructureascode slideshare-160331143725
PPTX
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
PDF
Infrastructureascode slideshare-160331143725
PDF
Delivering Docker & K3s worloads to IoT Edge devices
PDF
Docker in a JS Developer’s Life
PDF
Kubernetes laravel and kubernetes
PDF
Docker Essentials Workshop— Innovation Labs July 2020
PPTX
[Codelab 2017] Docker 기초 및 활용 방안
PPTX
PDF
Improve your Java Environment with Docker
PPTX
Primi passi con Docker - ItalianCoders - 12-01-2021
PDF
Ansible101
PPTX
Docker Introduction.pdf
Docker, c'est bonheur !
Docker Compose user guide
Docker for (Java) Developers
Getting started docker notes
kubernetes - minikube - getting started
From zero to Docker
Infrastructureascode slideshare-160331143725
Infrastructure as code: running microservices on AWS using Docker, Terraform,...
Infrastructureascode slideshare-160331143725
Delivering Docker & K3s worloads to IoT Edge devices
Docker in a JS Developer’s Life
Kubernetes laravel and kubernetes
Docker Essentials Workshop— Innovation Labs July 2020
[Codelab 2017] Docker 기초 및 활용 방안
Improve your Java Environment with Docker
Primi passi con Docker - ItalianCoders - 12-01-2021
Ansible101
Ad

More from Saumil Shah (20)

PDF
The Hand That Strikes, Also Blocks
PDF
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
PDF
Announcing ARMX Docker - DC11332
PDF
Precise Presentations
PDF
Effective Webinars: Presentation Skills for a Virtual Audience
PDF
INSIDE ARM-X Cansecwest 2020
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
INSIDE ARM-X - Countermeasure 2019
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 - HITB2018PEK
PDF
HackLU 2018 Make ARM Shellcode Great Again
PDF
Hack.LU 2018 ARM IoT Firmware Emulation Workshop
The Hand That Strikes, Also Blocks
Unveiling EMUX - ARM and MIPS IoT Emulation Framework
Announcing ARMX Docker - DC11332
Precise Presentations
Effective Webinars: Presentation Skills for a Virtual Audience
INSIDE ARM-X Cansecwest 2020
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
INSIDE ARM-X - Countermeasure 2019
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 - HITB2018PEK
HackLU 2018 Make ARM Shellcode Great Again
Hack.LU 2018 ARM IoT Firmware Emulation Workshop

Recently uploaded (20)

PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Big Data Technologies - Introduction.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Approach and Philosophy of On baking technology
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
Cloud computing and distributed systems.
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Big Data Technologies - Introduction.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
The AUB Centre for AI in Media Proposal.docx
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
20250228 LYD VKU AI Blended-Learning.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Unlocking AI with Model Context Protocol (MCP)
MIND Revenue Release Quarter 2 2025 Press Release
Mobile App Security Testing_ A Comprehensive Guide.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Approach and Philosophy of On baking technology
Agricultural_Statistics_at_a_Glance_2022_0.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Encapsulation theory and applications.pdf
Cloud computing and distributed systems.
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation

Debugging with EMUX - RIngzer0 BACK2WORKSHOPS

  • 1. @therealsaumil @_ringzer0 debugging WITH EMUX SAUMIL SHAH @therealsaumil 7 JULY 2022 < BACK2 workshops` ringzer¿
  • 2. @therealsaumil @_ringzer0 # WHO AM I Saumil Shah @therealsaumil educating, entertaining and exasperating audiences since 1999
  • 3. @therealsaumil @_ringzer0 WHAT IS ARM + MIPS IoT Emulation Framework emux.exploitlab.net
  • 4. @therealsaumil @_ringzer0 What Is This Workshop About An Introduction to debugging binaries on emulated targets Using GDB + gdbserver for remote debugging Hands-on examples How EMUX makes the debugging process easy
  • 5. @therealsaumil @_ringzer0 EMUX docker container HOST EMUX DOCKER launcher EMULATED TARGET ON QEMU emux-docker-shell workspace (shared directory) nweb (target binary) 192.168.100.2 192.168.100.1 socat 80 20080 RINGZER0 HACKME
  • 6. @therealsaumil @_ringzer0 Concepts Covered Functions of a Debugger How does Remote Debugging work EMUX's debugger wrappers Advantages of using GEF Debugging a webserver binary Crash Dump Analysis
  • 7. @therealsaumil @_ringzer0 Functions of a Debugger Inspect the target Inspect the CPU state Examine Memory Control Process Execution Analyse Crashes and Exceptions Luxuries: Plugins, Macros, Logging
  • 8. @therealsaumil @_ringzer0 Remote Debugging - how it works GDB multiarch nweb (target binary) 192.168.100.1 gdbserver :5000 --attach <PID> (gdb) target remote 192.168.100.2:5000 (gdb) set sysroot target:/path/to/rootfs (gdb) continue REMOTE HOST 192.168.100.2
  • 9. @therealsaumil @_ringzer0 Remote Debugging - emuxgdb emux-docker-shell nweb (target binary) REMOTE HOST 192.168.100.1 gdbserver $ emuxgdb nweb (gdb) " Automatically looks up the PID of the target " Launches gdbserver on the remote host " Launches gdb-multiarch locally " Connects to remote gdbserver " Sets sysroot " Ready to debug! 192.168.100.2
  • 11. @therealsaumil @_ringzer0 A few GDB/GEF commands RECONNAISSANCE vmmap [GEF] Display the process' memory layout info target Information about the target being debugged (ELF binary) info sharedlibrary Shared Libraries that are loaded with the binary info functions List of functions that belong to the target binary PROCESS EXECUTION break Set a breakpoint continue Resume process execution rbreak Set multiple breakpoints using regular expressions stepi / nexti Step Into / Next Instruction CPU AND MEMORY context [GEF] Better view of registers, stack, code, call stack, etc. x Examine memory (many variations) hexdump [GEF] When you want characters and bytes side by side backtrace Display the call stack info frame Inspect stack frames disassemble Disassemble code printf Formatted printing LUXURIES set logging Enable / Disable logging and redirect log output to a file commands Execute multiple commands in sequence every time a breakpoint is reached
  • 12. @therealsaumil @_ringzer0 EMUX utilities emuxps List processes running in the emulated device emuxkill Terminate a process inside the emulated device emuxmaps Remote process virtual memory layout emuxgdb Attach gdb to a remote process in the emulated device emuxnetstat Remote netstat emuxhalt Shut down the emulated device monitor Attach to QEMU monitor
  • 14. @therealsaumil @_ringzer0 Start EMUX ./run-emux-docker : : [+] Setting up forwarded ports 20080:80,20443:443,28080:8080,24433:4433,9999:9999 [+] mapping port 20080 -> 192.168.100.2:80 [+] mapping port 20443 -> 192.168.100.2:443 [+] mapping port 28080 -> 192.168.100.2:8080 [+] mapping port 24433 -> 192.168.100.2:4433 [+] mapping port 9999 -> 192.168.100.2:9999 ___ __ __ _ __ __ / __| / | | | / / by Saumil Shah | The Exploit Laboratory | __| |/| | |_| ) ( @therealsaumil | emux.exploitlab.net ___|_| |_____/_/_ [EMUX-DOCKER !] ~$ 1. Start the EMUX Docker Container
  • 15. @therealsaumil @_ringzer0 Launch the target 2. Run launcher and boot into Damn Vulnerable ARM Router [EMUX-DOCKER !] ~$ launcher
  • 16. @therealsaumil @_ringzer0 Start Userspace ./emux-docker-shell [emux-docker !] ~$ 3. Open a new terminal window and attach to emux-docker-shell [emux-docker !] ~$ userspace 4. Run userspace
  • 17. @therealsaumil @_ringzer0 Enter the DVAR Console 5. Select "Enter the Damn Vulnerable ARM Router CONSOLE" option
  • 18. @therealsaumil @_ringzer0 Start nweb (our target binary) Entering Damn Vulnerable ARM Router CONSOLE (/bin/sh) [+] Logging enabled [+] EMUX Debug log - /home/r0/workspace/logs/emuxdebug.log [+] QEMU Console log - qemuconsole.log [+] chroot /emux/DV-ARM/rootfs-arm /.emux/emuxshell Script started, output log file is '/home/r0/workspace/logs/emuxdebug.log'. BusyBox v1.23.2 (2021-10-14 18:26:48 IST) built-in shell (ash) / # nweb 80 /www/nweb/ 6. Manually start the nweb web server from the Busybox prompt ./emux-docker-shell [emux-docker !] ~$ curl http://192.168.100.2 <h1>Ringzer0 Hackme</h1> 7. Start another emux-docker-shell and test nweb
  • 19. @therealsaumil @_ringzer0 Grab the attack scripts! [emux-docker !] ~$ cd workspace [emux-docker !] ~/workspace$ wget https://saumil.net/tmp/attack1.py --2022-07-07 14:12:48-- https://saumil.net/tmp/attack1.py Resolving saumil.net (saumil.net)... 208.113.163.5 Connecting to saumil.net (saumil.net)|208.113.163.5|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 535 [text/plain] Saving to: 'attack1.py' attack1.py 100%[=======================>] 535 --.-KB/s in 0s 2022-07-07 14:12:50 (58.9 MB/s) - 'attack1.py' saved [535/535] [emux-docker !] ~/workspace$ chmod +x attack1.py 8. From the emux-docker-shell grab the following attack scripts
  • 21. @therealsaumil @_ringzer0 HERE BE THE GOODS CODE: https://github.com/therealsaumil/emux !- ANNOUNCEMENTS: @therealsaumil DOCS: https://emux.exploitlab.net/