+ All Categories
Home > Business > Exploring the Portable Executable format

Exploring the Portable Executable format

Date post: 15-Jan-2015
Category:
Upload: ange-albertini
View: 1,062 times
Download: 8 times
Share this document with a friend
Description:
a 44CON 2013 workshop
Popular Tags:
58
Exploring the Portable Executable format London, England Ange Albertini 2013/09/13
Transcript
Page 1: Exploring the Portable Executable format

Exploringthe Portable Executable

format

London, EnglandAnge Albertini 2013/09/13

Page 2: Exploring the Portable Executable format

Workshop package (PoCs+docs)

http://www.xchg.info/corkami/workshop.zip

Recommended PE viewer:http://icerbero.com/peinsider

Page 3: Exploring the Portable Executable format
Page 4: Exploring the Portable Executable format
Page 5: Exploring the Portable Executable format
Page 6: Exploring the Portable Executable format
Page 7: Exploring the Portable Executable format
Page 8: Exploring the Portable Executable format
Page 9: Exploring the Portable Executable format
Page 10: Exploring the Portable Executable format
Page 11: Exploring the Portable Executable format
Page 12: Exploring the Portable Executable format
Page 13: Exploring the Portable Executable format
Page 14: Exploring the Portable Executable format
Page 15: Exploring the Portable Executable format
Page 16: Exploring the Portable Executable format

a handmade PEsimple.exe

a first real exampleworking minimal

Page 17: Exploring the Portable Executable format
Page 18: Exploring the Portable Executable format
Page 19: Exploring the Portable Executable format
Page 20: Exploring the Portable Executable format

detailedwalkthrough

Page 21: Exploring the Portable Executable format
Page 22: Exploring the Portable Executable format

DOS headerunused in PE mode

Page 23: Exploring the Portable Executable format
Page 24: Exploring the Portable Executable format

PE headerPE signature

Page 25: Exploring the Portable Executable format
Page 26: Exploring the Portable Executable format

Optional HeaderNOT optional in executables

Page 27: Exploring the Portable Executable format
Page 28: Exploring the Portable Executable format

DataDirectoriesend of OptionalHeader16 (max) * [RVA, Size]

each entry interpreted differently

Page 29: Exploring the Portable Executable format
Page 30: Exploring the Portable Executable format

Sectionsmemory mapping

Page 31: Exploring the Portable Executable format
Page 32: Exploring the Portable Executable format
Page 33: Exploring the Portable Executable format

Importsstandard loader mechanism

NOT requiredload DLL, locate APIs

Page 34: Exploring the Portable Executable format
Page 35: Exploring the Portable Executable format

compiled PEcompiled.execloser to reality

extra non-critical structure

Page 36: Exploring the Portable Executable format
Page 37: Exploring the Portable Executable format
Page 38: Exploring the Portable Executable format
Page 39: Exploring the Portable Executable format

DLLexports

relocations

Page 40: Exploring the Portable Executable format
Page 41: Exploring the Portable Executable format
Page 42: Exploring the Portable Executable format

driversubsystem, checksum

low alignments mappingdifferent imports

Page 43: Exploring the Portable Executable format
Page 44: Exploring the Portable Executable format

resourcesstructure

version, manifest/icon, APIs

Page 45: Exploring the Portable Executable format
Page 46: Exploring the Portable Executable format
Page 47: Exploring the Portable Executable format

Thread Local Storagecallback list

before EntryPoint & after ExitProcess

Page 48: Exploring the Portable Executable format
Page 49: Exploring the Portable Executable format

.Netdifferent and integrated binary

2nd loader

Page 50: Exploring the Portable Executable format
Page 51: Exploring the Portable Executable format

what about 64b?

very few changes● 2 magic constants● a few elements become QWord

○ ImageBase, Imports thunks, callbacks● Exceptions have their own DataDirectory

○ no need for LoadConfig (SafeSEH)

Page 52: Exploring the Portable Executable format

and ARM

● a different magic constant● still 16b DOS Stub !● nothing special, PE wise

○ the beauty of ‘Portability’

Page 53: Exploring the Portable Executable format

trivial

Page 54: Exploring the Portable Executable format
Page 55: Exploring the Portable Executable format
Page 56: Exploring the Portable Executable format
Page 57: Exploring the Portable Executable format
Page 58: Exploring the Portable Executable format

Recommended