note
chargrill
<p>Clever! [liverpole]++</p>
<p>Here's a crack at deobfuscating it:</p>
<spoiler>
<p>First things first, fix that pesky whitespace.</p>
<c>
@= = "GqwpWrlplbnTbnpDwghav" =~ /.../g;
@+ - map { +map ++$_, @= } + $= ... 3**7;
@' = split /(?=[A-Q])/, join $*, @=;
die +qq+ @'$/+
</c>
<p>Clean up a few things, simplifying where possible:</p>
<c>
@= = "GqwpWrlplbnTbnpDwghav" =~ /.../g;
@+ - map { map ++$_, @= } + 60 ... 2187;
@' = split /(?=[A-Q])/, join $*, @=;
die qq" @'$/"
</c>
<p>But there's still those extra "<c>+</c>"'s and "<c>-</c>"'s in that second line... Well, thanks to that hint about [blazar]'s post, I think I know what's going on, so let me try something...</p>
<c>
for( qw( Gqw pWr lpl bnT bnp Dwg hav ) ){
my $num = $_;
#for( 60 ... 2187 ){ $num = ++$num }
# the above changed to the below to "deobfuscate" the deobfuscation.
for( 60 .. 2187 ){
$num++;
}
push( @array, $num );
}
print "$_\n" for @array;
OUTPUT:
Jus
tAn
oth
erP
erl
Hac
ker
</c>
<p>Success!</p>
<p>So here's what's going on: line 1 sets the <c>@=</c> array to some values, which happen to be the equivalent of "<c>( 'Gqw', 'pWr', 'lpl', 'bnT', 'bnp', 'Dwg', 'hav' )</c>".</p>
<p>Line 2 cleverly "re-maps" (using a <c>map</c> inside a <c>map</c>, nonetheless) the <c>@=</c> array by <c>++</c> "incrementing" every value 2,127 times - the exact number of times required to "increment" <c>Gqw</c> to <c>Jus</c><sup>*</sup>. The preceeding <c>@+ -</c> just adds a little line noise, as it doesn't seem to affect the final result if removed. Same with the <c>+ </c> in front of <c>$=</c> (which, incidentally, (as documented ;) defaults to 60).</p>
<p>Line 3 joins <c>@=</c> by the value of <c>$*</c>, which is (as documented ;) undefined, giving us "JustAnotherPerlHacker", which is then <c>split</c> in between a lowercase character and a following uppercase character thanks to the zero width positive look-ahead assertion <c>/(?=[A-Q])/</c>, and the resulting list from the <c>split</c> is stored in <c>@'</c>.</p>
<p>Finally, with a few <c>+</c> cluttering things up (and used as <c>qq</c>'s quoting character for interpolating the values of the variables in the string given to <c>die</c>), you 'print' the contents of <c>@'</c>, trusting that (as documented ;) the default value of a single space for <c>$"</c> hasn't changed, and <c>$/</c> also defaults (as documented ;) to a newline.</p>
<p><sup><b>*</b></sup> (The bit of <c>perldoc perlop</c> that details this is: <i>
The auto-increment operator has a little extra builtin magic to it. ... If, however, the variable has been used in only string contexts since it was set, and has a value that is not the empty string and matches the pattern "<c>/^[a-zA-Z]*[0-9]*\z/</c>", the increment is done as a string, preserving each character within its range, with carry ...</i>. Incrementing "Gqw", and you get "Gqx")
</spoiler>
<p><b>Update:</b> Cleared up the "obfuscated deobfuscation" as noted by [ysth], though the original test was written to most closely resemble (from at least my point of view) the original obfuscated code. Apologies for any confusion. Also added a little extra explanation (with reference to associated documentation).</p>
<!-- Node text goes above. Div tags should contain sig only -->
<div class="pmsig"><div class="pmsig-474411">
<br><br>
--chargrill
<hr>
<font size=2>
<code>
s**lil*; $*=join'',sort split q**; s;.*;grr; &&s+(.(.)).+$2$1+; $; =
qq-$_-;s,.*,ahc,;$,.=chop for split q,,,reverse;print for($,,$;,$*,$/)
</code>
</font>
</div></div>
585310
585310