coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hex to ASCII conversion?


From: Bob Proulx
Subject: Re: Hex to ASCII conversion?
Date: Fri, 26 Dec 2014 17:13:15 -0700
User-agent: Mutt/1.5.23 (2014-03-12)

Bernhard Voelker wrote:
> Bob Proulx wrote:
> I only know of the double-folded printf way via octal:
> 
>   $ env printf $(env printf '\\%03o' 0x48 0x61 0x70 0x70 0x79)
>   Happy

Oh, that is clever!  And I got a hint from another friend that I
shared that question with too.  I learned something about printf that
I hadn't known.  I hadn't grok'd that it would interpret all character
escape sequences.  Of course it is obvious that it does but I hadn't
internalized it.  You and my friend George both gave me the same hint
back.  As they say, great minds think alike!

But that means it can be done simply by having printf read the escape
sequence.

  $ printf "\x48\x61\x70\x70\x79\n"
  Happy

Aha!  And for me there was the moment of insight that I was looking to
acquire.  That is the syntax!

It is quite easy by an endless number of different ways to reformat
the hex codes so that printf can manage it now.  The original was a
reverse DNS lookup return so had dots separating them.

  $ echo 48.61.70.70.79.20 | while read -d. c; do printf "\x$c";done;echo
  Happy

And if anyone is interested in the reason I wanted this there was a
very nice hack that floated around the Internet this Christmas.  It
was actually broken yesterday which is why I didn't mention it in my
previous message.  It would have been cruel to mention it when it
wasn't working.  But I see they have it back working again today!
Yay!  It is fun.  It is best to run with a wide terminal 100+ or
wider.  If you follow the output closely and with the hex hints above
it will lead you to the authors of the hack.

  traceroute -m255 xmas.futile.net

Enjoy!
Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]