Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Binary editing
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Unsupported Software
View previous topic :: View next topic  
Author Message
Ibrahim
n00b
n00b


Joined: 30 Nov 2009
Posts: 2

PostPosted: Tue Dec 01, 2009 10:00 am    Post subject: Binary editing Reply with quote

Hello everyone.I have a problem.i cant edit .bin (binary) files.Please help me.
Back to top
View user's profile Send private message
xaviermiller
Administrator
Administrator


Joined: 23 Jul 2004
Posts: 8045
Location: ~Brussels - Belgique

PostPosted: Tue Dec 01, 2009 10:20 am    Post subject: Reply with quote

Hello,

What do you want to do ?
Which .bin file do you want do edit ? Why ?

Which relation with Gentoo ?
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Tue Dec 01, 2009 12:01 pm    Post subject: Reply with quote

You are going to have to be more explicit than that.

.bin files usually contain binary code, and the only sane way to edit that is using a suitable editor, usually in hexadecimal or binary format. A good hex editor for linux is khexedit, there are many more, both text and GUI based.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5879

PostPosted: Tue Dec 01, 2009 5:04 pm    Post subject: Reply with quote

khexedit is a KDE3 app, so it might be a bad idea to install now. IIRC the replacement is called "okteta" but I've not used that one.
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Tue Dec 01, 2009 5:09 pm    Post subject: Reply with quote

Ant_P wrote:
khexedit is a KDE3 app, so it might be a bad idea to install now. IIRC the replacement is called "okteta" but I've not used that one.


True. I even use it from time to time, but my brain still hasn't catch up some of the name changes from 3.x to 4.x hehe. Thanks so much for the correction.
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 517

PostPosted: Tue Dec 01, 2009 10:51 pm    Post subject: Reply with quote

I'd love to open binaries in gedit. Unfortunately, gedit chokes on itself when it encounters even one char it can't display.

Yes, I am aware that I can't really edit the files with that. I just wanna see if there are strings in there... :(
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Tue Dec 01, 2009 10:55 pm    Post subject: Reply with quote

haarp wrote:
I'd love to open binaries in gedit. Unfortunately, gedit chokes on itself when it encounters even one char it can't display.

Yes, I am aware that I can't really edit the files with that. I just wanna see if there are strings in there... :(


There's a tool for that, it's called "strings".

Code:
$ strings /bin/ls | head
/lib64/ld-linux-x86-64.so.2
librt.so.1
__gmon_start__
_Jv_RegisterClasses
clock_gettime
libc.so.6
strcpy
__printf_chk
fnmatch
readdir

_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 517

PostPosted: Wed Dec 02, 2009 5:27 pm    Post subject: Reply with quote

Yes, I know. But that's not the same as a real editor ;)
Besides, gedit still doesn't work if it encounters even a single unknown char. It doesn't even have to be a binary
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43562
Location: 56N 3W

PostPosted: Wed Dec 02, 2009 6:41 pm    Post subject: Reply with quote

haarp,

hexedit. Be aware that using a hexeditor is bad for your system if you save the results of any changes.

You can point it at files, partitions or even whole drives. It can edit anything. Everything is a file on Linux.
The most common use for a hex editor is data recovery on a copy of the damaged disk/partition.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 517

PostPosted: Wed Dec 02, 2009 7:09 pm    Post subject: Reply with quote

Hex editors are cool, I agree. Using ghex2 myself. But still, there are often situations where you just want a simple editor like gedit to open a file and not choke on some uncommon newline format or something ;)
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5879

PostPosted: Wed Dec 02, 2009 7:36 pm    Post subject: Reply with quote

If you want that type of thing, maybe try GVim. It won't complain if you feed it binary files though it is a bit slow displaying them. There's even hex encode/decode options in the menu to use it as a primitive hex editor.

I've used both ghex and khexedit in the past, but I found the latter much easier to do stuff with.
Back to top
View user's profile Send private message
yoshi314
l33t
l33t


Joined: 30 Dec 2004
Posts: 848
Location: PL

PostPosted: Thu Dec 03, 2009 8:15 am    Post subject: Reply with quote

