LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 06-30-2015, 06:24 PM   #1
lbjksp
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Rep: Reputation: Disabled
Elf headers of binary corrupted - fix?


I have a binary (compiled with gcc) with corrupted elf headers.

The file utility shows the following information:
Code:
mybinary: ERROR: ELF 64-bit LSB executable, x86-64, invalid version (SYSV), dynamically linked (uses shared libs)error reading (Invalid argument)
readelf -h ./mybinary shows this at the end of the output:
Code:
readelf: Error: Unable to seek to 0xffffff60e9000000 for string table
readelf: Error: Section 8 has invalid sh_entsize 6c2f343662696c2f (expected 18)
readelf: Error: Section 23 has invalid sh_entsize 0 (expected 10)
readelf: Error: no .dynamic section in the dynamic segment
What can I do to fix this binary? I can not run a file with broken elf headers in gdb for example.
 
Old 06-30-2015, 08:58 PM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by lbjksp View Post
I have a binary (compiled with gcc) with corrupted elf headers.

The file utility shows the following information:
Code:
mybinary: ERROR: ELF 64-bit LSB executable, x86-64, invalid version (SYSV), dynamically linked (uses shared libs)error reading (Invalid argument)
readelf -h ./mybinary shows this at the end of the output:
[CODE]
readelf: Error: Section 8 has invalid sh_entsize 6c2f343662696c2f (expected 18)
"entsize" looks like a string "l/46bil/". Perhaps the string command helps you get a clue.
I'd say that something overwrote the header.
Or the header is in a different format than expected by readelf or file; perhaps it was created for a different platform.

While I don't know if there are programs that can fix corrupted ELF headers, I am curious: Can you run this binary? Can you recreate it? If not, where did you get it from?
 
Old 07-01-2015, 07:09 AM   #3
lbjksp
LQ Newbie
 
Registered: Jun 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by berndbausch View Post
"entsize" looks like a string "l/46bil/". Perhaps the string command helps you get a clue.
I'd say that something overwrote the header.
Or the header is in a different format than expected by readelf or file; perhaps it was created for a different platform.

While I don't know if there are programs that can fix corrupted ELF headers, I am curious: Can you run this binary? Can you recreate it? If not, where did you get it from?
The ELF headers were corrupted on purpose by the author of this binary to prevent it from being reverse engineered. gdb or objdump or disassembler tools either print an error message (File format not recognized) or crash. I can run this binary perfectly fine. It's a small crackme file for a reverse engineering exercise, which is not easy as debugging or disassembling is not possible to due the corrupted headers.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding Program Headers in ELF file kk2mkk Programming 6 02-14-2010 12:01 PM
invaild ELF headers after filesystem recovery, can't boot replica9000 Linux - Software 0 10-13-2007 05:11 PM
FedoraCore 3: Invalid ELF headers drogers Fedora 1 10-31-2005 11:57 AM
How to compile into ELF binary? kornerr Programming 3 06-29-2005 11:37 AM
Reading Memory Value from ELF Binary Damaged Soul Programming 4 11-24-2004 11:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration