nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Editing binary without corrupting it?

This is a discussion on Editing binary without corrupting it? within the Shell scripting forums, part of the Development/Scripting category; I'll try to explain shortly what I am trying to do. There is a binary that is executed on linux ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Forgotten your password? Mark Forums Read
  #1 (permalink)  
Old 10-03-2006, 03:22 AM
Junior Member
User
 
Join Date: Jun 2006
Posts: 21
Rep Power: 0
karabaja
Default Editing binary without corrupting it?

I'll try to explain shortly what I am trying to do. There is a binary that is executed on linux based satellite receivers. And I've seen compressed version of these binaries which also run fine and take half the space regular one does. And it is useful on receivers with a lack of free space.
So I contacted man who originally released these compressed versions. He told me that he just gzipped them and added few lines in file header.
Now the problem is that he didn't want to help me any further when I got stuck. I gzip the binary but if I try to edit it saved file will be corrupt.
Then I placed header from his compressed files in a file called "file1" then did
Code:
cat file1 file2.gz > finalfile
and that got me pretty close what the file should look like but it is not exactly it.

I'll post here what he got and then what I got but just few lines of the files to illustrate:

his version:
Code:
else
  echo "Cannot decompress $0"
  /bin/rm -rf $tmpdir
  exit 1
fi; exit $res
‹ýzA¬Ńç}°¦±~	óx˝ľ†DMľ€ Ő jÉlČ–Mľ
what I got:

Code:
else
  echo "Cannot decompress $0"
  /bin/rm -rf $tmpdir
  exit 1
fi; exit $res‹wźEcamd_3880iXç˙G
The difference is that his file has a break of line after header he added. After the "res". And when I did cat to join two files in one, it just continues binary code right after the "res" not in next line.
Now is there a way for me to do what he did, since he didn't answer to my question about that.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-03-2006, 08:12 AM
monk's Avatar
Senior Member
User
 
Join Date: Jan 2005
Location: Tibet
My distro: Debian GNU/Linux
Posts: 482
Rep Power: 5
monk will become famous soon enough monk will become famous soon enough
Default

Use -b with vi:
Code:
vi -b file
A few options will be set that makes it possible to edit a binary or executable file.
Reply With Quote
  #3 (permalink)  
Old 10-03-2006, 08:34 AM
Junior Member
User
 
Join Date: Jun 2006
Posts: 21
Rep Power: 0
karabaja
Default

Thx a lot. That worked great.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
Howto Ubuntu Linux editing admin or root configuration files tom Getting started tutorials 3 03-25-2008 12:50 AM
convert perl code into binary executable chandanperl Coding in General 0 03-13-2008 11:43 AM
Read arguments from a file and pass them to binary file AHJ Shell scripting 1 10-31-2007 07:04 PM
Source src.rpm vs binary rpm files shankar100 Linux software 2 06-15-2007 05:06 PM
help me in editing this columns sureshbup Shell scripting 1 12-12-2006 03:29 PM


All times are GMT +5.5. The time now is 09:05 PM.


Powered by vBulletin® Version 3.7.4 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36