Solved

vim xxd add/remove bytes

Posted on 2013-01-24
3
936 Views
Last Modified: 2013-02-11
Before I give up on vim/xxd as my hex editor of choice, does anyone here know of a reliable way to add or remove bytes from a file? Most of the time, if I try to add anything that changes the length of the file, it blows up pretty badly. The way xxd actually uses the offsets, it seems unlikely. (Adding and removing at the end isn't too tough).

I wrote a small executable that does just about the same thing as xxd except it lets you change the file size; but before I bother making it more robust, I thought I'd make sure xxd can't do what I want.
0
Comment
Question by:TommySzalapski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 38817930
Yes, the offsets are going to break it every time.  I think the only way is to use the -p option to do a plain hexdump, though that does lose the useful ASCII representation.

Or add an "ignore offset" option to "xxd -r"!
0
 
LVL 37

Author Comment

by:TommySzalapski
ID: 38820906
Hah, that's true. I could just modify xxd. It's probably faster to write my own though since it's such a simple thing. I'll have to check the -p option Monday and see if that does the trick.
0
 
LVL 37

Author Comment

by:TommySzalapski
ID: 38876786
Oops. Forgot I had this out there. Haven't needed hex editing in a while.

Adding the -p does fix it. It does make it lots harder to read though, so I'll keep my little app around for personal use. Thanks for the tip.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
postfix start error! 9 86
apache does not start on Kali linux 4 102
change password for AD retention policy and Citrix 2 89
php mail() send emails but the message is lost 4 33
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question