ERESI(1)

πŸ“¦ version 0.83-a3-phoenix, in nixos 26.05, nixpkgs unstable

ERESI(1) β€” The ERESI Reverse Engineering Software Interface πŸ’…

Bestie, this is the ERESI(1) manual page, aka the User commands page, and it's lowkey a whole reverse-engineering universe. Part 1 is right here, so grab your iced coffee. πŸ“βœ¨

πŸ’– NAME πŸ’–

ERESI β€” The ERESI Reverse Engineering Software Interface. That's the whole name, iconic and to the point. πŸ‘‘

🌸 SYNOPSIS 🌸

elfsh [OPTIONS]

etrace [OPTIONS]

e2dbg programtodebug

kernsh

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so ERESI β€” The ERESI Reverse Engineering Software Interface β€” is a unified reverse engineering framework for UNIX operating systems based on the Executable & Linking Format (ELF). We're talking Linux, BSD, Solaris, IRIX, and BeOS, bestie. 🌈

It has a command line interface that makes it useful remotely, and it can generate graph images from code analysis on demand. It also has a real dedicated reverse engineering language that makes it scriptable and adaptable to the precise needs of the users. No cap, that's a big deal. πŸ’…

ERESI contains more than 10 innovative and exclusive features that turn it into an environment of choice for the instrumentation, analysis, debugging, tracing, hooking, or simply integrity checking and events logging of binary programs. It's giving main character energy in a terminal. πŸ‘‘

ERESI is composed of ELFsh (the ELF shell), E2dbg (The Embedded ELF debugger), and Etrace (The Embedded ELF tracer). This documentation applies on all of the components. 🫢

✨ OPTIONS ✨

The ELF shell (part of ERESI) can take the following command line parameters:

  • -f β€” input file
  • -w β€” output file
Note that the command line is slightly different for E2dbg and Etrace, which do NOT take those parameters. πŸ’€

πŸŽ€ COMMANDS πŸŽ€

E2dbg and Etrace have to be executed using a unique command line parameter (the program file to be debugged or traced). The following primitives can be used interactively in E2dbg, Etrace, and ELFsh, but also on command line when preceded by a - (ELFsh only) at the UNIX shell command prompt. Periodt. πŸ’…

πŸ’œ General purpose commands πŸ’œ

Here's the roster, exactly as listed:

cat edit exec exit help info list load lscripts nocolor profile quit sdir setcolor switch unload workspace

And here's the tea:

  • cat β€” print the file argument
  • edit β€” Edit the file given in parameter
  • exec β€” Fork and execute parameter command (with args)
  • help β€” Print the help screen
  • info β€” Print the extra details help screen
  • list β€” List the loaded files and their ID
  • load filename β€” Load input file filename
  • lscripts β€” List macro commands
  • nocolor β€” Toggle color status
  • profile (enable | disable) (traces | warns | alloc | debug | all) β€” Change the ELFsh profiling behavior.

Traces profiling print all the internal function calls done by the framework. Warning profiling prints all the (fatal and non-fatal) warnings reported by the internal API : it's very useful for tracking bugs and it should be used when reporting issues on the bugtracking system. Allocation and debug profiling are experimental and should only be used by experienced ERESI developers. ✨

  • quit β€” Quit the shell without saving
  • sdir β€” Change the script directory. This allows to make precise the location of complete ERESI library and bind script files on command names in the shell.
  • setcolor β€” Associates data types to colors.
    • setcolor type [bg,fg] color
    • setcolor type [underline,bold] (1=on,0=off)

Available types:

address, number, string, endstring, warnstring typestring, fieldstring, instr, pspecial, psname pspecial, pversion, prelease, pedition

Available colors:

black red green yellow blue magenta cyan white
  • switch (filename | fileID) β€” Change the current file to work on to filename or fileID
  • unload (filename | fileID) β€” Unload file filename or fileID without saving
  • workspace [wname] β€” When executed without parameter, this command list existing workspaces. When given an existing workspace name, this command switch to that workspace. If given a non-existing workspace name, this command creates a new workspace and switch to it.
  • tables [regex] β€” If given without parameter, list all the existing hash tables in the ERESI framework. If given with a parameter, print the content of hash tables whose name match the regular expression.
  • vectors [vname[:idx1:...:idxN]] [symbol|addr] β€” If given without parameter, list all the existing vectors in the ERESI framework. If given with a parameter, print the content of this vector. If given one long parameter, print the content of a given vector entry. If given 2 parameters, modify the vector entry with a user provided address or resolved symbol address.

🌈 Ondisk/Memory ELF commands 🌈

