On windows machine there are lots of third party editors available to edit a binary file. I belive there should be some thing similer buildin in the *nix systems as well. any idea how can i edit a binary file on unix?
You can also try ghex2 GNOME utilities. This give you the automated hex-to-ASCII on the side, as well as the various character/integer decodes at the bottom.
(source: googlepages.com)
In vim You can type :%!xxd to turn it into a hexeditor. :%!xxd -r to go back to normal mode. xxd is shipped in a vim installation.
See here for some remarks about editing binary files with vim (boils down to :set binary to avoid trouble, use only the "R" or "r" command to change text, don't delete characters).
If You are an Emacs fan, see here for a guide on how to edit a binary file with Emacs.
There are much more hexeditors on Linux/Unix....
I use hexedit on Ubuntu
sudo apt-get install hexedit
Bless is a high quality, full featured hex editor.
It is written in mono/Gtk# and its primary platform is GNU/Linux. However it should be able to run without problems on every platform that mono and Gtk# run. Main Features Bless currently provides the following features:
- Efficient editing of large data files and block devices.
- Multilevel undo - redo operations.
- Customizable data views.
- Fast data rendering on screen.
- Multiple tabs.
- Fast find and replace operations.
- A data conversion table.
- Advanced copy/paste capabilities.
- Highlighting of selection pattern matches in the file.
- Plugin based architecture.
- Export of data to text and html (others with plugins).
- Bitwise operations on data.
- A comprehensive user manual.
I used to use bvi.
I am developing hexvi to overcome :%!xxd
and bvi
's limitations.
hexvi
Features
- vim-like keybindings and commands
- going to specific offsets
- inserting, replacing, deleting
- searching for stuff (PCRE regexes)
- everything is a command, and can be mapped in
hexvirc
- color schemes
- support for large files
- support for multiple files (via tabs)
- Python so the entry level to hack around should be lower than C's
- CLI through and through
Cons
- as of March 2016, it's alpha so features are missing, but I'm working on those:
- file saving
- undo/redo
- command history
- visual selection
- man page
- no autocomplete
bvi
Features
- vim-like keybindings and commands
- going to specific offsets
- inserting, deleting, replacing
- searching for stuff (text and hex)
- undo/redo
- CLI through and through
Cons
- regarding its vim capabilities - unfortunately, it understands only the most
basic things and definitely needs more love in this regard (example: doesn't
understand
:wq
, but understands:w
and:q
) - no visual selection support whatsoever
- no tab/split screen support
- crashes often
- no support for large files
- no command history
- no autocomplete
I like KHexEdit, which is part of KDE
Its "Windows style" UI is probably quite quick to learn for most people (compared to Vim or Emacs anyway :)
There's lightweight binary editor, check hexedit. http://www.linux.org/apps/AppId_6968.html. I tried using it for editing ELF binaries in Linux at least.
I made wxHexEditor, it's open sourced, written with C++/wxWidgets GUI libs and can open even your exabyte sized disk!
Just try.
As variant, you can use radare2:
> r2 -w /usr/bin/ls
[0x004049d0]>V
[0x004049d0 14% 1104 (0x0:-1=1)]> x @ entry0
- offset - | 0 1 2 3 4 5 6 7 8 9 A B C D E F| 0123456789ABCDEF
0x004049d0 |31ed 4989 d15e 4889 e248 83e4 f050 5449| 1.I..^H..H...PTI
0x004049e0 |c7c0 103a 4100 48c7 c1a0 3941 0048 c7c7| ...:A.H...9A.H..
0x004049f0 |202a 4000 e877 dcff fff4 660f 1f44 0000| *@..w....f..D..
0x00404a00 |b807 e661 0055 482d 00e6 6100 4883 f80e| ...a.UH-..a.H...
0x00404a10 |4889 e576 1bb8 0000 0000 4885 c074 115d| H..v......H..t.]
0x00404a20 |bf00 e661 00ff e066 0f1f 8400 0000 0000| ...a...f........
0x00404a30 |5dc3 0f1f 4000 662e 0f1f 8400 0000 0000| ]...@.f.........
0x00404a40 |be00 e661 0055 4881 ee00 e661 0048 c1fe| ...a.UH....a.H..
0x00404a50 |0348 89e5 4889 f048 c1e8 3f48 01c6 48d1| .H..H..H..?H..H.
0x00404a60 |fe74 15b8 0000 0000 4885 c074 0b5d bf00| .t......H..t.]..
0x00404a70 |e661 00ff e00f 1f00 5dc3 660f 1f44 0000| .a......].f..D..
0x00404a80 |803d c19b 2100 0075 1155 4889 e5e8 6eff| .=..!..u.UH...n.
0x00404a90 |ffff 5dc6 05ae 9b21 0001 f3c3 0f1f 4000| ..]....!......@.
0x00404aa0 |bf10 de61 0048 833f 0075 05eb 930f 1f00| ...a.H.?.u......
0x00404ab0 |b800 0000 0048 85c0 74f1 5548 89e5 ffd0| .....H..t.UH....
0x00404ac0 |5de9 7aff ffff 662e 0f1f 8400 0000 0000| ].z...f.........
0x00404ad0 |488b 0731 d248 f7f6 4889 d0c3 0f1f 4000| H..1.H..H.....@.
For details about how work in visual mode you can read here
I've had good experience with wxHexEditor... just make sure if you are hex-editing a drive you do it via the menu
Devices -> Open Disk Device -> SCSI Disk Drive Partition #_N_
来源:https://stackoverflow.com/questions/839227/how-to-edit-binary-file-on-the-unix-systems