Thursday, May 8, 2008

Recover data from hexdump output in the console

It happens sooner or later to delete some blocks of a disk by a wrong "dd" executed as root... :-) Ok, if you've been so lucky to "hexdump -v -C" those blocks to the console before you can just copy&paste the dump-ed ouput and send it to the standard input of this one-liner perl script:
 
map { map { print pack('H[2]', $_) } split(/\s+/, $1)
if ((/^\w+\s+((\w{2}\s+){1,16})\s+|.*$/i) && ($1)) } 
 
The corresponding binary data can be taken from the standard output. That's it! :-)

No comments:

Post a Comment