Those commands work in all components of the ERESI framework (ELFsh, E2dbg, and Etrace). The roster is:

add cmp ctors disasm div dtors dyn dynsym elf findrel get got hexa interp mod mul notes pht print redir rel reladd set sht sub write test

And here's the breakdown, bestie:

  • add β€” Add the 2 parameters and put the result in variable $_
  • cmp β€” Compare 2 parameters. The difference is put in variable $_
  • ct ctors [Regex] β€” Print .ctors section entries matching Regex
  • D disasm [Regex] β€” Disassemble matching binary objects in current file
disasm parameter

Allowed parameter format : regx regx:rva regx:rva%size regx%size

  • regx : Regular expression (mandatory)
  • rva : Byte offset from the beginning (optional)
  • size : Bytes number limit (optional)
  • div β€” Divide first param by second one and put the result in the first one
  • dt dtors [Regex] β€” Print .dtors section entries matching Regex
  • dyn β€” Print the ELF dynamic section
  • ds dynsym [Regex] β€” Print dynamic symtab (.dynsym) entries matching Regex
  • e elf β€” Print the ELF header
  • findrel β€” Try to find back stripped relocation information.
Note: retrieving this information in a very exact manner is very difficult, this command only gives you an approximative list of pointer accesses in the binary code. It does not deal either with constructed addresses using multiple arithmetic and logic instructions, or with false positives that appear to be valid mapped pointers but are not in reality (ex: Hashed data). πŸ™ˆ
  • get β€” Print parameter object value. The parameter can be a constant or defined value, a variable or any ELF object that is part of any file loaded in the shell, provided you give its id at the beginning of the object path. See info command for the exact grammar of object paths.
  • g got [Regex] β€” Print the entries of the Global Offset Table (GOT) matching Regex. The regex can apply on either an address, an entry index, or a resolved symbol from the entry address (or contained address).
  • X hexa [Regex] β€” Dump matching binary objects in current file. This has the same syntax than D/disasm command.
X parameter

ParamFormat : regx regx:rva regx:rva%size regx%size

  • regx : Regular expression (mandatory)
  • rva : Byte offset from the beginning (optional)
  • size : Bytes number limit (optional)
  • interp β€” Print ELF interpreter path standing in .interp section.
  • mod β€” Modulo operation between 2 parameters. The result is put in the destination variable.
  • mul β€” Multiply the 2 parameters. The result is put in the destination variable.
  • n notes [Regex] β€” Print the Notes sections entries matching Regex
  • p pht β€” Print the Program Header Table (PHT)
  • print [ObjectPath1 ObjectPath2 ... ObjectPathN] β€” Print the values of objects ObjectPath1 ObjectPath2 ... ObjectPathN. Objects can be constant strings, ELF objects, variables, defined values, and so on.
  • redir func (func2 | addr) β€” Redirect calls to function func to func2 or address addr.

If the original function has a PLT entry, the ALTPLT technique is used to perform the redirection. If the function is internal (or if we are in a static binary) the CFLOW technique is used to perform the redirection. ALTPLT technique is available on INTEL, SPARC, MIPS, and ALPHA architectures. CFLOW technique is currently not available on the SPARC architecture. The hook (second) function is usually an injected C code provided by the user and injected using the reladd primitive. In case the provided hook function calls other function which are not in the host binary, ERESI will use the EXTPLT technique (or EXTSTATIC technique on static binaries) to relink the host binary in order to add new relocation entries, dynamic symbols with their names, symbol versions, extra GOT and PLT entries (using additionally the ALTGOT technique on RISC architectures), and will fixup the .dynamic section to reflect those changes on the section list. πŸ”₯

  • r rel [Regex] β€” Print the relocation entries matching Regex
  • reladd (DestFilePath | DestfileID) (RelocFilePath | RelocFileID) β€” Inject the ELF relocatable object RelocFileID into the ELF executable object DestFileID. This command is used for injecting plain C compiled code linked into a .o file into a host ET_EXEC (executable) or ET_DYN (shared library) ELF file.
  • set DestObjectPath SourceObjectPath β€” Set the value of object DestObjectPath to SourceObjectPath. The $_ variable gets modified depending on the result. See the info command for a list of all accessible objects using the set command.
  • s sht [Regex] β€” Print the sections in the Section Header Table (SHT) matching Regex
  • sub β€” Substract 2nd parameter to the first one. The $_ variable is modified depending on the result.
  • write DestObjectPath SourceObjectPath β€” Copy data from SourceObjectPath to DestObjectPath. The destination object has to be of type RAW (the data field of a section) and the source object has to be of type RAW or STRING. See the info command for more detail about this.
  • test β€” it's in the roster above; this part doesn't give it a separate description.

