Name 3 major file extensions that commonly use the PE File Format?
EXE, SYS, DLL
PE Sections have a virtual size, and a size on disk – and the two may be different. In what common malware situation may be size on disk be quite a bit lower than size in memory?
Packed code – more space allocated for the unpacked version
Describe briefly (3-4 lines) why PE Files need to use Relative Virtual Addresses (RVA)
Mentioned ImageBase, having to relocate, and having things relative to that.
What is a handle?
It’s simply a pointer to the first memory address of that dll or exe. You can essentially find any part of the file in memory simply from the handle.
Name a few tools to analyse PE files?
PE Browse, Winitor, Hiew, DependencyWalker
How many sections does a PE file usually has?
Usually at least 2 sections - one for code, one for data, exist within a file. There might be one code section, but a couple of different data sections – one for Read only data, one for R/W etc.
What is File Alignment / Section Alignment?
Sections in the file line up with a multiple of the File Alignment value - usually 512 bytes (0x200)
Sections loaded in memory line up with a multiple of the size of page of memory (Section Alignment):
What is RVA?
Relative Virtual Addresses (RVA) - Offset in memory relative to where PE file is loaded.
E.g. Exe loaded at 0x400000, code section at 0x4010000
=> RVA = Target address(0x4010000) - Load address (0x400000) = RVA (0x1000)
What’s the Image Base Address?
All files have a field in the header called “Image Base Address” which is the location in the memory the PE File would prefer to load. Sometime this area is taken and the file is loaded at a different memory address. To solve that we use Relative addresses (RVA).
What is the IAT?
The Windows Loader builds a Import Address Table (IAT) for each DLL loaded by the process containing those functions.
If you look at this table in file on disk it will simply list the functions used by the program. However when the PE File is loaded into memory this table is updated to point to the actual DLL code in memory.
What are the main sections of the PE File?
What is important in the MZ header?
What is important in the PE header?
What is important in the PE header/Image_File_Header?
What is important in the PE header/Image_Optional_Header?
What is important in the PE header/Image_Section_Header (Sections Table)?
Section Header contains one data structure for each section in the file:
Name a few tools to analyse PE files?
What is the OEP?
The Original Entry Point is the field in the Optional Header that shows the RVA of the memory address for the first piece of code to be executed.