background preloader

ELF generic

Facebook Twitter

ELF Format. Rambles around computer science. Diverting trains of thought, wasting precious time ELF introspection, robustly and portably I often find myself writing code that does introspection at the ELF level.

Rambles around computer science

This is for things like looking up symbols, walking the link map, figuring out which shared object a particular memory address belongs to, which memory regions are executable, and so on. These are fairly common things to want to do in ptrace()- or LD_PRELOAD-based tools, or binary interpreter-like (Valgrind-style) ones. This post is about how to do these things robustly from within a process, where “robustly” brings some particular restrictions.

What introspection? What does our address space look like? This picture is a refinement of the usual OS textbook diagram of a Unix address space. What's ELF? But actually, that omits some of the most interesting stuff! Dynamic symbols, program headers and the miscellaneous dynamic linking metadata are what we're interested in introspecting on. What's “robustly”? The link map. Learning Linux Binary Analysis PDF Download Free. Documentation/Applicatif : ELF Injection [Root Me : plateforme d'apprentissage dédiée au Hacking et à la Sécurité de l'Information] ELF Shared Library Injection Forensics - Backtrace I/O. At Backtrace we built and are continually building security and forensics features into our product that rely on understanding the structural nuances of ELF binary internals, and process memory infection techniques.

ELF Shared Library Injection Forensics - Backtrace I/O

This article outlines some of the core concepts that are being applied in our technology today. For well over a decade attackers have been installing memory resident backdoors, rootkits, and parasites of various kinds into userland processes. The goal is to inject executable code into an existing process, to alter its functionality, while remaining stealth and keeping the attackers activity surreptitious. The most commonly used approach for inserting executable code into an existing process is a technique that has been termed shared library injection. The 101 of ELF Binaries on Linux: Understanding and Analysis - Linux Audit. An extensive dive into ELF files: for security incident response, development, and better understanding We often don’t realize the craftsmanship of others, as we conceive them as normal.

The 101 of ELF Binaries on Linux: Understanding and Analysis - Linux Audit

One of these things is the usage of common tools, like ps and ls. Even though the commands might be perceived as simple, under the hood there is more to it: ELF binaries. Modern dynamic linking infrastructure for PLT. Given that Unix won, I think it's interesting that dynamic languages make very little use of the dynamic linking and loading infrastructure provided by modern free Unixes such as Linux and the BSDs.

Modern dynamic linking infrastructure for PLT

Most dynamic PLs opt to implement "dynamism" (i.e. redefining stuff, loading code at runtime) with application-specific data structures (e.g. Lisp: red-black trees for uniquifying symbols, function pointers and indirect function calls), and they do so solely at runtime (mostly using interpreters and JITs, although Scheme, one of the most advanced dynamic languages, is increasingly illuminating the possibilities of static, independent compilation of dynamic programs). (Metaprogramming at runtime is perilous, as it is easy to mix up phase distinctions, something we can expect newer dynamic programming languages to discover in a decade (of course we don't know which decade.))

Link-time is mostly ignored. Rambles around computer science. The Original Magazine of the Linux Community. ELF File Format. Executable and Linking Format (ELF) is the object format used in UNIX-like operating systems.

ELF File Format

This post introduces the ELF file format in the big picture of Linux. We will use the readelf tool from Binutils to view the content of the ELF file of a C program as below. Save the code in a file named test.c, and then collect/make the source code into a *.o file and an executable with the commands below. The first command should produce a file named test.o, and the second command will output a file test. File Types Below are the four main types of ELF files Relocatable files: created by the collector/maker and put together/group together, usually ends with .o extension, and to be processed by the linker to produce the executable or library files.

The Teensy Files. This page is a complete guide to everything I've written about creating teensy ELF executable for Linux.

The Teensy Files

Take a look at your /bin directory: how big is the smallest ELF executable in there? Try writing the smallest hello-world program you can. Can you get it under, say, 1K? This is precisely what I set out to do one day, and I ended up with a minor obsession over creating the smallest possible executables. How does one go about making a Linux ELF executable small? The Essays. The Art Of ELF: Analysis and Exploitations. New systems make attackers life hard and common exploitation techniques get harder to reproduce.

The Art Of ELF: Analysis and Exploitations

The purpose of this article is to be very general on mitigation techniques and to cover attacks on x32 as a reference to x64 architectures to stick with the new constraints of today. Here, you will find the first step which is an ELF format file analysis. After that we will speak about the protections and ways to bypass them. To finish, we will introduce the x86_64 that makes things more difficult for nowadays exploitations. ELF Tutorial. This tutorial describes the steps to loading ELF files targeting the i386 (32-bit architecture, little-endian byte order).

ELF Tutorial

All code in the tutorial is in the form of C compatible C++ and strives to teach by example, by using simplified (and sometimes naive), neat, and functional snippets of code. It may later be expanded to cover other types of ELF files, or formats targeting other architectures or machine types. ELF Data Types # include <stdint.h> typedef uint16_t Elf32_Half; // Unsigned half inttypedef uint32_t Elf32_Off; // Unsigned offsettypedef uint32_t Elf32_Addr; // Unsigned addresstypedef uint32_t Elf32_Word; // Unsigned inttypedef int32_t Elf32_Sword; // Signed int. Hacking Your ELF For Fun And Profit. Have you ever wondered how the Linux kernel module_init and *_initcall(e.g. subsys_initcall) macros work?

Hacking Your ELF For Fun And Profit

Even after a quick glance at their definition things might not be exactly clear: The key to understanding what’s going on here is understanding that __attribute__((__section__(...))) business. Normally, variables are placed in sections like data or bss. But with gcc, you can use the section attribute to manually specify which section of the ELF (assuming you’re compiling to ELF) you’d like that variable to live in. Reversing tutorials - level 2 - Le format ELF - Hackademics : Forum de hacking – hackers white hat – cours de securite informatique. The 101 of ELF Binaries on Linux: Understanding and Analysis - Linux Audit.