开发者

What does this perl line from a "bleached" file do?

I have some perl files which have been "bleached" (don't know if it was from ACME::Bleach, or something similar). Not being very fluent in perl, I'd like to understand what the one-liner that starts the file does to decode the whitespace that follows:

$_=<<'';y;\r\n;;d;$_=pack'b*',$_;$_=eval;$@&&die$@;$_

The rest of the file is whitespace characters, and the file is executable by itself (it's placed in a /bin directory).

[Solution], thanks to @JB.

The开发者_JAVA百科 pack portion of this seems the most complex, and it took me a while to notice what was going on. Pack is taking the LSB only of every 8 characters, and unpacking that as a big-endian character in binary. Tabs hence become '0's, and spaces become '1's.

    '\t\t   \t  ' => '#'
in binary:
    00001001 00001001 00100000 00100000 00100000 00001001 00100000 0100000
every LSB:
    1 1 0 0 0 1 0 0
convert from from big-endian format:
    0b00100011 == 35 == ord('#')


  • $_ = << ''; reads the rest of the file into the accumulator.
  • y;\r\n;;d; strips carriage returns and line feeds.
  • $_ = pack 'b*', $_; converts characters to bits in $_, LSB first.
  • $_ = eval; executes $_ as Perl code.
  • $@ && die $@; $_ handles exceptions and the return code gracefully.


You can use unbleach.pl to remove bleaching, if that's what you're really trying to do.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