I’ve recently wanted to edit one binary file because there was compiled in the binary a text string with a word I didn’t liked and therefore I wanted to delete. I know I can dig in the source of the proggie with grep and directly substitute my “unwatned text” there but I wanted to experiment, and see what kind of hex binary text editors are for Free OSes.
All those who lived the DOS OS computer era should certainly remember the DOS hex editors was very enjoyable. It was not rare case, where in this good old days, one could simply use the hex editor to “hack” the game and add extra player lives or modify some vital game parameter like put himself first in the top scores list. I even remember some DOS programs and games was possible to be cracked with a text editor … Well it was times, now back to current situation as a Free Software user for the last 12 years it was interesting to see what is the DOS hexeditor like alternatives for FreeBSD and Linux and hence in this article I will present my findings:
A quick search in FreeBSD ports tree and Debian installable packages list, I’ve found a number of programs allowing one to edit in console and GUI binary files.
Here is a list of the hex editors I will in short review in this article:
- hexedit
- dhex
- chexedit
- hte
- hexer
- hexcurse
- ghex
- shed
- okteta
- bless
- lfhex
1. hexedit on Linux and BSD – basic hex editor
I’ve used hexedit already on Linux so I’ve used it some long time ago.
My previou experience in using hexedit is not too pinky, I found it difficult to use on Redhat and Debian Linux back in the day. hexedit is definitely not a choice of people who are not “initiated” with hex editting.
Anyways if you want to give it a try you can install it on FreeBSD with:
freebsd# cd /usr/ports/editors/hexedit
freebsd# make install clean
…
On Debian the hexedit, install package is named the same so installation is with apt:
debian:~# apt-get –yes install hexedit
2. Hex editting with chexedit
I’ve installed chexedit the usual way from ports:
freebsd# cd /usr/ports/editors/chexedit
freebsd# make install clean…
chexedit is using the ncurses text console library, so the interface is very similar to midnight commander (mc) as you see from below’s screenshot:
Editting the binary compiled in string was an easy task with chexedit as most of the commands are clearly visible, anyways changing a certain text string contained within the binary file with some other is not easy with chexedit as you need to know the corresponding binary binary value representing each text string character.
I’m not a low level programmer, so I don’t know the binary values of each keyboard character and hence my competence came to the point where I can substitute the text string I wanted with some unreadable characters by simply filling all my text string with AA AA AA AA values…
chexedit on Debian is packaged under a deb ncurses-hexedit. Hence to install it on Deb run:
debian:~# apt-get –yes install ncurses-hexedit
…
Further on the binary to run chexedit on binary contained within ncurses-hexedit is:
debian:~# hexeeditor
3. Hex Editting on BSD and Linux with hte
Just after trying out chexedit, I’ve found about the existence of one even more sophisticated hexeditor console program available across both FreeBSD and Linux.
The program is called hte (sounds to me a bit like the Indian word for Elephant “Hatti” :))
hte is installable on Debian with cmd:
debian:~# apt-get install ht
On FreeBSD the port name is identical, so to install it I execed:
freebsd# cd /usr/ports/editors/hte
freebsd# make install clean
…
hte is started on Debian Linux (and presumably other Linux distros) with:
$ hte
On FreeBSD you need to run it with ht command:
freebsd# ht
You see how hte looks like in below screenshot:
ht has the look & feel like midnight commander and I found it easier to use than chexedit and hexeditor
4. hexer VI like interface for Linux
As I was looking through the available packages ready to install, I’ve tried hexer
debian:~# apt-get install –yes hexer
…
hexer does follow the same standard commands like VIM, e.g. i for insert, a for append etc.
It was interesting to find out hexer was written by a Bulgarian fellow Petar Penchev 🙂
(Proud to be Bulgarian)
http://people.freebsd.org/~roam/ – Petar Penchev has his own page on FreeBSD.org
As a vim user I really liked the idea, the only thing I didn’t liked is there is no easy way to just substitute a string within the binary with another string.
5. hexcurse another ncurses library based hex editor
On Deb install and run via:
debian:~# apt-get –yes install hexcurse
debian:~# hexcurse /usr/bin/mc
hexcurse is also available on FreeBSD to install it use cmd:
freebsd# cd /usr/ports/editors/hexcurse
freebsd# make install clean
….
To access the editor functions press CTRL+the first letter of the word in the bottom menu, CTRL+H, CTRL+S etc.
Something I disliked about it is the program search is always in hex, so I cannot look for a text string within the binaries with it.
6. ghex – Editting binary files in graphical environment
If you’re running a graphical environment, take a look at ghex. ghex is a gnome (graphical hex) editor.Installing ghex on Debian is with:
debian:~# apt-get –yes install ghex
….
To run ghex from terminal type:
debian:~# ghex2
To install ghex on FreeBSD (and I assume other BSDs), install via port:
freebsd# cd /usr/ports/editors/ghex
freebsd# make install clean
Gnome hex editor have plenty of tools, useful for developers to debug binary files.
Some nice tools one can find are under the the menus:
Windows -> Character Table
This will show a complete list of each keyboard sent character in ASCII, Hex, Decimal, Octal and Binary
Another useful embedded tool in ghex is:
Windows -> Type Convertion Dialog
Note that if you want to use the Type Convertion Dialog tool to find the representing binary values of a text string you will have to type in the letters one by one and save the output within a text file and later you can go and use the same editor to edit the text string within the binary file you like.
I’m not a programmer but surely for programmers or people who want to learn some binary counting, this 2 ghex edmebbed tools are surely valuable.
To conclude even though there are plenty of softwares for hex editting in Linux and BSD, none of them is not so easy to use as the old DOS hexdedit tool, maybe it will be a nice idea if someone actually rewrites the DOS tool and they package it for various free operating systems, I’m sure many people will find it helpful to have a 1:1 equivalent to the DOS tool.
7. Shed pico like interfaced hex editor
For people, who use pico / nano as a default text editor in Linux shed will probably be the editor of choice as it follows the command shortcuts of picoOn Deb based distros to install it run:
debian:~# apt-get install –yes shed
…
Shed has no BSD port as of time of writting.8. Okteta a KDE GUI hex editor
For KDE users, I found a program called okteta. It is available for Deb based Linuxes as deb to install it:
debian:~# apt-get –yes install okteta
As of time of writting this article there is no okteta port for BSDs.
Okteta has plenty of functions and even has more of a functions than ghexedit. Something distinctive for it is it supports opening multiple files in tabs.
9. lfhex a large file text editor
lfhex is said to be a large (binary) file text editor, I have not tested it myself but just run it to see how it looks like. I don’t have a need to edit large binary files too, but I guess there are people with such requirements too 🙂
To install lfhex on Debian:
debian:~# apt-get install –yes lfhex
lfhex has also a FreeBSD port installable via:
freebsd# cd /usr/ports/editors/lfhex
freebsd# make install clean
10. Bless a GUI tool for editting large hex (binary) files
Here is the description directly taken from the BSD port /usr/ports/editors/bless
Bless is a binary (hex) editor, a program that enables you to edit files asa sequence of bytes. It is written in C# and uses the Gtk# bindings for theGTK+ toolkit.
To install and use ot on deb based Linuxes:
debian:~# apt-get install –yes bless
….
On BSD installation is again from port:
freebsd# cd /usr/ports/editors/bless
freebsd# make install clean
….
Something that makes bless, maybe more desirable choice for GUI users than ghex is its availability of tabs. Opening multiple binaries in tabs will be useful only to few heavy debuggers.
11. Ghextris – an ultra hard hacker tetris game 🙂
For absolute, hacker / (geeks), there is a tetris game called ghextris. The game is the hardest tetris game I ever played in my life. It requires more than regular IQ and a lot of practice if you want to become really good in this game.
To enjoy it:
debian:~# apt-get –yes install ghextris
Unfortunately there is no native port of ghextris for BSD (yet). Anyhow, it can be probably run using the Linux emulation or even compiled from source.
Well that’s all I found for hexedit-ing, I’ll be happy to hear if someone can give me some feedback on his favourite editor.