Reply to comment

bin2file

After writing bindump I thought: "Ok... and now?"
Now I have the opportunity to redirect bindump's output in a text file and _manage every single bit_ of _every file_.

But... after having modified the bits of the text file, what could I do with them?
Actually nothing! |-:
So the second step starts: bin2file.

Bin2file takes in input a sequence of bits and it writes the sequence (byte per byte) in a new file (specified with -w flag before). The new file is opened in append mode, this will be useful later.
The bit's sequence is read in little-endian byte order (mind it!).

Let's make an example. At first I use bindump on a file, then I extract bits and I send them into bin2file to recreate the identical file:

eddy22@lisbeth:~/myprog/bindump$ md5sum lena.bmp 
866bc20f9bbcfbdd038d0e3af0b0cfeb  lena.bmp
eddy22@lisbeth:~/myprog/bindump$ sha1sum lena.bmp 
480bbcf4e62533f7b218587d72bf1d66ef99f060  lena.bmp
eddy22@lisbeth:~/myprog/bindump$ ./bindump lena.bmp | cut -c10-80 | xargs ./bin2file
-w new_lena.bmp
eddy22@lisbeth:~/myprog/bindump$ md5sum new_lena.bmp 
866bc20f9bbcfbdd038d0e3af0b0cfeb  new_lena.bmp
eddy22@lisbeth:~/myprog/bindump$ sha1sum new_lena.bmp 
480bbcf4e62533f7b218587d72bf1d66ef99f060  new_lena.bmp

Now I modify "on the fly" each bit by 0 to 1 from 200000's bytes to 299999, from 400000 to 499999 and from 600000 to 699999.
In RGB the value 11111111 11111111 11111111 is white.

eddy22@lisbeth:~/myprog/bindump$ ./bindump lena.bmp | sed -e '/^00[246]..... /s/0/1/g' |
cut -c10-80 | xargs ./bin2file -w lena01.bmp

the result is:

Lena 01

In the next example I change each bit by 0 to 1 and viceversa from 200KB to 600KB:

eddy22@lisbeth:~/myprog/bindump$ ./bindump lena.bmp | sed -e '/^00[2-6]..... /y/01/10/' |
cut -c10-80 | xargs ./bin2file -w lena02.bmp

Lena 02

Other funny things with bindump and bin2file caming soon on this site! (-:

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.