0

Desired output of something like "xxd -b file":

00000000 00000000 00000000 00000000

00000000 00000000 00000000 00000000

..etc

then followed by

plaintext here

Actual output:

00000000 00000000 00000000 00000000 plai

00000000 00000000 00000000 00000000 n te

00000000 00000000 00000000 00000000 xt h

Hopefully communicates what I'm getting at. This is just a minor issue I encountered doing a beginner CTF, but it felt very off and sloppy to copy paste just one line at a time, since highlighting treats the actual information I want in the right column as just part the array of text. I've tried a few different flags with xxd and read the man page, but I have not found an option that outputs the plaintext by itself or in a manner that is more readable. Is there another tool I should be using, ideally one that is common on most linux distros?

Tyk
  • 68
  • 9

1 Answers1

1

Process the file twice, once by xxd, once by cat. Use cut to remove the plaintext from the xxd output:

xxd -b file | cut -d' ' -f1-8 ; cat file

Use 2-8 if you aren't interested in the positions.

choroba
  • 231,213
  • 25
  • 204
  • 289
  • I guess there is some things to explore here but doing this, with or without the -b flag, returns a jumbled mess that isn't readable nor contains the plaintext anywhere. – Tyk Feb 05 '21 at 00:08
  • 1
    If `cat file` outputs a jumbled mess, your file is binary, and the "plaintext" isn't text, it's the jumbled mess itself. Seems like your question is lacking important context, like how you're filtering the section of `file` you want. – Leonardo Dagnino Feb 05 '21 at 00:30
  • cat file works fine, xxd -b file outputs one that's semi-human readable but challenging to copy-paste, the issue is that whatever happens after the pipe turned into a mess that's not human readable. – Tyk Feb 11 '21 at 13:20