RIVERSIDE RESEARCH INSTITUTE Helikaon Linux Debugger: A Stealthy Custom Debugger For Linux Jason Raber, Team Lead - Reverse Engineer.

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Utilizing the GDB debugger to analyze programs Background and application.
Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
Chapter 5 Anti-Anti-Virus. Anti-Anti-Virus  All viruses self-replicate  Anti-anti-virus means it’s “openly hostile” to AV  Anti-anti-virus techniques?
Chapter 6 Limited Direct Execution
Microprocessor system architectures– IA32 debugging and performance monitoring Jakub Yaghob.
Architectural Support for OS March 29, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Contiki A Lightweight and Flexible Operating System for Tiny Networked Sensors Presented by: Jeremy Schiff.
Accessing parameters from the stack and calling functions.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
OllyDbg Debuger.
What are Exception and Interrupts? MIPS terminology Exception: any unexpected change in the internal control flow – Invoking an operating system service.
Code Injection and Software Cracking’s Effect on Network Security Group 5 Jason Fritts Utsav Kanani Zener Bayudan ECE 4112 Fall 2007.
Embedded Systems Principle of Debugger. Reference Materials kl.de/avr_projects/arm_projects/#winarmhttp://
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
System Calls 1.
Trying to like a boss… REVERSE ENGINEERING. WHAT EVEN IS… REVERSE ENGINEERING?? Reverse engineering is the process of disassembling and analyzing a particular.
Micro-Computer Applications: Procedures & Interrupts Dr. Eng. Amr T. Abdel-Hamid ELECT 707 Fall 2011.
Application Security Tom Chothia Computer Security, Lecture 14.
Practical Malware Analysis Ch 8: Debugging Rev
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
Memory & Storage Architecture Seoul National University GDB commands Hyeon-gyu School of Computer Science and Engineering.
Orchestra: Intrusion Detection Using Parallel Execution and Monitoring of Program Variants in User-Space Babak Salamat, Todd Jackson, Andreas Gal, Michael.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2011.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Part 3: Advanced Dynamic Analysis Chapter 8: Debugging.
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Goals: To gain an understanding of assembly To get your hands dirty in GDB.
1 CSE 451 Section 2: Interrupts, Syscalls, Virtual Machines, and Project 1.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Introduction to InfoSec – Recitation 2 Nir Krakowski (nirkrako at post.tau.ac.il) Itamar Gilad (itamargi at post.tau.ac.il)
RIVERSIDE RESEARCH INSTITUTE Deobfuscator: An Automated Approach to the Identification and Removal of Code Obfuscation Eric Laspe, Reverse Engineer Jason.
CSNB374: Microprocessor Systems Chapter 5: Procedures and Interrupts.
CNIT 127: Exploit Development Ch 3: Shellcode. Topics Protection rings Syscalls Shellcode nasm Assembler ld GNU Linker objdump to see contents of object.
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
1 CSE451 Architectural Supports for Operating Systems Autumn 2002 Gary Kimura Lecture #2 October 2, 2002.
Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions.
Functions/Methods in Assembly
7. IRQ and PIC ENGI 3655 Lab Sessions. Richard Khoury2 Textbook Readings  Interrupts ◦ Section
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
Lecture 7 Rootkits Hoglund/Butler (Chapter 5-6). Avoiding detection Two ways rootkits can avoid detection –Modify execution path of operating system to.
VMM Based Rootkit Detection on Android
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
CSc 453 Linking and Loading
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
Lecture 10 Anti-debugger techniques. Anti-debuggers Making reverse-engineering and disassembly painful –Polymorphism –Encryption –Interrupt disabling.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2014.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Tracing for Hardware, Driver and Binary Reverse Engineering in Linux Mathieu Desnoyers Recon 2006.
Static and dynamic analysis of binaries
Live Phishing Attack Authentication Activity from a Foreign Address.
Exceptional Control Flow
Dynamic Analysis ddaa.
Debugging with gdb gdb is the GNU debugger on our CS machines.
CS 3305 System Calls Lecture 7.
Malware Incident Response  Dynamic Analysis - 2
Assembly Language Programming II: C Compiler Calling Sequences
Discussions on HW2 Objectives
Architectural Support for OS
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2015.
Discussions on HW2 Objectives
Reverse engineering through full system simulations
Architectural Support for OS
Following Malware Execution in IDA
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2016.
CAP6135: Malware and Software Vulnerability Analysis Buffer Overflow : Example of Using GDB to Check Stack Memory Cliff Zou Spring 2013.
Interrupts and System Calls
Return-to-libc Attacks
Presentation transcript:

RIVERSIDE RESEARCH INSTITUTE Helikaon Linux Debugger: A Stealthy Custom Debugger For Linux Jason Raber, Team Lead - Reverse Engineer

RECON2008 Overview The Problem: Anti-debugging Helikaon: How it works Demo Nuts and Bolts Debugger Output This and That Future Work Summary

RECON2008 The Problem: Anti-debugging Linux OS is not immune to malware and viruses Protect their IP Why custom debugger? –COTS debuggers, such as GDB and IDA Pro, are detected in Linux utilizing a variety of anti-debugging techniques –Often interesting to break protections, why reproduce every time

