SlideShare ist ein Scribd-Unternehmen logo
1 von 26
Downloaden Sie, um offline zu lesen
Compromising Linux Virtual Machines
with Debugging Mechanisms
Russell Sanford
xort@blacksecurity.org
October 2016
What are we going to be covering?
• Some kernel hacking!
• Injecting API calls into running 64bit kernels
• All Kernels 3x/4x (64bit)
• Tool Release automating attack: bl4ck_vmpop.py !!!
Why?
• Bypass disk encryption schemes
• Get to underlining OS & code to audit!
• Nobody has talked about abusing VMware’s debugging features?
Previous work has only be done on infecting paused VM memory stored on disk (SLOW!!!)
Tools Involved
• IDA Pro 64bit
• VMware Workstation >= 5.0 or VMware Player >= 3.0
• Binwalk
The Old Way – Manual Exploitation
• Compiling another kernel of the same version
• Comparing function calls & string usage against the
kernel with symbols.
• Slowly locating and labelling the functions needed
Manually hooking function calls and Injecting substituted
commands into target
VMware GDB Stubs
•VMware Workstation >= 5.0
•VMware Player >= 3.0
•Fusion
•Allow R/W/X of memory, ability to single step, etc @ kernel level
•Can be done to booted machine (must be temporarily paused)
•When attaching to VMware we land in default_idle()
The Plan… Automating Exploitation
•1) Extracting the kernel for IDA with binwalk
•2) Decompile kernel in IDA
•3) Enable debugging in VMware VMX file
•4) Attach IDA database to VMware’s gdbserver port (8864)
•5) Locate kernel API using unique byte sequences *
• A) _vmalloc()
• B) call_usermodehelper_setup()
• C) call_usermodehelper_exec()
• D) call_usermodehelper_fns()
•6) Back up current state of processor (Back up Registers)
•7) Call _vmalloc() to allocate working space for passing argv[] (program arguments)
•8) Populate memory area with argv[] information
•9) Call call_usermodehelper_setup() to initialize subprocess_info structure *
•10) Pass subprocess_info structure to call_usermodehelper_exec() *
•11) Restore backed up registers and restore control to CPU
* In some 3x versions call_usermodehelper_fns() is used in place of _setup() + _exec()
Kernel API Involved
_vmalloc(unsigned __int64 size,
gfp_t gfp_mask,
pgprot_t prot )
call_usermodehelper_setup(char *path,
char **argv,
char **envp,
gfp_t gfp_mask,
int (*init)(subprocess_info *, cred *),
void (*cleanup)(subprocess_info *),
void *data )
call_usermodehelper_fns(char *path,
char **argv,
char **envp,
int wait,
int (*init)(subprocess_info *, cred *),
void (*cleanup)(subprocess_info *),
void *data )
call_usermodehelper_exec(subprocess_info *sub_info,
int wait )
1) Allocating Memory
_vmalloc()
2) Launching a Command In Userland
call_usermodehelper_setup()
call_usermodehelper_exec()
OR
call_usermodehelper_fns()
call_usermodehelper_setup & _exec Example
struct subprocess_info *info;
char userprog[] = "/bin/bash";
char *argv[] = {userprog, “-c", “/bin/bash < /dev/ttyS0 > /dev/ttyS0 2> /dev/ttyS0”,
NULL };
char *envp[] = NULL;
info = call_usermodehelper_setup(userprog, argv, envp, UMH_WAIT_EXEC,
NULL, NULL, NULL);
call_usermodehelper_exec(info, wait | UMH_KILLABLE);
Step #1 Extracting the kernel with binwalk for IDA
binwalk –e my_kernel.bin)
cd _my_kernel.bin
file * | grep ELF
A directory named “_my_kernel.bin” will be created
Change into the directory of extracted files
use the ‘file’ and ‘grep’ commands to locate extracted
kernel
Step #3 Enable debugging in VMware VMX file
•Virtual Machines Can Be Paused and Restarted in Debug Mode !
(gdbserver)
Step #2 Decompile the Kernel in IDA
1) Open the 64-bit ELF file with IDA Pro
and click “OK” to begin analysis
2) Wait for analysis to complete. Analysis
indicator at bottom right to say ‘idle’
Step #4 Attach IDA database to VMware’s gdbserver
Select Debugger->Select Debugger
from drop down menu and Select
‘Remote GDB debugger’
Select Debugger->Process Options
and verify port 8864 is selected
Select Debugger->Attach To
Process to connect to Vmware’s
gdbserver.
Step #4 Attach IDA database to VMware’s gdbserver
Select Debugger->Debugger
Options from drop down menu
Click ‘Set Specific Options’ in the Debugger Setup Window
Click ‘Memory Map’ in the GDB Configuration Window
Right-Click in the ‘Manual Memory Regions’ Window and select ‘Insert’
Continued….
Step #4 Attach IDA database to VMware’s gdbserver
The default End Address is
0xFF00000000000000
Change this value to
0xFFFFFFFFFFFFF000
…Continued
Step #5 Locate kernel API using unique byte sequences
Formula:
• When ‘Search Key‘ is encountered in memory – Analyze the next X bytes
(predetermined range)
• Check byte range for patterns known to exist uniquely to the function we are
looking for
• Check byte range to make sure patterns do not exist within range
• Find beginning of function
Step #6 Back up current state of processor
•Back up current state of processor (Back up Registers)
•Easy to do with IDA
•Backup up Registers with IDA Pro’s GetRegValue() function
Step #7 Allocating working space with _vmalloc()
• vmalloc() > kmalloc() for our needs
•Provides Larger Non-Contiguous Memory Allocations
_vmalloc(unsigned __int64 size, gfp_t gfp_mask,
pgprot_t prot)
_vmalloc(0x1000, 0x20, 0x8000000000000163)
Step #8 Populate memory area with argv[] info
• Top area is set aside to hold Qword (8 bytes)
pointers to strings (ARGV array)
• Ends with a NULL (0x0) Qword to terminate
array
• Bottom area will hold actual string data.
• Strings are C-Strings (NULL byte terminated)
Step #9 Call call_usermodehelper_setup() to
initialize subprocess_info struct
Call_usermodehelper_setup()
returns a pointer to a
initialized subprocess_info
structure.
ENVP, *init, *cleanup, and *data
Can be NULL
call_usermodehelper_setup(char *path, char **argv, char **envp, gfp_t gfp_mask,
int (*init)(subprocess_info *, cred *), void (*cleanup)(subprocess_info *), void *data)
Step #10 Pass subprocess_info structure to
call_usermodehelper_exec()
• Pass subprocess_info structure to call_usermodehelper_exec()
• Call with wait = 0
• Executes command in User Land
call_usermodehelper_exec(subprocess_info *sub_info, int wait)
Step #11 Restore processor’s saved state
•Restore the saved state of processor (Back up Registers)
•Easy to do with IDA
•Restore Registers with SetRegValue() function
Current Payloads
•Serial Bind Shell
•Add SUID 0 (root) User
•Add User
•TCP Connect Back
•Run a command as Root
Pwnage with bl4ck_vmpop.py (idapython)
Serial Bind Shell Leveraged from a Linux Virtual Machine
What's Next?
MIPS
ARM
Standalone program independent of IDA Pro
Automated hardware hacking tool?
Thanks!

