lief library to instrument executable formats table of
play

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

RMLL 2017 Romain Thomas - rthomas@quarkslab.com LIEF: Library to Instrument Executable Formats Table of Contents Introduction Project Overview Demo Conclusion About Romain Thomas (rthomas@quarkslab.com) - Security engineer Working on


  1. RMLL 2017 Romain Thomas - rthomas@quarkslab.com LIEF: Library to Instrument Executable Formats

  2. Table of Contents Introduction Project Overview Demo Conclusion

  3. About � Romain Thomas (rthomas@quarkslab.com) - Security engineer � Working on obfuscation, software protection and reverse engineering � Contributor to the Triton project, a dynamic binary analysis framework.

  4. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  5. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  6. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  7. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  8. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  9. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  10. Layers of information Tools Format pefile, readelf, otool, LLVM . . . ELF , PE , Mach-O , COFF , XCOFF ... Content LLVM, IDA, capstone . . . x86 , ARM , MIPS , AArch64 . . . Behavior Frida, Intel Pin, Triton, Qemu . . . DBI, emulator, sandbox, debugger . . .

  11. Howto? � Get assembly code? � Get symbols? � Get imported functions? � Get entry point?

  12. Executable Formats What is an executable format ?

  13. Executable File Formats in a Nutshell

  14. Executable File Formats in a Nutshell Executable file format gives information such as: � First instruction address to execute

  15. Executable File Formats in a Nutshell Executable file format gives information such as: � First instruction address to execute � Libraries used

  16. Executable File Formats in a Nutshell Executable file format gives information such as: � First instruction address to execute � Libraries used � Target architecture ( x86 , ARM . . . )

  17. Executable File Formats in a Nutshell The three mainstream formats: � ELF : Linux, Android . . . � PE : Windows � Mach-O : OS-X, iOS, . . .

  18. Purpose of LIEF � Provide a cross-platform library to parse ELF, PE and Mach-O formats

  19. 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 . . . )

  20. 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

  21. 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 . . . )

  22. 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 . . . ) Provide an all-in-one library to deal with executable formats

  23. Table of Contents Introduction Project Overview Architecture Abstract Layer Tests and CI Demo Conclusion

  24. Architecture

  25. Architecture LIEF ELF PE Mach-O Binary Parser Builder Binary Parser Builder Binary Parser Builder Abstract layer C++ Python / C

  26. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  27. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  28. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  29. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  30. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  31. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  32. Architecture Format Binary Parser Builder Files Files Files Format modeling � ELF/{Binary Header Section ...}.cpp � ELF/Parser.{tcc,cpp} � ELF/Builder.{tcc,cpp} � Header Parse the format and create � PE/{Binary DosHeader Section ...}.cpp � PE/Parser.{tcc,cpp} � PE/Builder.{tcc,cpp} Take the Binary object � Sections a Binary object and reconstruct an executable � MachO/{Binary Header LoadCommand ...}.cpp � MachO/BinaryParser.{tcc,cpp} � MachO/Builder.{tcc,cpp} � . . .

  33. Abstract Layer

  34. Abstract Layer ELF Entry point Sections Symbols Libraries Relocations PE Mach-O

  35. What is abstracted - Binary Binary level � Imported functions � Exported functions � Patch value(s) from a given address � Retrieve value(s) from a given address

  36. What is abstracted - Header Header: � Type � Entry point � Architecture � Modes � Endianness

  37. What is abstracted - Header Header: � Type � LIEF::OBJECT_TYPES::TYPE_EXECUTABLE � LIEF::OBJECT_TYPES::TYPE_LIBRARY � . . . � Entry point � Architecture � Modes � Endianness

  38. What is abstracted - Header Header: � Type � Entry point � Architecture � LIEF::ARCHITECTURES::ARCH_ARM � LIEF::ARCHITECTURES::ARCH_X86 � LIEF::ARCHITECTURES::ARCH_ARM64 � . . . � Modes � Endianness

  39. What is abstracted - Header Header: � Type � Entry point � Architecture � Modes � LIEF::MODES::MODE_64 � LIEF::MODES::MODE_THUMB � LIEF::MODES::MODE_V9 � . . . � Endianness

  40. What is abstracted - Header Header: � Type � Entry point � Architecture � Modes � Endianness � LIEF::ENDIANNESS::ENDIAN_BIG � LIEF::ENDIANNESS::ENDIAN_LITTLE

  41. What is abstracted - Section Section: � Name � Offset � Size � Virtual Address � Raw content � Entropy

  42. What is abstracted - Symbol Symbol: � Name

  43. Architecture

Recommend


More recommend