πŸ¦‹ Debugger commands πŸ¦‹

Roster:

backtrace break continue dbgstack delete dumpregs linkmap stack step display threads itrace
  • backtrace β€” Print backtrace (needs frame pointer).
  • break (BPsymbol | 0xaddress) β€” Put a breakpoint on symbol or address. Print all breakpoints if given without parameter.
  • step β€” Enable or disable stepping of debuggee program. Use continue for singlestepping.
  • continue β€” Continue executing debuggee program after breakpoint or singlestep.
  • delete (BPID | BPsymbol | 0xaddress) β€” Delete breakpoint by symbol, address, or ID.
  • dbgstack WordsNBR

Okay so this one's a little orphan paragraph that's mid-command, but the facts are the facts bestie: it dumps N words from the debugger stack, where N is the first parameter. And the reason we can even do this? The debugger is embedded into the debuggee process. Iconic behaviour, honestly.

  • stack WordsNBR β€” dump WordsNBR words on the debuggee stack. 🫢
  • dumpregs β€” dump the registers of the debuggee, right at the breakpoint or step. Snap a pic of the CPU's whole mood.
  • linkmap β€” print the Linkmap list for the debuggee process. πŸ¦‹
  • display BPid Full_ERESI_command β€” set a command to run on an event. First param has to be the breakpoint id that corresponds to the event, no cap. The ERESI command can be literally any valid ERESI command β€” including sourcing an ERESI script. Big main character energy for a breakpoint, tbh.
  • threads [ThreadID] β€” with no parameter? It lists the existing threads in the debuggee process. With a thread ID parameter? The current thread gets switched to the thread indicated by that ID. Two moods, one command. ✨
  • itrace β€” singlestep the debuggee program until the next breakpoint event, printing all executed instructions until it stops. Prepare to be flooded, bestie 😭

🌈 ELFsh modules commands

modhelp modload modunload β€” the module trio, the holy trinity, iykyk πŸ’…

  • modhelp ModuleFilePath β€” print help for a loaded ERESI module. Read the instructions, babe.
  • modload ModuleFilePath β€” load an ERESI module. The path has to be absolute, or relative to the registered module path.
  • modunload ModuleFilePath β€” unload an ERESI module. Same deal: absolute path, or relative to the registered module path.

πŸŽ€ ELF objects flags

fixup shtrm sstrip β€” three little flag-setters that change the ELFsh internal descriptor, not the file. (Well, some of them save later. Keep reading πŸ“)

  • fixup β€” mark the BSS section to be included in the disk file. The BSS gets immediately fixed in the ELFsh internal descriptor of the object.
  • shtrm β€” mark the Section Header Table as removed. Heads up: the SHT will be removed only when the file is saved, so it's a "later" kind of deal.
  • sstrip β€” mark the Section Header Table (SHT) and the Symbol Table (.symtab) as stripped. Same vibe: they will be removed only when the file is saved.
πŸ’€ Nobody's deleting anything behind your back here β€” the removal waits for save. Periodt.

πŸ¦‹ Ondisk only ELF commands

These commands only work in ELFsh, or in E2dbg when switched to the static mode using the mode command. So like, don't come at them from dynamic mode, they will not answer.

append extend flush insert remove save stab sym

  • append SectionName SourceObjectPath β€” append the data of object SourceObjectPath to section SectionName.
  • extend SectionName length β€” extend section SectionName with length zero bytes.
  • flush β€” flush all injected .o files from the current file.
  • insert β€” inject a new object (section, symbol, or program header) in the current working file. Here's the full syntax, verbatim:
insert sect  name code|data|unmap [sz] [align]
       sym   name value           [sz]
       phdr  type vaddr           [sz]
  • remove β€” remove an ELF object (section, symbol, or program header) from the current working file. And the shapes it takes:
remove sect name
       sym  name
       phdr index
  • save filename β€” dump the current selected file to the output file filename. Bestie, this command writes a file on disk. Like, actually on your actual disk. Be normal about it πŸ™ˆ
  • debug β€” print unified debug format information for the current file.
  • st sym [Regex] β€” print the symtab (.symtab) entries matching Regex.

πŸ’œ Kernsh modules commands