Weitere ähnliche Inhalte

Was ist angesagt?

AVX-512(フォーマット)詳解
AVX-512(フォーマット)詳解AVX-512(フォーマット)詳解
AVX-512(フォーマット)詳解MITSUNARI Shigeo
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File SystemAdrian Huang
 
Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Angel Boy
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
Reliable Windows Heap Exploits
Reliable Windows Heap ExploitsReliable Windows Heap Exploits
Reliable Windows Heap Exploitsamiable_indian
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedVmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedAdrian Huang
 
Process Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelProcess Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelHaifeng Li
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data RepresentationWang Hsiangkai
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)shimosawa
 
SpectreBustersあるいはLinuxにおけるSpectre対策
SpectreBustersあるいはLinuxにおけるSpectre対策SpectreBustersあるいはLinuxにおけるSpectre対策
SpectreBustersあるいはLinuxにおけるSpectre対策Masami Hiramatsu
 
Anatomy of the loadable kernel module (lkm)
Anatomy of the loadable kernel module (lkm)Anatomy of the loadable kernel module (lkm)
Anatomy of the loadable kernel module (lkm)Adrian Huang
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in LinuxAdrian Huang
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzerDmitry Vyukov
 
あなたの知らないnopたち@ラボユース合宿
あなたの知らないnopたち@ラボユース合宿あなたの知らないnopたち@ラボユース合宿
あなたの知らないnopたち@ラボユース合宿MITSUNARI Shigeo
 

