Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the aarch64 elf version in template file and reassemble #19871

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bwatters-r7
Copy link
Contributor

@bwatters-r7 bwatters-r7 commented Feb 11, 2025

It turns out we are using ELF version 0 for aarch64 staged elf payloads. There's no such version. In fact, there has ever only been version 1. See https://en.wikipedia.org/wiki/Executable_and_Linkable_Format for the value in offset 0x14.

This just sets that value to 1. It does not fix all the problems we have seen, but it does allow debuggers and other tools to work so we can figure out why it is failing.

Related:
#19841
#19865

Testing

Old

msf6 payload(cmd/linux/https/x64/meterpreter_reverse_tcp) > use payload/linux/aarch64/meterpreter/reverse_tcp
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > set lhost 10.5.135.201
lhost => 10.5.135.201
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > generate -f elf -o aarch64_staged.elf
[*] Writing 332 bytes to aarch64_staged.elf...
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > file aarch64_staged.elf
[*] exec: file aarch64_staged.elf

aarch64_staged.elf: ELF 64-bit LSB executable, ARM aarch64, invalid version (SYSV), statically linked, no section header
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > readelf -a aarch64_staged.elf
[*] exec: readelf -a aarch64_staged.elf

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x0
  Entry point address:               0x400078
  Start of program headers:          64 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         1
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0

There are no sections in this file.

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x000000000000014c 0x0000000000000220  RWE    0x1000

There is no dynamic section in this file.

There are no relocations in this file.

The decoding of unwind sections for machine type AArch64 is not currently supported.

Dynamic symbol information is not available for displaying symbols.

No version information found in this file.
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > 

New

msf6 payload(cmd/linux/https/x64/meterpreter_reverse_tcp) > use payload/linux/aarch64/meterpreter/reverse_tcp 
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > set lhost 10.5.135.201
lhost => 10.5.135.201
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > generate -f elf -o aarch64_staged.elf
[*] Writing 332 bytes to aarch64_staged.elf...
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > file aarch64_staged.elf
[*] exec: file aarch64_staged.elf

aarch64_staged.elf: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), statically linked, no section header
msf6 payload(linux/aarch64/meterpreter/reverse_tcp) > readelf -a aarch64_staged.elf
[*] exec: readelf -a aarch64_staged.elf

ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           AArch64
  Version:                           0x1
  Entry point address:               0x400078
  Start of program headers:          64 (bytes into file)
  Start of section headers:          0 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         1
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0

There are no sections in this file.

There are no section groups in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000400000 0x0000000000400000
                 0x000000000000014c 0x0000000000000220  RWE    0x1000

There is no dynamic section in this file.

There are no relocations in this file.

The decoding of unwind sections for machine type AArch64 is not currently supported.

Dynamic symbol information is not available for displaying symbols.

No version information found in this file.

@smcintyre-r7 smcintyre-r7 added bug rn-fix release notes fix payload labels Feb 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug payload rn-fix release notes fix
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants