Académique Documents
Professionnel Documents
Culture Documents
Ange Albertini
101
ortable
corkami.com
xecutable
Dissected PE
Hexadecimal dump
ASCII dump
MZ..............
constant signature
offset of the PE Header
PE..L...........
....a...
Signature
Machine
NumberOfSections
SizeOfOptionalHeader
Characteristics
'PE', 0, 0
0x14c [intel 386]
3
0xe0
0x102 [32b EXE]
constant signature
processor: ARM/MIPS/Intel/...
number of sections 2
relative offset of the section table 2
EXE/DLL/...
00
00
00
00
00
00
........
................
......@.........
................
.@..............
................
........
Magic
AddressOfEntryPoint
ImageBase
SectionAlignment
FileAlignment
MajorSubsystemVersion
SizeOfImage
SizeOfHeaders
Subsystem
NumberOfRvaAndSizes
0x10b [32b]
0x1000
0x400000
0x1000
0x200
4 [NT 4 or later]
0x4000
0x200
2 [GUI]
16
32 bits/64 bits
where execution starts 5
address where the file should be mapped in memory
3
where sections should start in memory 2
where sections should start on file 2
required version of Windows
total memory space required
total size of the headers 3
driver/graphical/command line/...
number of data directories 4
...00 00 00 00-00 00 00 00
00 20 00 00-00 00 00 00-00 00 00 00-00 00 00 00
00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00
........
................
................
ImportsVA
0x2000
Offset:0x40
Offset:0x58
DOS header
MZ..............
shows
it's00-40
a binary
00 00 00 00-00 00 00 00-00
00 00
00 00 00
............@...
PE header
0000
4D 5A 00 00-00 00 00 00-00 00 00 00-00 00 00 00
MZ..............
0030
00
50
00
00
00
00
00
00
00
00
00
00
45
00
00
00
00
40
00
00
20
00
00
00
00
00
00
00
00
00
00
00
00
00-00
00-4C
00-E0
00-00
00-00
00-00
00-00
00-00
00-10
00-00
00-00
00
01
00
00
00
00
02
00
00
00
00
00
03
02
00
40
00
00
00
00
00
00
00-00
00-00
01-0B
00-00
00-00
00-04
00-00
00-00
00-00
00-00
00-00
00
00
01
10
10
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00-40
00-00
00-00
00-00
00-00
00-00
00-02
00-00
00-00
00-00
00-00
00
00
00
00
02
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
............@...
PE..L...........
....a...........
................
......@.........
................
.@..............
................
................
................
................
0130
00
00
00
2E
00
00
00
00
00
00
10
00
72
02
00
10
00
00
00
00
00
64
00
00
00
00
00
00-00
00-00
00-00
61-74
00-00
00-40
00-00
00-00
00-00
00
10
00
61
04
00
30
00
00
00
00
00
00
00
00
00
00
00
00-2E
00-00
00-00
00-00
00-00
40-2E
00-00
00-00
00-00
74
02
00
10
00
64
02
00
00
65
00
00
00
00
61
00
00
00
78-74
00-00
00-20
00-00
00-00
74-61
00-00
00-40
00-00
00
02
00
20
00
00
06
00
00
00
00
00
00
00
00
00
00
00
00
00
60
00
00
00
00
C0
00
.........text...
................
...............`
.rdata..........
................
....@..@.data...
.....0..........
............@..+
................
0200
6A 00 68 00-30 40 00 68-17 30 40 00-6A 00 FF 15
70 20 40 00-6A 00 FF 15-68 20 40 00-00 00 00 00
00 00 00 00-00 00 00 00-00 00 00 00-00 00 00 00
j.h.0@.h.0@.j. .
p.@.j. .h.@.....
................
0400
3C
68
85
00
00
69
61
5A
2E
00
00
00
00
00
78
73
00
32
00
00
<...........x...
h...D...........
...p...........
............L...
....Z.........Ex
itProcess...Mess
ageBoxA.L.......
Z.......kernel32
.dll.user32.dll.
................
0600
61 20 73 69-6D 70 6C 65-20 50 45 20-65 78 65 63
75 74 61 62-6C 65 00 48-65 6C 6C 6F-20 77 6F 72
6C 64 21 00-00 00 00 00-00 00 00 00-00 00 00 00
a.simple.PE.exec
utable.Hello.wor
ld!.............
simple.exe
00
00
00
00
00
65
41
00
73
00
00-00
00-00
00-00
00-00
00-00
73-73
00-4C
00-6B
65-72
00-00
00
00
00
00
00
00
20
65
33
00
00
00
00
00
00
00
00
72
32
00
00-78
00-00
00-00
00-4C
00-00
00-4D
00-00
6E-65
2E-64
00-00
20
00
00
20
00
65
00
6C
6C
00
00
00
00
00
45
73
00
33
6C
00
00
00
00
00
00
00
00
00
00
00
00
00-00
00-4C
00-E0
00-00
00-00
00-00
00-00
00-00
00-10
00-00
00-00
00
01
00
00
00
00
02
00
00
00
00
00
03
02
00
40
00
00
00
00
00
00
00-00
00-00
01-0B
00-00
00-00
00-04
00-00
00-00
00-00
00-00
00-00
00
00
01
10
10
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00-40
00-00
00-00
00-00
00-00
00-00
00-02
00-00
00-00
00-00
00-00
00
00
00
00
02
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
00
10
00
72
02
00
10
00
00
header
00
60
00
00
00
00
C0
00
................
...............`
.rdata..........
................
....@..@.data...
.....0..........
............@..+
................
j.h.0@.h.0@.j. .
p.@.j. .h.@.....
................
3C
68
85
00
00
69
61
5A
2E
00
00
00
00
00
78
73
00
32
00
00
<...........x...
h...D...........
...p...........
............L...
....Z.........Ex
itProcess...Mess
ageBoxA.L.......
Z.......kernel32
.dll.user32.dll.
................
a.simple.PE.exec
utable.Hello.wor
ld!.............
20
20
20
00
00
74
67
20
64
00
00
00
64
00
00
00
00
00
00
00
00
00
00
50
65
00
6C
00
00-00
00-00
61-74
00-00
00-40
00-00
00-00
00-00
00-00
00-44
00-70
00-00
00-5A
72-6F
42-6F
00-00
6C-00
00-00
10
00
61
04
00
30
00
00
00
20
20
00
20
63
78
00
75
00
00
00
00
00
00
00
00
00
00
00
00
00
00
65
41
00
73
00
00-00
00-00
00-00
00-00
40-2E
00-00
00-00
00-00
00-00
00-00
00-00
00-00
00-00
73-73
00-4C
00-6B
65-72
00-00
02
00
10
00
64
02
00
00
00
00
00
00
00
00
20
65
33
00
00
00
00
00
61
00
00
00
00
00
00
00
00
00
00
72
32
00
00-00
00-20
00-00
00-00
74-61
00-00
00-40
00-00
00-78
00-00
00-00
00-4C
00-00
00-4D
00-00
6E-65
2E-64
00-00
02
00
20
00
00
06
00
00
20
00
00
20
00
65
00
6C
6C
00
00
00
00
00
00
00
00
00
00
00
00
00
45
73
00
33
6C
00
00
00
00
00
00
00
00-00
00-00
00-00
00-00
00-00
00-10
00
00
00
02
00
00
00
40
00
00
00
00
01-0B 01 00 00-00 00 00
00-00 10 00 00-00 00 00
00-00 10 00 00-00 02 00
00-04 00 00 00-00 00 00
00-00
00 00 information
00-02 00 00
executable
00-00 00 00 00-00 00 00
00
00
00
00
00
00
00
.........
................
......@.........
................
.@..............
................
................
00
00
2E
00
00
00
00
00
10
00
72
02
00
10
00
00
00
00
64
00
00
00
00
00
2E 74 65 78-74 00 00 00
.text...
00-00 10 00 00-00 02 00 00-00 02 00 00 ................
00-00 00 00 00-00 00 00 00-20 00 00 60 ...............`
61-74 61 00 00-00 10 00 00-00 20 00 00 .rdata..........
00-00 04 00 00-00 00 00 00-00 00 00 00 ................
how the
loaded
memory
00-40 defines
00 00 40-2E
64file
61 is74-61
00in00
00 ....@..@.data...
00-00 30 00 00-00 02 00 00-00 06 00 00 .....0..........
00-00 00 00 00-00 00 00 00-40 00 00 C0 ............@..+
00-00 00 00 00-00 00 00 00-00 00 00 00 ................
sections table
code
sections
00
00
00
00
00
00
00
00
00
40
00
00
00
00
00
00
00
00
00-00
00-00
00-00
00-00
00-00
00-10
00
00
00
02
00
00
00
40
00
00
00
00
...0B
00-00
00-00
00-04
00-00
00-00
00...
01
10
10
00
00
00
00
00
00
00
00
00
00-00
00-00
00-00
00-00
00-02
00-00
00
00
02
00
00
00
00
00
00
00
00
00
............@...
optional header
data directories
technical
the
executable
00 00 00-00 00 details
00 00-2E 74about
65 78-74 00
00 00
.........text...
00
00
00
2E
00
00
00
00
00
00
00
00
40
00
00
00 00 00 00-00 00 00 00 ................
00 20 00 00-00 00 00 00-00 00 00 00-00 00 00 00 ................
pointers
to 00-00
extra structures
(exports,
00 00 00 00-00
00 00
00 00 00-00
00 00 imports,...)
00 ................
Offset:0x138
00
00
2E
00
00
00
00
10
00
72
02
00
10
00
00
00
64
00
00
00
00
00-00
00-00
61-74
00-00
00-40
00-00
00-00
10
00
61
04
00
30
00
00
00
00
00
00
00
00
2E
00-00
00-00
00-00
00-00
40-2E
00-00
00-00
74
02
00
10
00
64
02
00
65
00
00
00
00
61
00
00
78-74
00-00
00-20
00-00
00-00
74-61
00-00
00-40
00
02
00
20
00
00
06
00
00
00
00
00
00
00
00
00
00
00
60
00
00
00
00
C0
.text...
................
...............`
.rdata..........
................
....@..@.data...
.....0..........
............@..+
20
20
20
00
00
74
67
20
64
00
00
00
00
00
00
50
65
00
6C
00
j.h.0@.h.0@.j. .
p.@.j. .h.@.
imports
data
a.simple.PE.exec
utable.Hello.wor
ld!.............
Sections table
*
RVA*
physical size
physical offset
VirtualSize VirtualAddress SizeOfRawData PointerToRawData Characteristics
0x1000
0x1000
0x200
0x200
CODE EXECUTE READ
0x1000
0x2000
0x200
0x400
INITIALIZED READ
0x1000
0x3000
0x200
0x600
DATA READ WRITE
Name
.text
.rdata
.data
For each section, a SizeofRawData sized block is read from the file at PointerToRawData offset.
It will be loaded in memory at address ImageBase + VirtualAddress in a VirtualSize sized block, with specific characteristics.
push
push
push
push
call
push
call
Equivalent C code
0
0x403000
0x403017
0
[0x402070]
0
[0x402068]
Consequences
Imports structures
Offset:0x400/RVA:0x402000
3C
68
85
00
00
69
61
5A
2E
20
20
20
00
00
74
67
20
64
00
00
00
00
00
50
65
00
6C
00-00
00-44
00-70
00-00
00-5A
72-6F
42-6F
00-00
6C-00
00
20
20
00
20
63
78
00
75
00
00
00
00
00
65
41
00
73
00-00
00-00
00-00
00-00
00-00
73-73
00-4C
00-6B
65-72
00
00
00
00
00
00
20
65
33
00
00
00
00
00
00
00
72
32
00-78
00-00
00-00
00-4C
00-00
00-4D
00-00
6E-65
2E-64
20
00
00
20
00
65
00
6C
6C
00
00
00
00
45
73
00
33
6C
00
00
00
00
78
73
00
32
00
<...........x...
h...D...........
...p...........
............L...
....Z.........Ex
itProcess...Mess
ageBoxA.L.......
Z.......kernel32
.dll.user32.dll.
descriptors
0x203c
0x2078
0x204c, 0
kernel32.dll
0x2044
0x205a, 0
a.simple.PE.exec
utable.Hello.wor
ld!.
IAT
INT
after loading,
0x402068 will point to kernel32.dlls ExitProcess
0x402070 will point to user32.dlls MessageBoxA
Hint,Name
user32.dll
0,MessageBoxA
0x205a, 0
0 0 0 0 0
Offset:0x600/RVA:0x403000
Hint,Name
0x204c, 0
0x2085
INT
0,ExitProcess
0x2068
0x2070
IAT
Strings
a simple PE executable\0
Hello world!\0
This is the whole file, however, most PE files contain more elements. Explanations are simplified, for conciseness.
3 Mapping
PointertoRawData
Section 1
PointertoRawData
Section 2
PointertoRawData
Relative
Virtual Address
0x200
0x400200
0x400
0x401000
0x600
0x800
SizeOfHeaders
VirtualAddress
0x402000
IAT
Section 1
VirtualAddress
0x403000
0x404000
ImageBase
Section 2
VirtualAddress
Section 3
Hint,"API name"
IAT
library.dll
SizeOfImage
Section 3
0x400000
SizeOf
Headers
0x0
VirtualSize
VirtualSize
VirtualSize
2 Sections table
Offset
SizeOf
Headers
5 Execution
4 Imports
SizeOf
RawData
SizeOf
RawData
1 Headers
Notes
Loading process
API_Address:
RVA
x86 assembly
j.h.0@.h.0@.j. .
p.@.j. .h.@.....
................
Offset:0x200/RVA:0x401000
3C
68
85
00
00
69
61
5A
2E
00
SizeOf
RawData
00
20
20
00
20
63
78
00
75
00
............@...
PE..L...........
....a...........
................
......@.........
................
.@..............
................
................
................
................
00
45
00
00
00
00
40
00
00
20
00
Section Alignment
00-00
00-44
00-70
00-00
00-5A
72-6F
42-6F
00-00
6C-00
00-00
00
50
00
00
00
00
00
00
00
00
00
File
Alignment
00
00
00
00
00
50
65
00
6C
00
MZ..............
NumberOfSections
20
20
20
00
00
74
67
20
64
00
00
00
00
00
00
00
PE..L...........
....a..
Explanation
'MZ'
0x40
Values
e_magic
e_lfanew
Offset:0x30
SHA-1 b7af4cb51ce38e43e030656eb2698fab408cf9cb
download @ pe101.corkami.com
Fields