Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is really, really, cool. I'm going to desecrate it by deobfuscating it merely because it gave me a deeper appreciation of how cool it is (and because I feel somewhat clever for being able to).

First, let's make it a little more readable...

use strict; $\=$/; $_=''; s//#?=>$":}\~>\\!;/; $/ =~ s//s{;};$")!{$"\\:<_!;/e; y{%*-.$'&(#-<}{@-~}s; { y(;-?)[\012r-{)!]s; y/T-_/`-|/; y/{-~/l-}/; redo if s/!/Y</g } print
The only changes other than adding whitespace are that I turned the literal newline in the first translation in the bare block into an escaped octal (\012), and I changed a bunch of substitution and transliteration and quote delimiters. Oh yeah, and I inverted the condition at the end of the block.

Now, taking that bad boy line by line...

use strict; $\=$/; $_='';
These are boring: we set the output record separator to something approximating a newline (platform dependent) so we get a newline at the end of the final printout (also achievable using the -l switch, but less obfuscated that way :-), and we set $_ to nothing in a strict compliant manner.
s//#?=>$":}\~>\\!;/;
This sets $_ to something interesting--remember, $" is a space for most purposes (says perlvar) so $_ is now "#?=> :}\~>\!;".
$/ =~ s//s{;};$")!{$"\\:<_!;/e;
is a mean, nasty, dirtyminded version of
s/;/$")!{$"\\:<_!/;
which really means
substr($_,-1)= $". ')!{' . $" . '\:<_!';
or
substr($_,-1)= ' )!{ \:<_!';
Which, in total, means that the first few lines break down to:
$_ = "#?=> :}~>\! )!{ \:<_!"
And a glimmer of where we're going seems to appear. (Note: we also screwed up our input record separator back there by prepending a "1" to it, owing to the sucessful subsitution inside the substitution, but we don't care.)

Update: killinrax points out that I missed this one: there was originally a literal newline in the left side of the substitution, so we've actually changed it to 1, rather than prepending a 1. D'oh!

Now, it gets interesting.

y{%*-.$'&(#-<}{@-~}s;
To make this easier to read, let's put in ASCII escapes:
y{%\052-\056$'&(\043-\074}{\100-\176}s;
Now, the first few things on the left side don't appear in $_, so we can take them out. The actual sequence on the left side is "%*+'-.$'&(" and none of those appears in $_, so we take out those 9 characters and the first nine on the right side, and we have
y{\043-\074}{\112-\176}s;
In fact, when we take out the parts that never get applied, what we really have is
y/#):</JPac/;
and $_ now reads "J?=> a}~>\! P!{ \ac_!".

Now we enter a bare block, which we will redo until there are no more !'s in $_ (which means we go through it twice, since that global substitution only succeeds once).

y(;-?)[\012r-{)!]s;
means
tr/\073-\077/\012r-{)!/s;
but applying the same principles we did above, we get
tr/\074-\077/r-{)!/s;
and then (since the right side is much longer than the left)
tr/\074-\077/r-u/s; or tr(<=>?)(rstu);
Which leaves us (the first time) with "Just a}~t\! P!{ \ac_!" as our string.

Next we have two very similar transliterations, which tranlate to

y/T-Z[\\]^_/`a-z{|/; y/{|}~/l-z{|}~/;
of which the only useful parts are going to be
y/Y\\_/ehk/; y/{}~/lno/;
This leaves us with "Just anoth! P!l hack!", to which we apply the substitution
s/!/Y</;
Then (since it succeeds) we redo the block, starting with "Just anothY< PY<l hackY<" and ending with "Just another Perl hacker". Since there are no more !s to apply the substitution to, it fails, and we exit the block, and print, getting our answer followed by a newline, because we set the output record separator to "\n" (assuming we're in Unix) way back at the top--remember that? :-)

So if we put it back together, the minimalist version (doing every operation, in almost the same order) is

#!/usr/bin/perl -lw use strict; $_=''; s//#?=> :}\~>\\!;/; substr($_,-1)= ' )!{ \:<_!'; y/#):</JPac/; s/!/Y</g; y(<=>?)(rstu); y/Y\\_/ehk/; y/{}~/lno/; print;
And the funny thing is, it's still almost impossible to read! All in all, an awesome obfu!



If God had meant us to fly, he would *never* have give us the railroads.
    --Michael Flanders


In reply to Re: Line Noise (deobfuscation attempt) by ChemBoy
in thread Line Noise by kilinrax

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-03-28 22:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found