Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

I'm amusing myself trying to obfuscate a little script ...

by hoaf (Novice)
on Sep 01, 2006 at 22:02 UTC ( [id://570842]=obfuscated: print w/replies, xml ) Need Help??

... that formats a text file for, um, legibility.

Just cat a file through it and voila! It's pretty.

#!/usr/local/bin/perl -n @x = ( { Begin => "{", End => "}" }, "(?:Attribute|Motion|Transform|Wo +rld|Frame)" ); $i-- if(/^\s*$x[1]End/ && $i); /^\s*\#/?s/^\s*//:s/^\s*/" "x(4*$i)/e; s/^(\s*$x[1](Begin|End).*)$/$1.(m|\#[\{\}]$|?"":" #$x[0]{$2}")/e; print; $i++ if(/^\s*$x[1]Begin/);
Any ideas? I figure that I should be able to do something that combines the two regular expression lines, then do something else to mask the data, but I'm new to the whole obfuscation thing. :^)

Thanks!

hoaf

Replies are listed 'Best First'.
Re: I'm amusing myself trying to obfuscate a little script ...
by dbwiz (Curate) on Sep 02, 2006 at 09:47 UTC
Re: I'm amusing myself trying to obfuscate a little script ...
by chargrill (Parson) on Sep 03, 2006 at 06:39 UTC

    Along those lines, everything I learned about obfuscating perl code, I learned from here.

    And I took notes.

    And to make sure I could find them again, I added them to my home node. Much like some of the other regular obfuscators have.

    Take a gander through the pages of [id://Obfuscated Code] and check out the home nodes of some of the authors. You're likely to find a wealth of information and ideas about obfuscating code.

    Also, DE-obfuscating some of the higher-ranked obfuscations REALLY helps in understanding how to create jems of your own. Try a little perl -MO=Deparse, adding your own whitespace, etc... and you'll start to gain your own insight.



    --chargrill
    $,=42;for(34,0,-3,9,-11,11,-17,7,-5){$*.=pack'c'=>$,+=$_}for(reverse s +plit//=>$* ){$%++?$ %%2?push@C,$_,$":push@c,$_,$":(push@C,$_,$")&&push@c,$"}$C[$# +C]=$/;($#C >$#c)?($ c=\@C)&&($ C=\@c):($ c=\@c)&&($C=\@C);$%=$|;for(@$c){print$_^ +$$C[$%++]}

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: obfuscated [id://570842]
Approved by shenme
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-16 16:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found