Ollydbg: Crash Course in Ollydbg
Ollydbg: Crash Course in Ollydbg
CPU
High Level Assembler Compiler
Assembly Machine
Language
(C, C++, C#, Language Code
etc) (Like .exe
Files)
Software Cycle
• To debug or analyze binary application we need to
convert the machine code to its real source code
▫ This is impossible yet
CPU
High Level Disassembler
Machine
Language
(C, C++, C#, etc) Code
(Like .exe Files)
Software Cycle
• We can only convert machine code to assembly !!
▫ Some projects are working on converting machine code to source code,
but they are not mature yet
Disassembler
CPU
Assembly Machine
Language Code
(Like .exe Files)
Disassembler vs Debugger
• Disassembler will only convert Machine Code to
Assembly Code (Like IDA Pro)
Disassembler vs Debugger
• Debuggers (Like OllyDBG) will show you the assembly code, it will
run the application, in addition to tracing:
▫ Memory
▫ Registers
▫ Stack
• Note: you will see the values of (memory, registers and stack)
changing during processing, and you can change any values.
• Note: If you are debugging a malicious code, it will infect your
machine.
Two Debuggers
• Ollydbg
▫ Most popular for malware analysis
▫ User-mode applications debugging only
• Windbg
▫ Supports kernel-mode debugging
▫ More complex and command line knowledge required
▫ This is Out of the Scope of Our Course
OllyDBG Advantages
• Intuitive user interface.
• Directly loads and debugs DLLs
• Allows for user-defined labels, comments and function descriptions
• No installation - no trash in registry or system directories
• Debugs multithread applications
• Attaches to running programs
• Recognizes ASCII and UNICODE strings
• Sets conditional, logging, memory and hardware breakpoints
• Can export modified version of your Machine Code.
System Requirements
• Works with most Windows Operating Systems
▫ During this course I’ll use Windows 10, 64bit
• 64 MB physical memory (128 MB recommended)
• At least 20 MB free disk space
• VGA display (SVGA with screen resolution at least 800x600 is strongly
recommended)
• Mouse or compatible pointing device (required)
• Administrative Rights
Download OllyDBG
• Download the final stable version from the URL:
▫ http://www.ollydbg.de/download.htm
Start Debugging (2 ways)
• Start the program with the debugger
▫ It stops running immediately prior to the execution of its entry point
• Attach a debugger to a program that is already running
▫ All its threads are paused
▫ Useful to debug a process that is affected by malware
OllyDBG Interface
Disassembler
Shows Instructions Registers
May be Loop
End Routine
and Return
Menu Buttons
Trace Into
Run/Play Trace Over
Pause
Windows Launching
• L : Log Data
• E : Executable Modules
• M : Memory Map
• T : Threads
• W : Windows
• H : Handles
• C : CPU
• / : Patches
• K : Stack
• B : Break Points
• R : References
• … : Run Trace
• S : Source
Stepping
• When you start debugging OllyDBG will detect the entry point of your
application (i.e the Main Function), it will stop there.
Note: Only use the Step Into if you think that this call has important functionality,
otherwise use step over
Stepping INTO vs OVER
• To Step Into > F7
• To Step Over > F8
Breakpoints
• Software execution
• Hardware execution
• Conditional
Software Execution Breakpoints
• The default option for most debuggers
• Debugger overwrites the first byte of the instruction with 0xCC
▫ The instruction for INT 3
▫ An interrupt designed for use with debuggers
▫ When the breakpoint is executed, the OS generates an exception and transfers
control to the debugger