i recommend wxHexEditor ( http://wxhexeditor.sourceforge.net/ ) for hex editing needs. it's main feature is that it doesn't choke on files bigger than ram, which unfortunately cannot be said about other popular and easy to use linux hex editors :/

i've submitted a simple ebuild on gentoo bugzilla ( https://bugs.gentoo.org/show_bug.cgi?id=283994 ) if anybody is interested.

if vim has a hex-mode - it might be a second decent hex editor.
_________________
~amd64
shrink your /usr/portage with squashfs+aufs
Back to top
View user's profile Send private message
haarp
Guru
Guru


Joined: 31 Oct 2007
Posts: 517

PostPosted: Thu Dec 03, 2009 8:53 am    Post subject: Reply with quote

haarp wrote:
simple editor like gedit

Ant_P wrote:
GVim

:mrgreen:

yoshi314 wrote:
i recommend wxHexEditor ( http://wxhexeditor.sourceforge.net/ ) for hex editing needs. it's main feature is that it doesn't choke on files bigger than ram, which unfortunately cannot be said about other popular and easy to use linux hex editors :/

i've submitted a simple ebuild on gentoo bugzilla ( https://bugs.gentoo.org/show_bug.cgi?id=283994 ) if anybody is interested.

if vim has a hex-mode - it might be a second decent hex editor.

Looking good. Gonna have to try that when I get home. Thanks
Back to top
View user's profile Send private message
codestation
Tux's lil' helper
Tux's lil' helper


Joined: 09 Nov 2008
Posts: 126
Location: /dev/negi

PostPosted: Fri Dec 04, 2009 1:49 am    Post subject: Reply with quote

Another good one is MadEdit http://madedit.sourceforge.net, it support large files and you can search and edit strings in various encodings.
_________________
Just feel the code...
Back to top
View user's profile Send private message
yoshi314
l33t
l33t


Joined: 30 Dec 2004
Posts: 848
Location: PL

PostPosted: Fri Dec 04, 2009 12:14 pm    Post subject: Reply with quote

since we're on hex editors topic already, i'd like to know whether there is an hex editor that would allow me to paste a file into another file with overwrite. and we're talking about big files here.

to clarify - i'd like to paste 1mb file into 50mb file, so that the 50mb file stays 50mb, and 1mb of data at the offset i'm pasting would get overwritten.

most hex editors would insert 1mb data inside the file, but without overwriting the original file - like this (let's assume one character is 100mb)

[xxxx] - file 1 ; 40mb
[zzzzzzzzz] - file 2 ; 900mb

[zzzzxxxxzzzzz] - what happens after injecting 1 into 2 somewhere in the middle. 900+400 = 1300mb
but what i want is :
[zzzzxxxxz] - 900mb

i know we have dd for it, but it seems it kept failing horribly last time i tried .during injecting 120MB file into 3GB file, the 3GB of data exploded into 120GB :/. why?
_________________
~amd64
shrink your /usr/portage with squashfs+aufs
Back to top
View user's profile Send private message
i92guboj
Bodhisattva
Bodhisattva


Joined: 30 Nov 2004
Posts: 10306
Location: Córdoba (Spain)

PostPosted: Fri Dec 04, 2009 2:15 pm    Post subject: Reply with quote

yoshi314 wrote:
since we're on hex editors topic already, i'd like to know whether there is an hex editor that would allow me to paste a file into another file with overwrite. and we're talking about big files here.

to clarify - i'd like to paste 1mb file into 50mb file, so that the 50mb file stays 50mb, and 1mb of data at the offset i'm pasting would get overwritten.

most hex editors would insert 1mb data inside the file, but without overwriting the original file - like this (let's assume one character is 100mb)

[xxxx] - file 1 ; 40mb
[zzzzzzzzz] - file 2 ; 900mb

[zzzzxxxxzzzzz] - what happens after injecting 1 into 2 somewhere in the middle. 900+400 = 1300mb
but what i want is :
[zzzzxxxxz] - 900mb

i know we have dd for it, but it seems it kept failing horribly last time i tried .during injecting 120MB file into 3GB file, the 3GB of data exploded into 120GB :/. why?


Why dd fails is a topic for investigation, you are probably messing something up with the syntax, I'd really use dd for the task, but I think that any hex editor can do that, the real problem is "how do my hex editor handle big files?", most are horrid at that task. And nowadays, 50mb is not really a big file :)
_________________
Gentoo Handbook | My website
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 5879

PostPosted: Fri Dec 04, 2009 2:21 pm    Post subject: Reply with quote

yoshi314 wrote:
i know we have dd for it, but it seems it kept failing horribly last time i tried .during injecting 120MB file into 3GB file, the 3GB of data exploded into 120GB :/. why?

I'm going to guess it's because you gave it "bs=1K seek=900M" instead of "seek=900000" (blocks).
Back to top
View user's profile Send private message
yoshi314
l33t
l33t


Joined: 30 Dec 2004
Posts: 848
Location: PL

PostPosted: Fri Dec 04, 2009 2:21 pm    Post subject: Reply with quote

50 mb was an example.

i was actually trying to replace ~220mb of data inside of ~3GB file with contents of another file.
_________________
~amd64
shrink your /usr/portage with squashfs+aufs
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 43562
Location: 56N 3W

PostPosted: Fri Dec 04, 2009 4:10 pm    Post subject: Reply with quote

yoshi314,

dd has worked fine for me for fixing 60Gb images of corrupt vfat filesystems, when I have to fake a Volume Boot Record, only 3 disk blocks and a copy of the FAT, about 20Mb.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Unsupported Software All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum