CSC 497/583 Advanced Topics in Computer Security

Slides:



Advertisements
Similar presentations
Sample chapter from Reverse Engineering Course.
Advertisements

Memory Protection: Kernel and User Address Spaces  Background  Address binding  How memory protection is achieved.
Assembler/Linker/Loader Mooly Sagiv html:// Chapter 4.3 J. Levine: Linkers & Loaders
Linking & Loading CS-502 Operating Systems
Lecture 10: Linking and loading. Lecture 10 / Page 2AE4B33OSS 2011 Contents Linker vs. loader Linking the executable Libraries Loading executable ELF.
Operating System Security : David Phillips A Study of Windows Rootkits.
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
Disclaimer The Content, Demonstration, Source Code and Programs presented here is "AS IS" without any warranty or conditions.
Memory Management (II)
1 CE6130 現代作業系統核心 Modern Operating System Kernels 許 富 皓.
Tanenbaum, Structured Computer Organization, Fifth Edition, (c) 2006 Pearson Education, Inc. All rights reserved The Assembly Language Level.
OBJECT MODULE FORMATS. The object module format we have employed as an educational device is called OMF (relocatable object format). It’s one of the earliest.
Trying to like a boss… REVERSE ENGINEERING. WHAT EVEN IS… REVERSE ENGINEERING?? Reverse engineering is the process of disassembling and analyzing a particular.
MIPS coding. SPIM Some links can be found such as:
Rootkits in Windows XP  What they are and how they work.
Windows PE files Infections and Heuristic Detection Nicolas BRULEZ / Digital River PACSEC '04.
File System Interface. File Concept Access Methods Directory Structure File-System Mounting File Sharing (skip)‏ File Protection.
File Systems (1). Readings r Reading: Disks, disk scheduling (3.7 of textbook; “How Stuff Works”) r Reading: File System Implementation ( of textbook)
CSE451 Linking and Loading Autumn 2002 Gary Kimura Lecture #21 December 9, 2002.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Static Shared Library. Non-shared v.s. Shared Library A library is a collection of pre-written function calls. Using existing libraries can save a programmer.
CSE 451: Operating Systems Winter 2011 Linking, Loading and Process Startup Mark Zbikowski Gary Kimura.
Homework tar file Download your course tarball from web page – Named using your PSU ID – Chapter labeled for each binary.
Windows workshop 2010 Understanding Software Dependencies in Windows Roland Yap School of Computing National University of Singapore Singapore
NTFS Filing System CHAPTER 9. New Technology File System (NTFS) Started with Window NT in 1993, Windows XP, 2000, Server 2003, 2008, and Window 7 also.
Lecture 11 Example Rootkit. Intel internship Intel CTG (Corporate Technology Group) –Advanced research & development –System integrity services using.
Memory Management Chapter 5 Advanced Operating System.
LECTURE 3 Translation. PROCESS MEMORY There are four general areas of memory in a process. The text area contains the instructions for the application.
METADATA IN.NET Presented By Sukumar Manduva. INTRODUCTION  What is Metadata ? Metadata is a binary information which contains the complete description.
Object Files & Linking. Object Sections Compiled code store as object files – Linux : ELF : Extensible Linking Format – Windows : PE : Portable Execution.
Binding & Dynamic Linking Presented by: Raunak Sulekh(1013) Pooja Kapoor(1008)
GOT overwrites and IAT hooks. What is this?  The GOT hijack was a key exploit technique for me, it was the first time I internalized that we are overwriting.
Computer Basics.
Lecture 3 Translation.
Malware Incident Response - Static Analysis
Shellcode COSC 480 Presentation Alison Buben.
Efficient Software-Based Fault Isolation
Chapter 1. Basic Static Techniques
Interprocess Communications Continued
The University of Adelaide, School of Computer Science
Linking & Loading.
Implementing Processes and Threads
Operating System Structure
CS-3013 Operating Systems C-term 2008
File Management.
Topic 2e High-Level languages and Systems Software
Operation System Program 4
The Assembly Language Level
Computer Science I CSC 135.
Chapter 3. Basic Dynamic Analysis
Chapter 4: Threads.
Case Study 2: Windows History of windows 2000
Lecture 30 Syed Mansoor Sarwar
Lecture Topics: 11/1 General Operating System Concepts Processes
CSE 451: Operating Systems Winter 2010 Module 16 Linking, Loading and Process Startup Mark Zbikowski Gary Kimura 1.
Computer Organization and Design Assembly & Compilation
The Assembly Language Level
Linking & Loading CS-502 Operating Systems
Mastering Memory Modes
CSCI 380: Operating Systems William Killian
CMSC 491/691 Malware Analysis
Implementing Processes and Threads
CSE 451: Operating Systems Winter 2009 Module 16 Linking, Loading and Process Startup Mark Zbikowski Gary Kimura 1.
PROGRAM IN EXECUTION Subject code: CSCI-620
Linking & Loading CS-502 Operating Systems
CSC 497/583 Advanced Topics in Computer Security
Following Malware Execution in IDA
Department of Computer Science
COMP755 Advanced Operating Systems
CSC 497/583 Advanced Topics in Computer Security
Presentation transcript:

CSC 497/583 Advanced Topics in Computer Security Class5 CSC 497/583 Advanced Topics in Computer Security Modern Malware Analysis PE Format (2): NT Header, IAT, EAT Si Chen (schen@wcupa.edu)

Portable Executable (PE) file A Portable Executable (PE) file is the standard binary file format for an Executable (.exe) or DLL under Windows NT, Windows 95, and Win32. Derived from COFF (Common Object File Format) in UNIX platform, and it is not really “portable”.  Now here is the kicker. Even though this specification is spelled out by Microsoft, compilers/linkers chose to ignore some parts of it. To make things even worse, the Microsoft loader doesn't enforce a good portion of this specification and instead makes assumptions if things start getting weird. So even though the spec outlined here says a particular field is supposed to hold a certain value, the compiler/linker or even a malicious actor could put whatever they want in there and the program will likely still run...

Portable Executable (PE) file PE formatted files include: .exe, .scr (executable) .dll, .ocx, .cpl, drv (library) .sys, .vxd (driver files) .obj (objective file) All PE formatted files can be executed, except obj file. .exe, .scr can be directly executed inside Shell (explorer.exe) others can be executed by other program/service PE refers to 32 bit executable file, or PE32. 64 bit executable file is named as PE+ or PE32+. (Note that it is not PE64).

PE Example – Notepad.exe

Load PE file (Notepad.exe) into Memory

DOS Header The first 2 letters are always the letters "MZ", the initials of Mark Zbikowski, who created the first linker for DOS. To some people, the first few bytes in a file that determine the type of file are called the "magic number,"

DOS Header e_lfanew  000000E0

DOS stub https://virtualconsoles.com/online-emulators/dos/

NT Header https://docs.microsoft.com/en-us/windows/desktop/api/winnt/

NT Header

Non-Executable, read/write Section Header Name Privilege .text/.code Executable, read .data Non-Executable, read/write .resource/.rsrc Non-Executable, read

Section Header

Section Header Members Meaning VirtualSize The total size of the section when loaded into memory, in bytes.  VirtualAddress The address of the first byte of the section when loaded into memory (RVA) SizeOfRaw Data The size of the section data on disk, in bytes. PointerToRawData The address of the first byte of the section on disk. Characteristics The characteristics of the image. https://docs.microsoft.com/en-us/windows/desktop/api/winnt/ns-winnt-_image_section_header

Section Header

Inspecting PE Header Information in Linux

Inspecting PE Header Information

Examining PE Section Table and Sections https://hub.docker.com/r/remnux/pescanner/

IAT (Import Address Table)

IAT (Import Address Table) Let’s review the concept of DLL (Dynamic Link Library) again…

Dynamic Linking

16-Bit DOS System import Library  Put binary code of stdio library into the executable file

Static Linking Waste space Hard to maintain Memory Program2 Program2.obj Lib.obj Program1 Program1.obj Lib.obj Program2 Program2.obj Lib.obj Program1 Program1.obj Lib.obj

Dynamic Linking Memory Lib.dll Program2 Lib.obj Program2.obj Program1 Dynamic linking has the following advantages: Saves memory Saves disk space. Upgrades to the DLL are easier. Provides after-market support. Supports multi language programs. Eases the creation of international versions  Memory Lib.dll Lib.obj Program2 Program2.obj Program1 Program1.obj Program2 Program2.obj Lib.dll Lib.obj Program1 Program1.obj

Two ways to Load DLL

Two ways to Load DLL An executable file links to (or loads) a DLL in one of two ways: Explicit Linking (run-time dynamic linking) the executable using the DLL must make function calls to explicitly load and unload the DLL, and to access the DLL's exported functions.  Implicit Linking (load-time dynamic linking) The operating system loads the DLL when the executable using it is loaded.

Two ways to Load DLL Explicit Linking (run-time dynamic linking) Implicit Linking (load-time dynamic linking)

DLL Injection IAT Table Two ways to Load DLL An executable file links to (or loads) a DLL in one of two ways: DLL Injection Explicit Linking (run-time dynamic linking) the executable using the DLL must make function calls to explicitly load and unload the DLL, and to access the DLL's exported functions.  Implicit Linking (load-time dynamic linking) The operating system loads the DLL when the executable using it is loaded. IAT Table

Implicit Linking and IAT (Import Address Table) Notepad.exe Call CreateFileW()  Call 0x01001104  Call 0x7C810CD9

Implicit Linking and IAT (Import Address Table) Notepad.exe Call CreateFileW()  Call 0x01001104  Call 0x7C810CD9 Call 0x01001104 Look up IAT Table Function Name IAT Address Real Address … CreateFileW() 0x01001104 0x7C810CD9 When the application was first compiled, it was designed so that all API calls will NOT use direct hardcoded addresses but rather work through a function pointer. This was accomplished through the use of an import address table. This is a table of function pointers filled in by the windows loader as the dlls are loaded. 

IAT (Import Address Table) Why IAT?

IAT (Import Address Table) Support different Windows Version (9X, 2K, XP, Vista, 7, 8, 10) Call CreateFileW() --> Call 0x01001104 Look up XP IAT Table Function Name IAT Address Real Address … CreateFileW() 0x01001104 0x7C810CD9 Windows 7 Function Name IAT Address Real Address … CreateFileW() 0x01001104 0x7C81FFFF

IAT (Import Address Table) Support DLL Relocation

Look up IAT Table with PEview

Import Directory Table The Import Directory Table contains entries for every DLL which is loaded by the executable. Each entry contains, among other, Import Lookup Table (ILT) and Import Address Table (IAT)

Inspecting file imports with pefile library

EAT (Export Address Table) Similar to IAT, EAT data is stored in IMAGE_EXPORT_DIRECTORY EAT contains an RVA that points to an array of pointers to (RVAs of) the functions in the module. 

Inspecting file export with pefile library

Exploring Dynamically Linked Functions with Dependency Walker

Common DLLs

Exploring Dynamically Linked Functions with Dependency Walker

Packed and Obfuscated Malware Malware writers often use packing or obfuscation to make their files more difficult to detect or analyze. Obfuscated programs are ones whose execution the malware author has attempted to hide. Packed programs are a subset of obfuscated programs in which the malicious program is compressed and cannot be analyzed. Both techniques will severely limit your attempts to statically analyze the malware.

Packers and Cryptos

Packed and Obfuscated Malware

DLL Injection

Q & A