Lesson 3 - Static & Dynamic Analysis
Lesson 3 - Static & Dynamic Analysis
•Monitoring.
• Runtime behavior is carefully monitored.
• Process monitors (system activity), network analyzers (network activity), debuggers, memory analysis tools.
• Data collection:
• System interactions (filesystem, registry, network).
• Memory usage.
• Function & API calls.
• Execution flow.
DYNAMIC ANALYSIS: DEBUGGING & TRACING
•Debugging & tracing.
• Debuggers allow monitoring execution by setting breakpoints & stepping through the code.
• Pausing execution at specific points of interest.
• Examining memory, registers, variables, stacks.
• Understand program's state at specific point.
• Tracing code execution path instruction by instruction.
• In addition, kernel-level tracing & monitoring of system activities.
•Dynamic instrumentation.
• Allows tracking function calls & memory access.
• Code injection & hooking into running processes.
DYNAMIC ANALYSIS: MEMORY ANALYSIS (1)
•Memory analysis.
• Capture & analyze memory dumps during execution.
• Understand memory usage, potential vulnerabilities, encrypted/obfuscated data.
•Detecting instrumentation.
• Check for running monitoring/tracing tools.
• Shutdown if present.
OBFUSCATION: ANTI-DYNAMIC TECHNIQUES (2)
•Detecting/preventing debugging.
• Query OS for running debugger.
• Through API calls.
• Check memory/processor artifacts for debugger presence.
• Processor debug flag set to 1.
• Hinder debugging process.
• Introducing spurious breakpoints.
• Clearing hardware breakpoints.
• Intentionally generating exceptions.
INSTRUMENTATION: INTRO
•Instrumentation.
• Process of inserting of code/probes into program & collecting of valuable runtime data.
•Key instrumentation techniques:
• Dynamic binary instrumentation (DBI).
• Inserting custom codes snippets (instrumentation) into program during runtime for monitoring/modification.
• Code injection.
• Tracing.
• Capturing/recording events/data during execution, providing valuable insights into behavior & interactions.
• System calls, handles, library calls.
INSTRUMENTATION: DBI
•Dynamic binary instrumentation (DBI).
• Capabilities:
• Log arguments & return values.
• What data enters/exits function.
• Modify specific instructions.
• Temporarily (during runtime) change behavior.
• Trigger custom actions.
• Custom code executed whenever function is called.
• Process:
• Load target program.
• Identify instrumentation points.
• Inject probes.
• Execute instrumented program.
• Collect & analyze data.
INSTRUMENTATION: TRACING
•Tracing.
• Classified by the type of event/resource being traced:
• Function calls tracing.
• Identifies when program calls specific functions.
• Reveals execution flow & dependencies.
• System calls tracing.
• Identifies system calls made by program.
• Reveals interactions with the OS, file system, network.
• Library & API calls tracing.
• Identifies calls to shared libraries & API calls.
• Reveals how program utilizes external data structures, functions, services.