LIEF: Library to Instrument Executable Formats Table of Contents - - PowerPoint PPT Presentation

lief library to instrument executable formats table of
SMART_READER_LITE
LIVE PREVIEW

LIEF: Library to Instrument Executable Formats Table of Contents - - PowerPoint PPT Presentation

Romain Thomas - rthomas@quarkslab.com LIEF: Library to Instrument Executable Formats Table of Contents Introduction Architecture Demo Conclusion About Romain Thomas - Security engineer at Quarkslab Working on obfuscation and software


slide-1
SLIDE 1

Romain Thomas - rthomas@quarkslab.com

LIEF: Library to Instrument Executable Formats

slide-2
SLIDE 2

Table of Contents

Introduction Architecture Demo Conclusion

slide-3
SLIDE 3

About

◮ Romain Thomas - Security engineer at Quarkslab ◮ Working on obfuscation and software protection, reverse engineering ◮ Contributor to the Triton project

(https://triton.quarkslab.com)

slide-4
SLIDE 4

Layers of information

pefile, readelf, otool, LLVM . . . LLVM, IDA, diStorm . . . Intel PIN, Qemu, gdb, Triton . . .

Tools Format

ELF, PE, Mach-O, COFF, XCOFF...

Content

Disassembler: x86, ARM, MIPS, AArch64 ...

Behavior

DBI, emulator, sandbox, debugger ...

Figure: Layer of information in an executable

slide-5
SLIDE 5

Howto?

◮ Get assembly code? ◮ Get symbols? ◮ Get imported functions?

slide-6
SLIDE 6

Executable File Formats in a Nutshell

slide-7
SLIDE 7

Executable File Formats in a Nutshell

Executable file format gives information such as:

◮ First instruction address to execute. ◮ Libraries used ◮ Target architecture (x86, ARM . . . )

slide-8
SLIDE 8

Executable File Formats in a Nutshell

The three mainstream formats:

◮ ELF: Linux, Android . . . ◮ PE: Windows ◮ Mach-O: OS-X, iOS, . . .

slide-9
SLIDE 9

Modification

Format modifications can be a starting point to:

◮ Packing ◮ Watermarking ◮ Hooking: Perform interposition on functions ◮ Persistent code injection ◮ Malware analysis (static unpacking . . . )

slide-10
SLIDE 10

Purpose of LIEF

◮ Provide a cross-platform library to parse ELF, PE and Mach-O

formats

◮ Abstract common features from the different formats (section,

header, entry point, symbols . . . )

◮ Enable format modifications ◮ Provide an API for different languages (Python, C++, C . . . )

slide-11
SLIDE 11

Howto? (answers)

Get assembly code?

slide-12
SLIDE 12

Howto? (answers)

Get assembly code?

1 import lief 2 binary = lief.parse("C:\\ Windows \\ explorer.exe") # PE 3 asm = binary. get_section (".text")

slide-13
SLIDE 13

Howto? (answers)

Get symbols?

slide-14
SLIDE 14

Howto? (answers)

Get symbols?

1 import lief 2 binary = lief.parse("/bin/ls") # ELF 3 for symbol in binary.symbols: 4 print(symbols)

slide-15
SLIDE 15

Howto? (answers)

Get imported functions?

slide-16
SLIDE 16

Howto? (answers)

Get imported functions?

1 import lief 2 binary = lief.parse("/usr/lib/libc ++ abi.dylib") # Mach -O 3 for function in

  • binary. imported_functions :

4 print(function)

slide-17
SLIDE 17

Table of Contents

Introduction Architecture Demo Conclusion

slide-18
SLIDE 18

Overview

Abstract layer C++

LIEF

Python / C ELF ELF::Binary ELF::Parser ELF::Builder PE PE::Binary PE::Parser PE::Builder Mach-O MACHO::Binary MACHO::Parser MACHO::Builder

Figure: Global architecture

slide-19
SLIDE 19

Modification process

LIEF object LIEF object /bin/ls (modified) /bin/ls Modification Parser Builder

Header

Sections

.text .data

Segments

LOAD DYNAMIC Header

Sections

.text .data .new section

Segments

LOAD DYNAMIC

slide-20
SLIDE 20

Table of Contents

Introduction Architecture Demo Conclusion

slide-21
SLIDE 21

Demo!

slide-22
SLIDE 22

Table of Contents

Introduction Architecture Demo Conclusion

slide-23
SLIDE 23

Roadmap

Some ideas for next versions:

◮ Graphical User Interface (Work in progress) ◮ Handle the OAT format (subset of the ELF format) ◮ PE API to hook functions ◮ PE/Mach-O fuzzer ◮ Handle the Dwarf format

slide-24
SLIDE 24

◮ Source code is available on GitHub:

https://github.com/lief-project (Apache 2.0 license)

◮ Website: https://lief.quarkslab.com

slide-25
SLIDE 25

◮ Source code is available on GitHub:

https://github.com/lief-project (Apache 2.0 license)

◮ Website: https://lief.quarkslab.com

Missing feature or bug?

slide-26
SLIDE 26

◮ Source code is available on GitHub:

https://github.com/lief-project (Apache 2.0 license)

◮ Website: https://lief.quarkslab.com

Missing feature or bug? lief@quarkslab.com

  • r

Open an issue / pull request

slide-27
SLIDE 27

Thank you!