Those commands only work in Kernsh. Kernel girlies only, sorry to the userspace girlies πŸ’…

  • openmem β€” open kernel memory and static kernel.
  • closemem β€” close kernel memory and static kernel.
  • sct β€” display the syscall table.
  • idt β€” display the interrupt descriptor table.
  • gdt β€” display the global descriptor table.
  • alloc β€” alloc contiguous kernel memory.
  • free β€” free contiguous kernel memory.
  • alloc_nc β€” alloc non contiguous kernel memory.
  • free_nc β€” free non contiguous kernel memory.
  • kmodule β€” handle kernel module. And the sub-flavours are:
    • kmodule -l module : load a lkm
    • kmodule -u module : unload a lkm
    • kmodule -r module1 module2 moduleout : link module with another
    • kmodule -i module original_name evil_name : change lkm init (original_name) with another function (evil_name)
  • ksym β€” get an address of a kernel symbol.
  • kmd5 sa output | sa:rva output | sa%rva%size output | sa%size output β€” make a md5sum. Breakdown, because there's a lot going on:
    • sa : symbol or addr
    • rva : byte offset from the beginning (optional)
    • size : bytes number limit (optional) β€” and if size is 0 or not put, we search the end of the function
    • output : file output (optional)
  • kcmd5 format | file β€” check a md5.
    • format : addr:mode:size:off:md5
    • file : filename

These primitives let you define and habitate types in the ERESI meta-language. Yes, "habitate". We stan a whole vocabulary 🌸

  • type [regex] β€” print the list of types (only the ones matching the regular expression, if one's given as a parameter).
  • type name = field1:type1 ... fieldN:typeN β€” define a new type in the ERESI meta-language. Predefined types include byte, short, int, caddr, daddr, long, hash, vector, string, and raw.
  • typedef tname tname2 β€” copy and rename a type. And listen: any modification on one of the types will not affect the other. They're independent girlies, no codependency πŸ’…
  • inform type [name | address] β€” make type name habitated by the variable standing at address name. If called with a single type name parameter, the command lists all variables that habitate this type. If given two parameters, the name is interpreted as a symbol pointing on a variable β€” its address is resolved and the type is informed about this variable. If only an address is given, its symbol is looked up and the variable corresponding to the symbol is informed. And if no symbol corresponds to that address? A new one is created that points on the address, and the newly symbolic variable is informed. Look at her go πŸ”₯
  • uninform type [name] β€” uninform a given variable from a type. If no variable name is given, all variables previously informed are removed from the type habitation. Total reset energy.

🌈 Network commands

connect disconnect net netkill netlist peerslist rcmd

  • connect β€” add a DUMP connection to given host.
  • disconnect β€” kill the DUMP connection from IP.
  • net β€” activate networking capabilities.
  • netkill β€” kill a network client by IP.
  • netlist β€” list connected network clients.
  • peerslist β€” list connected DUMP peers.
  • rcmd β€” execute a command on a remote machine. Remote bestie does it for you πŸ’–

πŸŽ€ Available prefixes

alert all quiet sort verb

  • alert β€” alert prefix : change alert regular expression.
  • a, all regex β€” set a global regular expression. All commands which take a regular expression as a parameter will default to use this global regular expression. Set it once, slay everywhere ✨
  • quiet β€” toggle the quiet flag (do not print executed commands).
  • sort β€” sorting prefix (use a -addr- or s -size-).
  • verb β€” toggle the verbose flag (undo the quiet flag).

🧚 Available Script jumps

A certain number of jumps construct are available, and here's the whole squad:

je jg jge jl jle jmp jne

  • je β€” jump on label if equal (use last cmp result).
  • jg β€” jump on label if greater (use last cmp result).
  • jge β€” jump on label if greater or equal (use last cmp result).
  • jl β€” jump on label if lower (use last cmp result).
  • jle β€” jump on label if lower or equal (use last cmp result).
  • jmp β€” unconditional jump to script label.
  • jne β€” jump on label if nont equal (use last cmp result).
😭 And yes, the page literally says "nont equal". Not me fixing it. The facts stay the facts.

You might also consider using a foreach construct, which is not described in this manual page. Rude of it, honestly.


πŸ‘‘ Available modules

modflow modremap modtest

  • modflow β€” Modflow is an ELFsh module designed to perform control flow analysis on ELF binaries. For detailed examples and usage, see README in ELFsh/modules/modflow.
  • modremap β€” "Modflow is an ELFsh module designed to perform remapping sections in Elf binaries" β€” that's verbatim what the page says, πŸ’€, and see ELFsh/modules/modremap for further details.
  • modtest β€” Modtest is a ElFsh module designed to show the usage of adding new commands to ELFsh. See ELFsh/modules/modtest for further details. (Yes: "a ElFsh". We keep it. πŸ“)

πŸ¦‹ OBJECT PATH FORMAT πŸ¦‹

okay so this section is literally the map for grabbing different objects inside an ELF file. for most commands, the object can also be a decimal or hexadecimal number β€” and when that happens, the ObjectPath is that number. no cap.


🧚 ELF Header 🧚

the shape is filename.hdrfield, bestie.

ELF header fields are:

  • magic β€” Magic number
  • class β€” File class
  • type β€” Object file type
  • machine β€” Architecture
  • version β€” Object file version
  • entry β€” Entry point virtual address
  • phoff β€” Program header table file offset
  • shoff β€” Section header table file offset
  • flags β€” Processor-specific Flags
  • ehsize β€” Size of the ELF header in bytes
  • phentsize β€” Size of the program headers
  • shentsize β€” Size of the section headers
  • phnum β€” Number of program headers
  • shnum β€” Number of section headers
  • shstrndx β€” Section header string table index
  • pax_pageexec β€” PAX use paging based non-executable pages
  • pax_emultramp β€” PAX emulate trampolines
  • pax_mprotect β€” PAX restrict mmap
  • pax_randmmap β€” PAX randomize mmap
  • pax_randexec β€” PAX randomly map executable address
  • pax_segmexec β€” PAX use segmentation based non-executable pages

πŸŽ€ got/ctors/dtors tables πŸŽ€

the format is (filename | fileID).(got|ctors|dtors)[index].

in this command, the index can also be a symbol name that corresponds to the requested GOT, CTORS, OR DTORS entry. iykyk.


🌸 Program segment header table 🌸

you reach these with (filename | fileID).pht[index].fi eld.

Program segment header table entry fields are:

  • type β€” Segment type
  • offset β€” Segment file offset
  • paddr β€” Segment physical address
  • vaddr β€” Segment virtual address
  • filesz β€” Segment size in file
  • memsz β€” Segment size in memory
  • flags β€” Segment flags
  • align β€” Segment alignment

πŸ’œ Symbol/Dynamic symbol tables πŸ’œ

the path is (filename | fileID).(symtab|dynsym)[index].fi eld.

Symbol/Dynamic symbol table entry fields are:

  • name β€” Symbol name
  • value β€” Symbol value
  • size β€” Symbol size
  • bind β€” Symbol binding
  • type β€” Symbol type
  • other β€” Symbol visibility

✨ Dynamic section ✨

hit it with (filename | fileID).dynamic[index].fi eld.

the .dynamic section entry fields are:

  • val β€” Integer or address value
  • tag β€” Dynamic entry type

πŸŽ€ Section header table πŸŽ€

the format is (filename | fileID).sht[index].fi eld.

the index can be the name of the section. Section Header Table entries fields are:

  • type β€” Section type
  • offset β€” Section Offset in ELF file
  • addr β€” Section Address
  • size β€” Section Size in bytes
  • link β€” Link to another section
  • info β€” Additional Info
  • align β€” Section Alignment
  • entsize β€” Entry size if section holds table
  • flags β€” section flag letters:
    • a β€” Section occupies memory during execution
    • w β€” Section is Writeable
    • x β€” Section is Executable
    • s β€” Contains nul-terminated strings
    • m β€” Section might be merged
    • l β€” Preserve order after combining
    • o β€” OS specific

πŸ¦‹ Relocation table πŸ¦‹

the path is (filename | fileID).rel[indextable][indexentry].fi eld.

Relocation entry fields are:

  • type β€” Relocation Type
  • sym β€” Relocation symbol index
  • offset β€” Address

🌈 Additional sections information 🌈

the format is (filename | fileID).section[sectionindex].fi eld.

πŸ’€ heads up: the section object is not a real object of the binary, but a kind of virtual one. it holds all the information about a section that do not stand in the sectoin header table entries.

Section fields are:

  • name β€” Section name
  • raw β€” Section Raw data

to access, use this path format:

filename.section[index[:offset[%elemsize]]].raw


✨ AUTHOR ✨

ERESI was created by Julien Vanegue and developed by the ERESI team.

<team at eresi-project dot antispam org>

the complete list of ERESI contributors can be found on the website:

http://www.eresi-project.org

this manual page was created by Julien Vanegue, from previous work on the ELFsh man page by Peter De Schrijver for the Debian GNU/Linux system. additional improvements were made by stingduk for version 0.7. iconic.


🌈 SEE ALSO 🌈


and that’s the whole ERESI(1) page, bestie β€” brought to you by ERESI 0.78, dated May 2007, and filed under ERESI(1). slay. πŸ’…βœ¨

πŸ“¦ where this page comes from