Well I'm not exactly an expert on obfuscation, the general principle would be to (ab)use the features of Perl as much as possible. Some of the more interesting ones I've seen come from abusing the delimeters for subsitute and match operators. japhy gives some good tips in japhy's Obfuscation Review. Also of course, you should remove uneeded whitespace and the like. Hope this gives you a starting point.
cephas
| [reply] |
If you look at the results of the latest Obfuscated Perl Contest,
you'll notice that all the entrants were required to submit not only
their code, but a "solution" file as well. With these, you
can hear from the authors what each one does,and how it
does it. My entry and a few other are
on this site as well.
| [reply] |
| [reply] |
I love obfuscation. These obfuscations aren't Perl, I've yet to do Perl obfuscation. Obfuscation comes into it's own using, what other languages calumny as "side-effects" and Perl folk know as 'features'.
I made a confusing method to produce a Just Another ... for each language. I found the suitability of each language to the job was telling and I tried to have fun with the language's idiom along the way.
The method is pretty simple:
- Use a=a^b, b=a^b, a=a^b to juxtapose two variables; I perform a=a^b, b=a^b to generate an XOR'd value.
- Use a rot5 * to scramble the key to produce the string
- By XORing each element of the two above you get the phrase. (I chose job titles to reflect my view of the attitude prevailent in the practicioners of each language.)
When I wrote these, a Java / Perl war was ongoing at work. Not wanting to pick sides (why reduce the chance of a good scrap? :). I used Mutt's mailhooks, to "tune my subtle song". For posterity here are my sig lines (Please don't -- me for referring to other languages, I found the conciseness rang out from these. Yeah I know the Java is a tad long winded but.....)
# Frank Booth, AHEM DIGITAL (www.ahem.com) tel:(XXX) XXXX XXXX
$_='Ozxy%fstymjw%';s:.:chr((ord$&)-5):geo;split//;print$_,map{
$_[$_]^chr((26,16,1,24,0,9,15,12,31,13,23,92,42)[$_])}(0..$#_)
/*Frank Booth, AHEM DIGITAL (www.ahem.com) tel: +XX (XXX) XXXX XXXX */
main(){char l[0x1b]={"Ozxy%fstymjw%"};int i=0,I[13]={9,85,3,6,79,6,28,
14,25,5,0,0,14};for(;13-i;l[13+i]=(l[i]-=5)^I[i++]);printf("%s\n",l);}
//Frank Booth, AHEM DIGITAL (www.ahem.com) tel: +XX (XXX) XXXX XXXX
import java.*;public class S{String a=new String(s("Ozxy%fstymjw%O"
));int[] b={43,3,18,84,68,4,24,10,24,7,21,23,82,100}; public static
void main(String[]S){S s=new S();System.out.print(s);}public static
String s(String b){StringBuffer w=new StringBuffer(b);for(int i=0;i
<0xe; w.setCharAt(i,(char)(w.charAt(i++)-5)));return w.toString();}
public String s(){StringBuffer w=new StringBuffer(a);for(int i=0;i<
w.length();w.setCharAt(i,(char)(b[i]^(int)w.charAt(i++))));return w
.toString();}public String toString(){return a+s()+"\n";}}/* :-) */
<!-- Frank Booth, AHEM DIGITAL (www.ahem.com) tel:(XXX) XXXX XXXX>
<html><body bgcolor=#666666 text=#CC9900>Just
another™ <b>H<!-
->TML </b>writer </body></html>
(The company name has been changed to protect the innocent, namely me ;0).
* Okay it's not a true rot routine, but I think this is: perl -pe's/([a-m])|[n-z]/chr(($1?13:-13)+ord$&)/ogie'
--
Brother Frankus. | [reply] [d/l] [select] |
/([a-m])|[n-z]/chr(($1?13:-13)+ord$&)/ogie
I know this handles capitals, but isn't it a slight
overcomplication of what is really:
tr/a-z/n-za-m/
Or is that part of the obfuscation? Sorry if I've missed
the point.
--
Brother Marvell
| [reply] [d/l] [select] |