Reverse an xxd hexdump

4

1

Given an xxd hexdump such as this one:

00000000: 1f8b 0808 4920 2258 0003 7069 6c6c 6f77  ....I "X..pillow
00000010: 2e74 7874 00d3 d707 8218 10d0 2799 c545  .txt........'..E
00000020: ba96 41a1 994c 7d60 d650 d53c 44a3 8a22  ..A..L}`.P.<D.."
00000030: cd43 34aa 28d2 3c44 a38a 22cd 4334 aa28  .C4.(.<D..".C4.(
00000040: d20c 00fd 512d 46b8 0500 00              ....Q-F....

Reverse it to produce the original input:

I "Xpillow.txt����'��E��A��L}`�P�<D��"�C4�(�<D��"�C4�(�
                                                      �Q-F�

(This is only an approximation of the original input)

You do not need to expand to shellcodes.

Dupe alert

This is not a duplicate of the other xxd hexdump challenge because this one does not to be expanded to shellcodes.

Rules

  • You may not use external programs that parse hexdumps (such as xxd).
  • Standard loopholes apply
  • This is , smallest code wins.

dkudriavtsev

Posted 2016-11-09T03:49:55.703

Reputation: 5 781

Question was closed 2016-11-09T08:41:35.753

There's more than one previous xxd question. – Peter Taylor – 2016-11-09T08:42:31.343

Answers

2

V, 27 bytes

ÎdW40|D
Í üî
Ó../<C-v><C-v>x&
éiD@"

Try it online!

Note that <C-v> represents the unprintable character 0x16.

Explanation

This answer is pretty fun because it's about modifying the input into V code and then executing that code. I'll explain each command one at a time

Î                " On every line:
 dW              "   Delete a word
   40|           "   Move to the 40th column
      D          "   Delete everything after this

Í                " Remove all occurrences of
                 " A space 
  üî             " or a newline

Now the buffer looks like this:

1f8b080849202258000370696c6c6f772e74787400d3d707821810d02799c545ba9641a1994c7d60d650d53c44a38a22cd4334aa28d23c44a38a22cd4334aa28d20c00fd512d46b8050000

The command to insert a character by its hex value is

<C-v>x<hex-value>

Here is where we start transforming it into actual V code.

Ó                " Replace
 ..              "   Two characters
   /             "   with
    <C-v><C-v>x  "   the text "<C-v>x"
               & "   And the two characters we just matched

<C-v>x1fi<C-v>x8bi<C-v>x08i<C-v>x08i<C-v>x49...

But the command has to be in insert mode. So we insert an 'i' at the beginning.

éi               " Insert an 'i'
  D              " Delete this line
   @"            " And evaluate it as V code

James

Posted 2016-11-09T03:49:55.703

Reputation: 54 537