Was ist angesagt? (20)

AVX-512(フォーマット)詳解
AVX-512(フォーマット)詳解AVX-512(フォーマット)詳解
AVX-512(フォーマット)詳解
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)Windows 10 Nt Heap Exploitation (English version)
Windows 10 Nt Heap Exploitation (English version)
 
WSL Reloaded
WSL ReloadedWSL Reloaded
WSL Reloaded
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
Reliable Windows Heap Exploits
Reliable Windows Heap ExploitsReliable Windows Heap Exploits
Reliable Windows Heap Exploits
 
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is bootedVmlinux: anatomy of bzimage and how x86 64 processor is booted
Vmlinux: anatomy of bzimage and how x86 64 processor is booted
 
Vulkan 1.1 Reference Guide
Vulkan 1.1 Reference GuideVulkan 1.1 Reference Guide
Vulkan 1.1 Reference Guide
 
Process Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux KernelProcess Scheduler and Balancer in Linux Kernel
Process Scheduler and Balancer in Linux Kernel
 
from Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Worksfrom Source to Binary: How GNU Toolchain Works
from Source to Binary: How GNU Toolchain Works
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data Representation
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
Execution
ExecutionExecution
Execution
 
SpectreBustersあるいはLinuxにおけるSpectre対策
SpectreBustersあるいはLinuxにおけるSpectre対策SpectreBustersあるいはLinuxにおけるSpectre対策
SpectreBustersあるいはLinuxにおけるSpectre対策
 
Anatomy of the loadable kernel module (lkm)
Anatomy of the loadable kernel module (lkm)Anatomy of the loadable kernel module (lkm)
Anatomy of the loadable kernel module (lkm)
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in Linux
 
Hands-on ethernet driver
Hands-on ethernet driverHands-on ethernet driver
Hands-on ethernet driver
 
syzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzersyzkaller: the next gen kernel fuzzer
syzkaller: the next gen kernel fuzzer
 
あなたの知らないnopたち@ラボユース合宿
あなたの知らないnopたち@ラボユース合宿あなたの知らないnopたち@ラボユース合宿
あなたの知らないnopたち@ラボユース合宿
 
FreeRTOS
FreeRTOSFreeRTOS
FreeRTOS
 

Ähnlich wie Compromising Linux Virtual Machines with Debugging Mechanisms

Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROPJapneet Singh
 
NativeBoost
NativeBoostNativeBoost
NativeBoostESUG
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)shimosawa
 
The Silence of the Canaries
The Silence of the CanariesThe Silence of the Canaries
The Silence of the CanariesKernel TLV
 
Linux SMEP bypass techniques
Linux SMEP bypass techniquesLinux SMEP bypass techniques
Linux SMEP bypass techniquesVitaly Nikolenko
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?Roman Elizarov
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesCharles Nutter
 
Java gpu computing
Java gpu computingJava gpu computing
Java gpu computingArjan Lamers
 
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them all
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them allDEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them all
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them allFelipe Prado
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopQuey-Liang Kao
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit AutomationMoabi.com
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012DefCamp
 
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...Faisal Akber
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisTamas K Lengyel
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesAlexandra Masterson
 
0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdf0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdfscribdsituation719
 

Ähnlich wie Compromising Linux Virtual Machines with Debugging Mechanisms (20)

Bypassing DEP using ROP
Bypassing DEP using ROPBypassing DEP using ROP
Bypassing DEP using ROP
 
NativeBoost
NativeBoostNativeBoost
NativeBoost
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
The Silence of the Canaries
The Silence of the CanariesThe Silence of the Canaries
The Silence of the Canaries
 
Linux SMEP bypass techniques
Linux SMEP bypass techniquesLinux SMEP bypass techniques
Linux SMEP bypass techniques
 
Why GC is eating all my CPU?
Why GC is eating all my CPU?Why GC is eating all my CPU?
Why GC is eating all my CPU?
 
JavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for DummiesJavaOne 2012 - JVM JIT for Dummies
JavaOne 2012 - JVM JIT for Dummies
 
