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

ELF parse error: Invalid Magic Bytes: [4D, 5A, 71, 46] #20

Closed
franalbani opened this issue Sep 12, 2024 · 5 comments
Closed

ELF parse error: Invalid Magic Bytes: [4D, 5A, 71, 46] #20

franalbani opened this issue Sep 12, 2024 · 5 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@franalbani
Copy link

Describe the bug

Can't open binaries from cosmo.zip that where compiled with Cosmopolitan libc

To reproduce

$ wget -qO /tmp/true https://cosmo.zip/pub/cosmos/bin/true
$ binsider /tmp/true
ELF parse error: `Invalid Magic Bytes: [4D, 5A, 71, 46]`

Software information

  • Operating system: Arch GNU/Linux x86_64 6.10.1-arch1-1
  • Rust version: rustc 1.81.0 (eeb90cda1 2024-09-04) (Arch Linux rust 1:1.81.0-1)
@franalbani franalbani added the bug Something isn't working label Sep 12, 2024
@orhun
Copy link
Owner

orhun commented Sep 13, 2024

Hey, thanks for reporting!

Does the file have a valid ELF format? binsider currently only support ELF.

$ file true

etc/true: DOS/MBR boot sector; partition 1 : ID=0x7f, active, start-CHS (0x0,0,1), end-CHS (0x3ff,255,63), startsector 0, 4294967295 sectors

Compared to:

$ file /usr/bin/ls

/usr/bin/ls: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=7aa8f52223e371fb77314d9a363129574096093b, for GNU/Linux 4.4.0, stripped

@orhun orhun added the question Further information is requested label Sep 20, 2024
@orhun orhun closed this as not planned Won't fix, can't repro, duplicate, stale Sep 24, 2024
@hustcer
Copy link

hustcer commented Oct 3, 2024

Thanks for the project! will Mach-O 64-bit executable be supported someday?

 ❯ file /opt/homebrew/bin/binsider
/opt/homebrew/bin/binsider: Mach-O 64-bit executable arm64

 ❯ binsider /opt/homebrew/bin/binsider
ELF parse error: `Invalid Magic Bytes: [CF, FA, ED, FE]`

@orhun
Copy link
Owner

orhun commented Oct 3, 2024

Yup, one day! See #26 :)

@franalbani
Copy link
Author

Does the file have a valid ELF format? binsider currently only support ELF.

No, it is a clever trick to "mimic" most executable formats out there. The file utility is just reporting the type of the first found segment but the ELF segment appears after.

It's called Actually Portable Executable

@orhun
Copy link
Owner

orhun commented Nov 12, 2024

Interesting. I think this should be reported to elf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants