Re: how to modify string in binary files ?

2009-09-01 Thread Jerome BENOIT

Hello Chris !

Chris Jones wrote:

On Mon, Aug 31, 2009 at 08:08:50PM EDT, Jerome BENOIT wrote:

Hello List,

I would like to change the string of a file name in a (propriety) binary:
if applicable, how can we do that ?


Use vim's binary mode. 


$ vim -b binary-file

And before you start editing:

:h edit-binary


I have just tried.

It is claimed that

 When editing executable files the number of characters must not change.
 Use only the R or r command to change text.  Do not delete characters
 with x or by backspacing.

So a string cannot be made longer.
Can we make a string shorter ?
The first idea that comes is to put a '\n' at the desired end of the string
and then fill the extra with '\0': is it safe. 


Otherwise, as no HEX code appears, is `bvi' a good alternative ?

Jerome



CJ




--
Jerome BENOIT
jgmbenoit_at_mailsnare_dot_net


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-09-01 Thread Ron Johnson

On 2009-09-01 01:03, Jerome BENOIT wrote:

Hello Chris !

Chris Jones wrote:

On Mon, Aug 31, 2009 at 08:08:50PM EDT, Jerome BENOIT wrote:

Hello List,

I would like to change the string of a file name in a (propriety) 
binary:

if applicable, how can we do that ?


Use vim's binary mode.
$ vim -b binary-file

And before you start editing:

:h edit-binary


I have just tried.

It is claimed that

 When editing executable files the number of characters must not change.
 Use only the R or r command to change text.  Do not delete characters
 with x or by backspacing.

So a string cannot be made longer.
Can we make a string shorter ?


The program is going to expect certain stuff to be at certain 
places within the file.  Adding or removing bytes is *definitely* A 
VERY BAD THING.



The first idea that comes is to put a '\n' at the desired end of the string
and then fill the extra with '\0': is it safe.


IFF the app was written in a language that uses \0 as the string 
terminator...



Otherwise, as no HEX code appears, is `bvi' a good alternative ?


It's what I'd use...

--
Brawndo's got what plants crave.  It's got electrolytes!


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-09-01 Thread Boyd Stephen Smith Jr.
In 4a9cd48b.6040...@cox.net, Ron Johnson wrote:
On 2009-09-01 01:03, Jerome BENOIT wrote:
 Hello Chris !

 Chris Jones wrote:
 On Mon, Aug 31, 2009 at 08:08:50PM EDT, Jerome BENOIT wrote:
 Hello List,

 I would like to change the string of a file name in a (propriety)
 binary:
 if applicable, how can we do that ?

 Use vim's binary mode.
 $ vim -b binary-file

 And before you start editing:
 :h edit-binary
 It is claimed that

  When editing executable files the number of characters must not change.
  Use only the R or r command to change text.  Do not delete characters
  with x or by backspacing.
 The first idea that comes is to put a '\n' at the desired end of the
 string and then fill the extra with '\0': is it safe.

IFF the app was written in a language that uses \0 as the string
terminator...

Which you should be able to tell upon inspection.  If there's no '\0' after 
your string, using them as terminators is probably useless.
-- 
Boyd Stephen Smith Jr.   ,= ,-_-. =.
b...@iguanasuicide.net   ((_/)o o(\_))
ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-'
http://iguanasuicide.net/\_/



signature.asc
Description: This is a digitally signed message part.


Re: how to modify string in binary files ?

2009-09-01 Thread Chris Jones
On Tue, Sep 01, 2009 at 02:03:02AM EDT, Jerome BENOIT wrote:

 Otherwise, as no HEX code appears, 

You need to use a vim add-on called xxd - it's in the vim-common
package.

