Skip to content

Persistence via ELF backdooring through codecave or new section - #21839

Open
dledda-r7 wants to merge 2 commits into
rapid7:masterfrom
dledda-r7:feat/persistence/elf
Open

Persistence via ELF backdooring through codecave or new section#21839
dledda-r7 wants to merge 2 commits into
rapid7:masterfrom
dledda-r7:feat/persistence/elf

Conversation

@dledda-r7

Copy link
Copy Markdown
Contributor

This pull request introduces a new ELF injector utility to enable payload injection into Linux ELF executables, supporting x86, x64, and AArch64 architectures.

New ELF Injector Implementation:

  • Added ElfInjector class in lib/msf/core/exe/elf_injector.rb that parses ELF headers, locates code caves or reusable program headers, and injects a payload with a trampoline to preserve original execution flow. Supports both code cave and new segment injection techniques, with thorough validation of ELF structures.
  • Implemented architecture-specific trampoline generators:
    • AArch64 trampoline in elf_injector/a_arch64.rb for ARM64, saving/restoring registers and branching logic for parent/child after clone.
    • X64 trampoline in elf_injector/x64.rb for x86_64, using Metasm assembly to fork and resume execution.
    • X86 trampoline in elf_injector/x86.rb for 32-bit x86, using Metasm assembly for similar logic.

Documentation:

  • Added documentation/modules/exploit/linux/persistence/elf.md with an overview of the module, supported targets, verification steps, options, limitations, and usage scenarios. This guides users through safe testing and highlights operational constraints.

Comment thread modules/exploits/linux/persistence/elf.rb Outdated
@dledda-r7

Copy link
Copy Markdown
Contributor Author
  1) Meterpreter mettle linux/x64/meterpreter_reverse_http linux post/test/search linux/mettle meterpreter successfully opens a session for the "linux/x64/meterpreter_reverse_http" payload and passes the "post/test/search" tests (malleable c2: minimal_uris_headers.profile)
     Failure/Error: expect(test_line).to_not include('FAILED', '[-] FAILED', '[-] Exception', '[-] '), "Unexpected error: #{test_line}"
       Unexpected error: [-] Post interrupted by the console user

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

1 participant