Following Malware Execution in IDA

Slides:



Advertisements
Similar presentations
Operating Systems Components of OS
Advertisements

Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
1 Exceptions, Interrupts & Traps Operating System Hebrew University Spring 2007.
Operating System Security : David Phillips A Study of Windows Rootkits.
RIVERSIDE RESEARCH INSTITUTE Helikaon Linux Debugger: A Stealthy Custom Debugger For Linux Jason Raber, Team Lead - Reverse Engineer.
Nullcon Goa 2010http://nullcon.net Intelligent Debugging and in-memory Fuzzers By Vishwas Sharma Amandeep Bharti Rohan Thakur.
Chap 2 System Structures.
Operating-System Structures
1 OS Structure, Processes & Process Management. 2 Recap OS functions  Coordinator  Protection  Communication  Resource management  Service provider.
1 Processes and Pipes COS 217 Professor Jennifer Rexford.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
OS Spring’03 Introduction Operating Systems Spring 2003.
OS Spring’04 Introduction Operating Systems Spring 2004.
1 CS503: Operating Systems Part 1: OS Interface Dongyan Xu Department of Computer Science Purdue University.
System Calls 1.
Practical Malware Analysis Ch 8: Debugging Rev
3/11/2002CSE Input/Output Input/Output Control Datapath Memory Processor Input Output Memory Input Output Network Control Datapath Processor.
OPERATING SYSTEM OVERVIEW. Contents Basic hardware elements.
Part 3: Advanced Dynamic Analysis Chapter 8: Debugging.
Chapter 2: Operating-System Structures. 2.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 2: Operating-System Structures Operating.
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles Processes & Threads Emery Berger and Mark Corner University.
Recall: Three I/O Methods Synchronous: Wait for I/O operation to complete. Asynchronous: Post I/O request and switch to other work. DMA (Direct Memory.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto OS-Related Hardware.
Lecture 11 Dynamic link libraries. Differences between static libraries and DLLs In static library code is added to the executable. In DLL, the code is.
1 Confidential Enterprise Solutions Group Process and Threads.
MICHALIS POLYCHRONAKIS(COLUMBIA UNIVERSITY,USA), KOSTAS G. ANAGNOSTAKIS(NIOMETRICS, SINGAPORE), EVANGELOS P. MARKATOS(FORTH-ICS, GREECE) ACSAC,2010 Comprehensive.
Operating Systems Lecture November 2015© Copyright Virtual University of Pakistan 2 Agenda for Today Review of previous lecture Hardware (I/O, memory,
UNIX Unit 1- Architecture of Unix - By Pratima.
Operating Systems Security
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Lecture 5 Rootkits Hoglund/Butler (Chapters 1-3).
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
CNIT 127: Exploit Development Ch 8: Windows Overflows Part 1.
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.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Introduction to Operating Systems Concepts
Computer System Structures
Protecting Memory What is there to protect in memory?
Processes and threads.
Live Phishing Attack Authentication Activity from a Foreign Address.
Exceptional Control Flow
Chapter 3: Process Concept
Operating Systems •The kernel is a program that constitutes the central core of a computer operating system. It has complete control over everything that.
Mechanism: Limited Direct Execution
CS399 New Beginnings Jonathan Walpole.
Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command Some by invocation from other running.
CS 3305 System Calls Lecture 7.
Intro to Processes CSSE 332 Operating Systems
KERNEL ARCHITECTURE.
Chapter 4: Threads.
Topics Introduction to File Input and Output
Loaders and Linkers: Features
Machine Independent Features
Chapter 2: System Structures
Memory Management Tasks
Lecture Topics: 11/1 General Operating System Concepts Processes
Threads Chapter 4.
Operating Systems Lecture 3.
CSE 451: Operating Systems Autumn 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 596 Allen Center 1.
CSE 451: Operating Systems Autumn 2001 Lecture 2 Architectural Support for Operating Systems Brian Bershad 310 Sieg Hall 1.
Chapter 2: Operating-System Structures
Malware and the Windows API
CSE 451: Operating Systems Winter 2003 Lecture 2 Architectural Support for Operating Systems Hank Levy 412 Sieg Hall 1.
CSC 497/583 Advanced Topics in Computer Security
Topics Introduction to File Input and Output
Interrupts and System Calls
In Today’s Class.. General Kernel Responsibilities Kernel Organization
Interrupts & Syscalls.
Return-to-libc Attacks
Presentation transcript:

Following Malware Execution in IDA

Following Malware Execution IDA Pro’s control flow graphs are very useful for viewing the malware’s possible execution paths Function calls, loops, if statements, etc But malware can transfer execution in ways other than jumps and calls Often need to find out how the malware is executing other code

DLLs

DLL review Dynamic link library Exports functions for other executables to use Advantage: can be shared among running processes, saving memory Any disadvantages?

How Malware Uses DLLs By storing malicious code By using Windows DLLs May export functions to other malware files May be loaded into another process By using Windows DLLs To interact with the operating system via Windows API functions By using third-party DLLs To interact with other non-Windows programs To use a library that may not be on the victim’s machine

Analyzing DLLs DLLs have many points from which code can be executed from Each exported function DllMain – which is not called explicitly, but rather DllMain is called whenever a process loads or unloads the DLL Normally used for managing any resources specific to a process, but malware sometimes uses it for other purposes

Processes

Process Review Process – program in execution Used to keep programs from interfering with each other Have separate address spaces OS manages how processes access shared resources (CPU, filesystem, hardware, etc)

Creating a Process The CreateProcess function is typically used to create a process Has many parameters, gives caller a high amount of control over how the process is created

Running an Embedded Executable Suppose the Malware contains an executable as a resource Uses FindResource, LoadResource, CreateFile, etc to write resource to disk Uses CreateProcess to run the resource

Creating a Remote Shell Remote shell – allows an attacker to run commands on the victim’s computer remotely Can create a remote shell by opening a socket to the attacker’s machine, and then making a single call to CreateProcess!

Creating a Remote Shell Need to pass specific arguments to CreateProcess The lpStartupInfo parameter points to a STARTUPINFO struct This struct contains handles to stdin, stdout, and stderr Point stdin, stdout, and stderr to the socket Call CreateProcess All input from the malware actor over the socket is run on the command line

Creating a Remote Shell – Sample Code Practical Malware Analysis pg 148

Process Injection Malware can inject its own code into a different process Typically performed using the VirtualAlloc, WriteProcessMemory, and CreateRemoteThread API calls Will cover this and other covert launching techniques later

Threads

Thread Review Thread – sequence of instructions belonging to a process that is executed by the CPU Each process contains one or more threads All threads share the process’ memory space Each thread has its own registers and stack

Creating a Thread Done using the CreateThread function Takes lpStartAddress, a pointer to a function Also takes lpParameter, a single parameter to the function The thread executes the function until it returns

Covertly Loading a Malicious Library Can use CreateThread to covertly load a malicious library into a process Need to set certain parameters to CreateThread Pass the address of the LoadLibrary Windows API function as the lpStartAddress parameter Pass the name of the desired library as lpParameter Even more stealthy if “LoadLibrary” and the name of the library are obfuscated

Services

Services Review Service – a task that runs in the background without an associated process or thread Managed by the Windows service manager The command net start can tell you what services are running

Why Malware Uses Services Can be set to automatically run when the computer boots Gives persistence Often run with SYSTEM privileges But need admin to specify this

Creating / Starting a Service OpenSCManager – Returns a handle to the service control manager, which is needed for all other service-related API calls CreateService – Adds a new service to the service control manager Can specify that the service automatically runs at boot StartService – Starts a service manually

Types of Services WIN32_SHARE_PROCESS – Stores code for a service in a DLL, run by svchost.exe WIN32_OWN_PROCESS – Stores code in an EXE, runs as an independent process KERNEL_DRIVER – Used for loading code into the kernel

Exceptions

Exceptions Review Exception – allows a program to handle events outside its normal execution path Can be triggered by: Errors (such as a divide by 0) Hardware (such as invalid memory access) Explicit call to RaiseException

Structured Exception Handling Structured Exception Handling (SEH) – Windows mechanism for handling exceptions List of functions for handling exceptions Each function can handle the exception or pass it to the next handler If an exception makes it to the end of the list without being handled, it is considered an unhandled exception and crashes the process

How Malware Uses Exceptions The SEH is a type of flow control that can’t be followed by disassemblers and can fool debuggers Malware can add its own custom exception handler to the SEH and then use trigger an exception to transfer execution to the handler