Google for vim tips with vim xxd as the keywords.

 is `bvi' a good alternative ?

I wasn't familiar with bvi, but one thing I like about vim is that you
can undo/redo your changes and test the results in another window. Not
sure bvi supports that?

As Ron said, this does not dispense you with making a backup.

Another thing - if the string you want to modify is not plain ASCII,
UTF-8, etc. vim could make it easier to locate/edit your string
depending on the circumstances.

CJ


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



how to modify string in binary files ?

2009-08-31 Thread Jerome BENOIT

Hello List,

I would like to change the string of a file name in a (propriety) binary:
if applicable, how can we do that ?

Thanks in advance,
Jerome

--
Jerome BENOIT
jgmbenoit_at_mailsnare_dot_net


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-08-31 Thread Ron Johnson

On 2009-08-31 19:08, Jerome BENOIT wrote:

Hello List,

I would like to change the string of a file name in a (propriety) binary:
if applicable, how can we do that ?


With a binary or hexadecimal editor.

$ apt-cache search binary editor

$ apt-cache search hex editor

--
Brawndo's got what plants crave.  It's got electrolytes!


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-08-31 Thread Celejar
On Tue, 01 Sep 2009 08:08:50 +0800
Jerome BENOIT jgmben...@mailsnare.net wrote:

 Hello List,
 
 I would like to change the string of a file name in a (propriety) binary:
 if applicable, how can we do that ?

Use a hex editor?

Celejar
-- 
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: how to modify string in binary files ?

2009-08-31 Thread Celejar
[Please reply only to the list, and don't cc. me, as per the list CoC.]

On Tue, 01 Sep 2009 09:24:06 +0800
Jerome BENOIT jgmben...@mailsnare.net wrote:

 Celejar wrote:
  On Tue, 01 Sep 2009 08:08:50 +0800
  Jerome BENOIT jgmben...@mailsnare.net wrote:
  
  Hello List,
 
  I would like to change the string of a file name in a (propriety) binary:
  if applicable, how can we do that ?
  
  Use a hex editor?
 
 Let me specify. My binary file is an executable binary file,
 not a data file. Of course, I want to be able to run the modified version.
 
 So according to you, I have just to edit my binary, modify the string by hand,
 and the modified binary is fine: is there any side effect ?

Since it's a binary file, you can't know for sure, but IIUC, there
likely won't be any side effects.  I'm no expert on this stuff, though,
so please take my advice with a grain of salt.

Celejar
-- 
mailmin.sourceforge.net - remote access via secure (OpenPGP) email
ssuds.sourceforge.net - A Simple Sudoku Solver and Generator


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: how to modify string in binary files ?

2009-08-31 Thread Jerome BENOIT

Celejar wrote:

On Tue, 01 Sep 2009 08:08:50 +0800
Jerome BENOIT jgmben...@mailsnare.net wrote:


Hello List,

I would like to change the string of a file name in a (propriety) binary:
if applicable, how can we do that ?


Use a hex editor?


Let me specify. My binary file is an executable binary file,
not a data file. Of course, I want to be able to run the modified version.

So according to you, I have just to edit my binary, modify the string by hand,
and the modified binary is fine: is there any side effect ?

Jerome



Celejar


--
Jerome BENOIT
jgmbenoit_at_mailsnare_dot_net


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-08-31 Thread Patrick Wiseman
On Mon, Aug 31, 2009 at 9:24 PM, Jerome BENOITjgmben...@mailsnare.net wrote:
 Celejar wrote:

 On Tue, 01 Sep 2009 08:08:50 +0800
 Jerome BENOIT jgmben...@mailsnare.net wrote:

 Hello List,

 I would like to change the string of a file name in a (propriety) binary:
 if applicable, how can we do that ?

 Use a hex editor?

 Let me specify. My binary file is an executable binary file,
 not a data file. Of course, I want to be able to run the modified version.

 So according to you, I have just to edit my binary, modify the string by
 hand,
 and the modified binary is fine: is there any side effect ?

I am running a version of WordPerfect 8 (the UN*X version) on my amd64
testing system in which I have replaced, in all the binaries,
references to 'ld-linux.so.1' with 'ld-linux.so.2'.  It works.

Patrick


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Re: how to modify string in binary files ?

2009-08-31 Thread Ron Johnson

On 2009-08-31 20:28, Celejar wrote:

[Please reply only to the list, and don't cc. me, as per the list CoC.]

On Tue, 01 Sep 2009 09:24:06 +0800
Jerome BENOIT jgmben...@mailsnare.net wrote:


Celejar wrote:

On Tue, 01 Sep 2009 08:08:50 +0800
Jerome BENOIT jgmben...@mailsnare.net wrote:


Hello List,

I would like to change the string of a file name in a (propriety) binary:
if applicable, how can we do that ?

Use a hex editor?

Let me specify. My binary file is an executable binary file,
not a data file. Of course, I want to be able to run the modified version.

So according to you, I have just to edit my binary, modify the string by hand,
and the modified binary is fine: is there any side effect ?


Since it's a binary file, you can't know for sure, but IIUC, there
likely won't be any side effects.  I'm no expert on this stuff, though,
so please take my advice with a grain of salt.


There will be no side effects *if* you only *change* the existing 
text bytes.


Unless... the binary does some sort of internal checksumming to 
detect (possibly malicious) changes or license modifications.


Lastly: we don't need to tell an experienced guy like you to make a 
copy of the binary before you change it, right?  ;)


--
Brawndo's got what plants crave.  It's got electrolytes!


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org




Re: how to modify string in binary files ?

2009-08-31 Thread Chris Jones
On Mon, Aug 31, 2009 at 08:08:50PM EDT, Jerome BENOIT wrote:
 Hello List,

 I would like to change the string of a file name in a (propriety) binary:
 if applicable, how can we do that ?

Use vim's binary mode. 

$ vim -b binary-file

And before you start editing:

:h edit-binary

CJ


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org