Genode Compositions
Genode CompositionsGenode Compositions
Genode Compositions
 
Java gpu computing
Java gpu computingJava gpu computing
Java gpu computing
 
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them all
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them allDEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them all
DEF CON 27- ITZIK KOTLER and AMIT KLEIN - gotta catch them all
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
Talk 160920 @ Cat System Workshop
Talk 160920 @ Cat System WorkshopTalk 160920 @ Cat System Workshop
Talk 160920 @ Cat System Workshop
 
SdE2 - Pilot Tock
SdE2 - Pilot TockSdE2 - Pilot Tock
SdE2 - Pilot Tock
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
 
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
PGCon 2014 - What Do You Mean my Database Server Core Dumped? - How to Inspec...
 
Stealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware AnalysisStealthy, Hypervisor-based Malware Analysis
Stealthy, Hypervisor-based Malware Analysis
 
Valgrind
ValgrindValgrind
Valgrind
 
GOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter SlidesGOTO Night with Charles Nutter Slides
GOTO Night with Charles Nutter Slides
 
0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdf0x01 - Breaking into Linux VMs for Fun and Profit.pdf
0x01 - Breaking into Linux VMs for Fun and Profit.pdf
 

Kürzlich hochgeladen

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 

Kürzlich hochgeladen (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

Compromising Linux Virtual Machines with Debugging Mechanisms

  • 1. Compromising Linux Virtual Machines with Debugging Mechanisms Russell Sanford xort@blacksecurity.org October 2016
  • 2. What are we going to be covering? • Some kernel hacking! • Injecting API calls into running 64bit kernels • All Kernels 3x/4x (64bit) • Tool Release automating attack: bl4ck_vmpop.py !!!
  • 3. Why? • Bypass disk encryption schemes • Get to underlining OS & code to audit! • Nobody has talked about abusing VMware’s debugging features? Previous work has only be done on infecting paused VM memory stored on disk (SLOW!!!)
  • 4. Tools Involved • IDA Pro 64bit • VMware Workstation >= 5.0 or VMware Player >= 3.0 • Binwalk
  • 5. The Old Way – Manual Exploitation • Compiling another kernel of the same version • Comparing function calls & string usage against the kernel with symbols. • Slowly locating and labelling the functions needed Manually hooking function calls and Injecting substituted commands into target
  • 6. VMware GDB Stubs •VMware Workstation >= 5.0 •VMware Player >= 3.0 •Fusion •Allow R/W/X of memory, ability to single step, etc @ kernel level •Can be done to booted machine (must be temporarily paused) •When attaching to VMware we land in default_idle()
  • 7. The Plan… Automating Exploitation •1) Extracting the kernel for IDA with binwalk •2) Decompile kernel in IDA •3) Enable debugging in VMware VMX file •4) Attach IDA database to VMware’s gdbserver port (8864) •5) Locate kernel API using unique byte sequences * • A) _vmalloc() • B) call_usermodehelper_setup() • C) call_usermodehelper_exec() • D) call_usermodehelper_fns() •6) Back up current state of processor (Back up Registers) •7) Call _vmalloc() to allocate working space for passing argv[] (program arguments) •8) Populate memory area with argv[] information •9) Call call_usermodehelper_setup() to initialize subprocess_info structure * •10) Pass subprocess_info structure to call_usermodehelper_exec() * •11) Restore backed up registers and restore control to CPU * In some 3x versions call_usermodehelper_fns() is used in place of _setup() + _exec()
  • 8. Kernel API Involved _vmalloc(unsigned __int64 size, gfp_t gfp_mask, pgprot_t prot ) call_usermodehelper_setup(char *path, char **argv, char **envp, gfp_t gfp_mask, int (*init)(subprocess_info *, cred *), void (*cleanup)(subprocess_info *), void *data ) call_usermodehelper_fns(char *path, char **argv, char **envp, int wait, int (*init)(subprocess_info *, cred *), void (*cleanup)(subprocess_info *), void *data ) call_usermodehelper_exec(subprocess_info *sub_info, int wait ) 1) Allocating Memory _vmalloc() 2) Launching a Command In Userland call_usermodehelper_setup() call_usermodehelper_exec() OR call_usermodehelper_fns()
  • 9. call_usermodehelper_setup & _exec Example struct subprocess_info *info; char userprog[] = "/bin/bash"; char *argv[] = {userprog, “-c", “/bin/bash < /dev/ttyS0 > /dev/ttyS0 2> /dev/ttyS0”, NULL }; char *envp[] = NULL; info = call_usermodehelper_setup(userprog, argv, envp, UMH_WAIT_EXEC, NULL, NULL, NULL); call_usermodehelper_exec(info, wait | UMH_KILLABLE);
  • 10. Step #1 Extracting the kernel with binwalk for IDA binwalk –e my_kernel.bin) cd _my_kernel.bin file * | grep ELF A directory named “_my_kernel.bin” will be created Change into the directory of extracted files use the ‘file’ and ‘grep’ commands to locate extracted kernel
  • 11. Step #3 Enable debugging in VMware VMX file •Virtual Machines Can Be Paused and Restarted in Debug Mode ! (gdbserver)
  • 12. Step #2 Decompile the Kernel in IDA 1) Open the 64-bit ELF file with IDA Pro and click “OK” to begin analysis 2) Wait for analysis to complete. Analysis indicator at bottom right to say ‘idle’
  • 13. Step #4 Attach IDA database to VMware’s gdbserver Select Debugger->Select Debugger from drop down menu and Select ‘Remote GDB debugger’ Select Debugger->Process Options and verify port 8864 is selected Select Debugger->Attach To Process to connect to Vmware’s gdbserver.
  • 14. Step #4 Attach IDA database to VMware’s gdbserver Select Debugger->Debugger Options from drop down menu Click ‘Set Specific Options’ in the Debugger Setup Window Click ‘Memory Map’ in the GDB Configuration Window Right-Click in the ‘Manual Memory Regions’ Window and select ‘Insert’ Continued….
  • 15. Step #4 Attach IDA database to VMware’s gdbserver The default End Address is 0xFF00000000000000 Change this value to 0xFFFFFFFFFFFFF000 …Continued
  • 16. Step #5 Locate kernel API using unique byte sequences Formula: • When ‘Search Key‘ is encountered in memory – Analyze the next X bytes (predetermined range) • Check byte range for patterns known to exist uniquely to the function we are looking for • Check byte range to make sure patterns do not exist within range • Find beginning of function
  • 17. Step #6 Back up current state of processor •Back up current state of processor (Back up Registers) •Easy to do with IDA •Backup up Registers with IDA Pro’s GetRegValue() function
  • 18. Step #7 Allocating working space with _vmalloc() • vmalloc() > kmalloc() for our needs •Provides Larger Non-Contiguous Memory Allocations _vmalloc(unsigned __int64 size, gfp_t gfp_mask, pgprot_t prot) _vmalloc(0x1000, 0x20, 0x8000000000000163)
  • 19. Step #8 Populate memory area with argv[] info • Top area is set aside to hold Qword (8 bytes) pointers to strings (ARGV array) • Ends with a NULL (0x0) Qword to terminate array • Bottom area will hold actual string data. • Strings are C-Strings (NULL byte terminated)
  • 20. Step #9 Call call_usermodehelper_setup() to initialize subprocess_info struct Call_usermodehelper_setup() returns a pointer to a initialized subprocess_info structure. ENVP, *init, *cleanup, and *data Can be NULL call_usermodehelper_setup(char *path, char **argv, char **envp, gfp_t gfp_mask, int (*init)(subprocess_info *, cred *), void (*cleanup)(subprocess_info *), void *data)
  • 21. Step #10 Pass subprocess_info structure to call_usermodehelper_exec() • Pass subprocess_info structure to call_usermodehelper_exec() • Call with wait = 0 • Executes command in User Land call_usermodehelper_exec(subprocess_info *sub_info, int wait)
  • 22. Step #11 Restore processor’s saved state •Restore the saved state of processor (Back up Registers) •Easy to do with IDA •Restore Registers with SetRegValue() function
  • 23. Current Payloads •Serial Bind Shell •Add SUID 0 (root) User •Add User •TCP Connect Back •Run a command as Root
  • 24. Pwnage with bl4ck_vmpop.py (idapython) Serial Bind Shell Leveraged from a Linux Virtual Machine
  • 25. What's Next? MIPS ARM Standalone program independent of IDA Pro Automated hardware hacking tool?