RECON2008 The Problem: Anti-debugging Traditional Ring-3 debuggers (GDB and IDA Pro) need to register with the OS to begin debugging a user application They need to handle signals such as a SIGTRAP to handle an INT 3, and are easily detectable due to Linux debuggers needing to use ‘ptrace’ to debug a binary Using the Helikaon debugger, registration with the OS is not required Checks for ptrace, signal, INT 3’s, and hardware debug register use are circumvented

RECON2008 Helikaon “Helikaon” — a stealthy Linux-driver- based debugger that will aid the engineer in debugging a running executable

RECON2008 Feature Comparison Chart User Debuggers (gdb, IDA Pro) Helikaon Debugger Caught by Registration-based Debugger Checks (e.g. Ptrace(), signal()) YesNo Uses INT 3's and Debug Registers for Breakpoints YesNo Caught by Single-stepping ChecksYesNo Caught by IDT ChecksYesNo Reading /proc/self/statYesNo Caught by Exception HandlersYesNo Parent-child DebuggingYesNo Timing checksYesNo Caught by User App Signature Detection YesNo

RECON2008 How is it stealthy? Helikaon injects a jump at runtime from kernel land into a user space running process rather than using standard debugger breakpoints like “INT 3” or DR0-DR7 hardware registers Using Helikaon to inject jumps to reroute code allows the debugger to have command of the running executable at a particular address Since the driver’s injections are dynamic, the code remains unmodified after its run is completed and injected jumps are removed immediately after they are used

RECON2008 Anti-debug Example

RECON2008 GDB Detected Disassembled program run through GDB debugger shows debugger detected

RECON2008 IF Debugger undetected Add a breakpoint in the Helikaon 0x80481D8

RECON2008 Running Helikaon View execution state (via registers etc) “No Debugger present or CC detected or signal detected”

RECON2008 Done at Runtime Inject jumps to reroute code allows the Helikaon debugger to have command of running exe Breakpoints on packed code Code remains unmodified on file

RECON2008 Nuts and Bolts The driver needs three things before being compiled and loaded: 1.Breakpoint address 2.Slack space address (could use startup code space) 3.Return address of a Syscall such as ‘uname’

RECON2008 Nuts and Bolts Cont. The chosen Syscall should be one that executes early, say in startup code, like the Syscall to ‘uname’

RECON2008 Why uname - Linux Kernel User Process Linux Kernel int 80

RECON2008 Hook Kernel via syscalls User Process Linux Kernel int 80 Helikaon Driver

RECON2008 Hooking process

RECON2008 Hooked uname Where the fun begins

RECON2008 Putting it together Helikaon Driver tasks 1. Hook the Syscalls ‘uname’ and ‘fdatasync’ – (could be other Syscall instead). User Process Runs 1. Syscall ‘uname’ executed in startup code. Helikaon Driver tasks 1.Hooked Syscall ‘uname’ rerouted to driver (previous slide) 2.Save off stolen bytes (where the breakpoint will go). 3.From hooked Syscall inject a “JMP slackspace” into the running process where you want to add the breakpoint. 4.Copy breakpoint handler code into slack space. Breakpoint Hit – User Process tasks 1.When EIP hits the “JMP slackspace” control will pass to slack space (handler code). 2.Handler code – push registers on stack. 3.Handler code – interrupt (generates Syscall ‘fdatasync’ – already hooked Syscall :). Helikaon Driver tasks – hooked ‘fdatasync’ 1.Print the registers from hooked Syscall fdatasync. 2.Replace stolen bytes in user process. 3.Optional: Modify registers or print memory. 4.Returns back to User Process. User Process tasks 1.Still in slack space – Pop all registers that were pushed on stack. 2.Jump back were breakpoint was (stolen bytes have been replaced). 3.Continue execution.

RECON2008 Putting it Together Cont. uname() Linux Kernel int 80 User Process Startup Main() BP (Jmp inserted) push regs fdatasync() Pop regs (10) Jmp BP Addr (11) Slack space Hooked syscalls Helikaon Hooked_uname() Steal bytes (2) Add BP Add Handler Code Hooked_fdatasync() Print regs (7) Replace stolen bytes Return to Slack (9) (1) (3) (4) int 80 (6) (5) (8)

1

RECON2008 Uname executed

RECON2008 Break Point Hit 0x80481D8 JMP 0x Move stack pointer in EBX so I can deref. Register values

RECON2008 This and That Encrypted code that becomes decrypted in memory could make a system call Looped code – Replace stolen bytes in slack then JMP [bpAddr + 5] Could reroute every instruction (instruction tracing)

RECON2008 Summary Software that prevents a reverse engineer from dynamic analysis through means of anti-debugging measures can be thwarted using Helikaon Debugger Utilizes ‘int 80’ to the reverse engineer’s advantage

RECON2008 Future Work Ability to reroute instructions in other drivers GUI front end controlled by user Utilize shared memory instead of slack space or clean up better in slack space

RECON2008 Contact Jason Raber Team Lead - Reverse Engineer