DevNetwork Obfuscated PHP Contest 2006

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

for some reason nobody used __halt_compiler() ;/
User avatar
hydroxide
Forum Commoner
Posts: 77
Joined: Mon Jun 05, 2006 9:53 am

Post by hydroxide »

Here's an interesting design example, to perhaps give contestants a good idea as to what wins obfuscated code contests. (This entry won best obfuscated game in the obfuscated C '05 contest.)

Code: Select all

#define    F getchar())
 #define H(z)*n++=z;
       #include        <setjmp.h>
    #define v main(0,0,0
           #define Z while(
                                                 #define _ if(
#define o(d)(S=63,u[l]=0,l[d]=6^e,q=1e4>v,0),l[d]=0,u[l]=e^6,S=b,q)
#define I(H,n) { _ r=l[x=H],!r|(r^e)<-1){ _ j=u[l],-7==r|6==r\
){ n; e=~e; return 1e5-443*f; } u[l]=0,t=j+1,i=j-1; _!i&89<\
x)i=j,t=6; _-1==t&30>x)t=j,i=-7; Z++i<t){ d =0; S&= 63; \
a=((j^e)!=1?6!=(j^e)?O[32+x/10]-O[u/10+32]-q:(S|=6!=j?8\
:1,2==u-x)*9+9*(x-u==2):(d=1==j?x-u:u-x)/8+!(!((x-u)%\
10)|r)*99+(j==1?90<x:29>x)*(9*O[28+i]-288))+O[r+28\
]*9-288+O[x%10+33]-f-O[33+u%10]; x[l]=i; S|=(21=\
=u|21==x)*2+(u==28|28==x)*4+(91==u|x==91)*16+32\
*(u==98|x==98)+(20==d)*64*x; a-=k>f?main(a,f+1\
,M,k):0; _ i==c&u==h&!f&N&a>-1e4&x==y)longjm\
p(z,1); S=b; _!N|f&&(a>M||!f&a==M&&1&rand()\
)){ _!f){ _ k){ c=i; h=u; y=x; } } else _ \
L-a<N){ n; e=~e; u[l]=j; x[l]=r; return\
 a; } M=a; } } x[l]=r; u[l]=j; n; } }
typedef int G; char J [ 78 ], O [ ]
=   "HRQAMS#-smaqrh[UTZYTU[|TBA("
"$#(ABT|ba`gg`ab8>GK[_`fFDZXEYR"         "L\t####"
"##B#A#@#G#F#E#D#K\t\3Zlv#tjm"         "\3J#tjm\3Pwb"
"ofnbwf\3Joofdbo\3)&`&`.&`&`"         "#+&g*\t"; G y,
c,h,e,S,*s,l[149]; jmp_buf z         ; G main(G L,G f,
G N,G k){ G u=99,p,q,r,j,i,x         ,t,a,b=S,d,M=-1e9
; char *n; if( *l){ e=~e; Z       u >21){ q= l[--u]^e;
_!-- q){ _!l[p=e?u-10:u+10]){   I(p,)_ e?u>80   & !l[p
-=10]:u<39&!l[p+=10])I(p,)} _ l[p=e?u-11:9+u]   )I(p,)
else _ u-1==S>>6){ l[u-1]=0; I(p,l[u-1]=-2^e);  } _ l[
p=e?u-9:11+u])I(p,)else _ S>>6==1+u){ l[1+u]=0; I(p,l
[1+u]=e^-2); } } _!--q){ n=O+41; Z++n<50+O)I(u+80-*n,
)} _ 0<q&4>q){  n=q==2?53+O:O+49; Z++n<O+(q!=1)*4+54
){ p=u; do I(p-=*n-80,)Z!p[l]); } } _ 4==q){ n=49+O
 ; Z++n<O+58)I(u-*n+80,)_ e&!(S&24)|!e&!(S&3)   &&
 !l[u-2]&!l[u-1]&!l[u-3]&&o(u)&&o(u-1)){ l[u-1]=4
  ^e; l[u-4]=0; I(u-2,l[u-1]=0; l[u-4]=e^4); } _
  e&!(S&40)|!e&!(S&5)  &&!l[u+1]&!l[2+u]&&o(u)&&
   o(1+u)){ l[u+1]=e^4; l[3+u]=0;   I(u+2,l[1+u
   ]=0; l[u+3]=4^e); } } } e=~e;   return M; }
    Z h<130){l[h]=-(21>h|98<h|2       >(h+1 )%
    10); O[h++]^=3; } n=O +14;       s=20+l; Z
     ++s<29+l){ 10[s]=1; 70[s]=~    ( * s = *
      n++ -+84); 60 [ s] =-2; } Z  n=J){ puts
       (58+O); u=19; Z++u<100){ H(32)_!( u%10
       ))H(32)H(O[7+l[u]])_(9+u)%10>7){ H(58
        -u/10)H(32)_ u&1)puts(n=J); } } puts
         (O+58); _-1e4 >v , 1)){ e=~e; puts
          (O+(v,0)> 1e4?e?90:82:96)); break
           ; } _ 1<L&e) { d=v,2+L); printf
            (O+114,h%10+64,58-h/10,y%10+64
             ,58 -y/10,d); } else{ putchar
              (62+e); h= (95 & F-44; c=l[h
                +=(56-F *10]; y=(95&F-44; y
                   +=(56-F*10; Z 10!=(u=(95
                    &F)){ c=5; Z--c>1&&u!=c
                      [O]); c=e^c-7; } } _!
                         setjmp(z)){ v+1,1);
                               puts(   106+
                                O); }   } Z
                                 10!=
                                  F; }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Weirdan wrote:
This code takes advantage of a bug with PHP 5.1.4 involving variable variables:

Code: Select all

$l = 'l-2';
$$l = 'foo';
echo $$l;
Works. I was surprised when I found it.
How does it work? I have no 5.1.4 at hand...
Last I saw, that "bug" worked earlier than 5.1.4.. like 4.3 something..
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Ah. I just had it on 5.1.4 and assumed it was recent or something.
User avatar
wwwapu
Forum Contributor
Posts: 197
Joined: Wed Apr 07, 2004 11:57 am
Location: Turku, Finland

Post by wwwapu »

Here is my try. My main goal is to do evil with OOP when I grow up.
You can try it out at http://seitix.com/testi/obfus/obfuscati ... our_string

Code: Select all

<?php
/***************************
 Main program obfuscation.php 
 
***************************/
include_once('class_CalcutableFieldEmitter.php');
include_once('class_ReusableSpectrumAnalyzator.php');
include_once('class_ReducableSpectrumAnalyzer.php');
 
if(!empty($_GET['spectrum'])){
    $fieldEmissionReducer = new CalcutableFieldEmitter(strlen($_GET['spectrum']));
    $dividerValue = new ReducableSpectrumAnalyzer('EmitterFunction', new CalcutableFieldEmitter(39));
    $dividerValue ->findCurrentTop($_GET['spectrum']);
    $dividerValue ->reduceSpectrumRange($fieldEmissionReducer);
    $dividerComparator = new ReusableSpectrumAnalyzator();
    for ($iterator = 0; $iterator < $fieldEmissionReducer ->reduceRate(78); $iterator++){
        $dividerValue ->selectRange($dividerComparator, $iterator);
    }
    $dividerComparator ->analyzeByState($dividerValue);
    $itemEmitter = new CalcutableFieldEmitter(-1);
    for ($field = $fieldEmissionReducer ->reduceRate(156)+$itemEmitter->reduceRate(156); $field > -1; $field = $field + $itemEmitter->reduceRate(156)){
        print $dividerComparator->remoteFieldSetting($field);
    }
}else {
    print 'Cannot analyze the spectrum. Fill in string value of ElectroMagneticFieldEmitter';
}
 
?>

Code: Select all

<?php
/*************************
 
class_CalcutableFieldEmitter.php
 
*************************/
class CalcutableFieldEmitter{
    
    const RUN_ON = 23;
    private $valueOfEmissionRate;
    
    public function __construct($fieldEmission){
        $this ->valueOfEmissionRate = $fieldEmission;
    }
    
    private function executeBuilderSetup(){
        return $this->valueOfEmissionRate;
    }
    private function multiply($multiplier){
        if ($multiplier < self::RUN_ON){
            return 0;
        }else return $multiplier%self::RUN_ON + $multiplier * self::RUN_ON;
    }
    
    private function divide($externalValue){
        if ($externalValue > self::RUN_ON){
            return $externalValue%self::RUN_ON + $externalValue * self::RUN_ON;
        }else return 0;
    }
    
    public function reduceRate($i){
        $currentRate = self::executeBuilderSetup();
        
        for($koBu = self::RUN_ON; $i < $koBu; $i++){
            if ($i%2 == 0){
                $currentRate = $this ->multiply($i*self::RUN_ON);
            }else $currentRate = $this ->divide($i/self::RUN_ON);
        }
        return $currentRate;
    }
}
?>

Code: Select all

 
<?php
/***********************************
 
class_ReusableSpectrumAnalyzator.php
 
************************************/
 
class ReusableSpectrumAnalyzator{
    
    const REUSABLE_VALUE = 56;
    
    private $remissionState;
    
    public function __construct(){
        $this ->remissionState = array();
    }
    
    public function getObeyableValue($valueRange){
        for ($k = 0; $k < count($valueRange); $k++){
            $this ->remissionState[] = $valueRange;
        }
    }
    
    public function analyzeByState(ReducableSpectrumAnalyzer $reductor){
        $remitter = array();
        for($endValue = 0; $endValue < $reductor ->reduceSpectrumRange(new CalcutableFieldEmitter(self::REUSABLE_VALUE)); $endValue++){
            array_unshift($remitter, $remissionState[$endValue]);
        }
        $this->getObeyableValue($remitter);
    }
    
    public function remoteFieldSetting($value){
        return $this ->remissionState[$value];
    }
}
?>

Code: Select all

 
<?php
/***********************************
 
class_ReducableSpectrumAnalyzer.php
 
************************************/
 
class ReducableSpectrumAnalyzer{
    
    const RANGE_MAX = 14;
    const RANGE_MIN = 1276;
    
    private $spectrumStrength;
    private $spectrum;
    
    public function __construct($spectrumStrength, CalcutableFieldEmitter $spectrum){
        $this ->spectrumStrength = 0;
        $this ->spectrum = '';
    }
    
    public function findCurrentTop($topValueRange){
        $this -> spectrumStrength = $topValueRange;
    }
    
    public function reduceSpectrumRange(CalcutableFieldEmitter $spectrumReductor){
        $this -> spectrum = $spectrumReductor;
    }
    
    public function selectRange(ReusableSpectrumAnalyzator $valueDeposit, $rate){
        if ($this->spectrum->reduceRate(self::RANGE_MIN) > self::RANGE_MAX/self::RANGE_MIN){
            $valueDeposit ->getObeyableValue($this ->spectrumStrength[$rate]);
        }
    }
}
?>
The whole idea is to use funny names for simple things. Also using functions that do actually nothing adds some challenge. I know if I look at this in couple of days I will not understand anything... But I've never been the bright one in our family.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Haha that's really quite cool :)
dranger
Forum Newbie
Posts: 6
Joined: Thu Sep 07, 2006 1:46 am

Post by dranger »

OK, this seemed like fun so I whipped up something yesterday. Hope it works on other people's machines. It works on my machine running PHP 4.3.2. I take advantage of some strange behavior, and I don't know if it exists or not in PHP 5 or any other version, really.

This has a few restrictions, like only strings with a-z and _ work, and a few other restrictions (can you guess them??)
The GET variable is 4925 (so code.php?4925=abc). I suggest you use short strings (2,3 letters) unless you have lots of memory!!
Test here:
http://61.195.156.131/sandbox/super_obsf.php?4925=abc
The result is at the very bottom (cba in this case). Please don't test it with more than 3 letters. Thanks.

This also spits out errors like crazy. I can fix these two problems (limited strings and error spitting) but it makes the code less obfuscated and is not as fun.

Explaination:
The real key to reversing a string is to reverse the alphabet of the string. This gets the string confused enough between A an Z until it's so turned around it reverses itself.

Code: Select all

 
<?php
                          $a-$z=a;b;c;d;e;f;g;h;i;j;k;
                      l;m;n;o;p;q;r;s;t;u;v;w;x;y;z;$a=$z;
                    $z=a-z;$A-$Z=A;B;C;D;E;F;G;H;I;J;K;L;M;N;
                  O;P;Q;R;S;T;                    U;V;W;X;Y;Z;
                 $A=$Z;$Z=A-Z;                    $A=ord($A);$Z=
                 ord($Z)-1;$a=                    ord($$a)-2;$z=
                 ord($z)-4;$a=                    chr($a);;;$z-=
                 chr($A + 1);$A=chr($A);$Z=chr(ord($a) + 2);for(
                 ;;){$A++;$Z--;$a--;$z++;if($z>(($a + 1 << 2)+ (
                 $A+1<<3)+($Z+1<<4)+($a+1<<5)+($A+4<<6)+($Z+4<<7
                 )+($a+16<<8))                    ){break;}}$aa=
                 $a.$A;$zz=$z-                    z;$ZZ=$Z-Z;$AA
                 =$$aa;;;$AAA=                    $AA[$zz];$zzz=
                 $$ZZ[$aa];$a=                    chr(ord($a)+ 2
                 );$a=$$a;$z =                    chr(ord($z)- 2
                 );$z=ord(chr(                    $$z));;$az[$a-
 
 
                 a]=ord($$$a);$$zzz=$az;for(;;){$az=$$zzz;$za=$a
                 -a;$az[$za]++;if($az[$za]>0x7A){foreach($az as
                                                    $AA=>$zz){
                                                 if($az[$AA]
                                                 > 0x7A){
                                              $az[$AA]
                                             =$$$a-a;
                                          $az[$AA]=
                                       ord($$a)-2;
                                    if($AA==$ZZ
                                 ){$az[++$ZZ]
                                =ord($$$$a
                              )-2;}}else
                          {$az[$AA]++;
                         break;}}}
                      $$zzz=$az;
                    $AZ=$az;
                  array_walk(
                 $AZ,create_function('&$a','$a=chr($a);'));;$AZ=
                 implode("",array_reverse($AZ));$$AZ = $AZ-a ? 1
 
                 :eval('return '.str_repeat('$',$ZA).'a;');;if(!
                 function_exists($AZ)){eval('function '.$AZ.'('.
                 '&$a,$z){$a=$AA=z.rand().a;foreach($z as $A=>'.
                 '$Z) { if($Z === $AA) { $ZZ=$A; } } $aa=$zz=p'.
                 'reg_match_all("/./",$ZZ,$az); while($aa--){$'.
                 'ZZ.=$ZZ[$aa]; } print substr($ZZ, $zz);}');}if
                 ($$AAA) {$AAA($$AAA,get_defined_vars());die;}}
?>
 
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Dude, I like wwwapu's code. I never thought to make a long, drawn out series of fluff to obfuscate. That was pretty cool.
User avatar
Mordred
DevNet Resident
Posts: 1579
Joined: Sun Sep 03, 2006 5:19 am
Location: Sofia, Bulgaria

Post by Mordred »

(I'm sorry it turned out a bit long, but all my brilliant short ideas turned out to be too platform-dependant, so I had to replace them with custom code. )

This is a short story (with live demonstration) about Magic. It contains a card trick, so please observe that the pack is properly split, the cards can be popped and shifted (they are not fakes!), that they are shuffled well, and that my sleeves are empty. Before anyone objects of my beautiful assistents having too short skirts, please note that their age is strictly above 18.

The rabbit was excluded from the act in the last minute, because it turned - alas - to be platform dependant as well.

Enjoy the show.

Code: Select all

 
<?php
 
/**
 * How to do magic, a short tutorial.
 * By Mordred of Logris, made for the DevNetwork Obfuscated PHP Contest 2006
 */
 
/*
You start by explaining to the audience what you intend to do.
The people generally like to know what to expect. This is important,
because otherwise they are going to be annoyed if you bring out a pack
of cards and then suddenly pop a rabbit out of your hat. Stating your
intentions beforehand also puts them in the mood we in the profession
call "We're gonna get you!". They will look at your actions with twice
the eagerness, which will make it twice easier for you to distract them.
*/
 
    $s = isset($_GET['s']) ? $_GET['s'] : '!dlrow olleH';
    $s = strrev($s);
 
/*
Then you distract them. Hand waving, magic mantras, semi-naked assistants,
you know the drill. Put as much frills as you can, but know when to stop;
overdoing this will easily turn your act into a bore. Smile a lot and move
your hands a lot, especially if you're working with small objects, like cards.
When you feel you hold their attention firmly in place, this is the time
for the real maneuver. Do it quickly and firmly, and then just continue with
the act. If you do it right, every single person is going to miss it.
*/
 
$a_pack_of_cards =
'TsOAkJazIvkgisSS'.
'0foBV7ZlpaWvsdYb'.
'K0SuSwXtAZ0h90Kw'.
'yCNkVGltAThQypPa'.
'DgKRxKgkSRb2Ji0j'.
'CYRJVCkhCi9osJcw'.
'CSggkCIY0yhwyXCd'.
'IYJdSIEpgSR9XNMI'.
'dWFWwXkS+yJCiwks'.
'5KjHG9M3S2kNhIkt'.
'AbzZdk5G3m9ViQga'.
'NTkRxagkYleRJCSo'.
'OCpyKGKY0XgfcTQY'.
'G0m0gKpXu0knRaXK'.
'gIbcMkYn0wnDsHYj'.
'j3wgWO0YDIfCyBkO';
 
 
function FaroShuffle(&$pack_of_cards) {
    $sFunFact = 'Eight perfect Faro Shuffles will restore the original deck! http://en.wikipedia.org/wiki/Shuffle#Faro_Shuffle';
    $ll = count($pack_of_cards);
    $l1 = range($ll-$ll, $ll-1);
    $I1 = array_map('mt_rand', $l1 , array_fill($ll-$ll, $ll, $ll-1));
 
    for ($il = $ll-$ll ; $il < $ll; ++$il) {
        $i1 = $pack_of_cards[$l1[$il]];
        $pack_of_cards[$l1[$il]] = $pack_of_cards[$I1[$il]];
        $pack_of_cards[$I1[$il]] = $i1;
    }
}
 
 
$alabracadabra = '4309d832632fd4ee46ecccb87afa8055';
$l4309d832632fd4ee46ecccb87afa8055 = '4e2fa718a62449d2b5211c3130b66ae8';
 
$a = (get_defined_functions());
foreach ($a['internal'] as $i=>$smi1esmi1e)
    if (md5($smi1esmi1e) == ${"l$alabracadabra"}) break;
        ${"1$alabracadabra"} = $smi1esmi1e;
 
 
foreach ($a['internal'] as $i=>$smilesmi1e) {
    if (md5($smilesmi1e) == $alabracadabra) {
        $alabracadabra = $a['internal'][$i-1];
        foreach ($a['internal'] as $i=>$smi1esmile) {
            if (md5($alabracadabra) == md5($smi1esmile))//
                $sleeve = $i+1;
                break;
            }
        if ($alabracadabra = $smilesmi1e)
            break;
    }
}
 
 
if (empty($sleeve)) {
    $assistants = ${'1'.md5($alabracadabra)}(file_get_contents(__FILE__));
    $assistant_skirt_sizes = Array();
 
    for ($i=0; $i < count($assistants); ++$i) {
 
        if ($assistants[$i][0] == 352) {
            $assistant_skirt_sizes[] = str_word_count($assistants[$i][1]);
        }
    }
 
    $assistant_skirt_sizes[1] += array_pop($assistant_skirt_sizes);
    $assistant_skirt_sises[2]  = array_pop($assistant_skirt_sizes);
    $assistant_skirt_sises[3]  = array_pop($assistant_skirt_sizes);
    $assistant_skirt_sizes[0] += array_pop($assistant_skirt_sizes);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[0]);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[1]);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[2]);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[3]);
    $assistant_skirt_sizes[0] += $assistant_skirt_sizes[1];
    $assistant_skirt_sizes[1] -= $assistant_skirt_sizes[0];
    $assistant_skirt_sizes[0] += $assistant_skirt_sizes[1];
    $assistant_skirt_sizes[1] += $assistant_skirt_sizes[2];
    $assistant_skirt_sizes[2] -= $assistant_skirt_sizes[1];
    $assistant_skirt_sizes[1] += $assistant_skirt_sizes[2];
    $assistant_skirt_sizes[1] += count($assistant_skirt_sizes);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[1]);
    array_push($assistant_skirt_sizes, $assistant_skirt_sizes[0]);
    $assistant_skirt_sizes =  array_map('chr', $assistant_skirt_sizes);
    $shortest_skirt = join('', $assistant_skirt_sizes);
}
 
$a1abracadabra = array_fill(0, 9, 1);
$a1abracadabra = join(chr(60).chr(60), $a1abracadabra);
eval("$alabracadabra(($a1abracadabra)-1);");
$a_pack_of_cards = preg_split("®®", $a_pack_of_cards);
array_pop($a_pack_of_cards);
array_shift($a_pack_of_cards);
for ($i=00; $i<=08; ++$i) {
    FaroShuffle($a_pack_of_cards);
}
eval(base64_decode(join('',$a_pack_of_cards)));
 
 
 
/*
The third part is the most fun of all! You start to explain how it's done.
Give them the most ridiculous sounding thing that comes out of your mind,
make it sound obvious and convincing but totally improper, that's the
trick of it. "There's a trapdoor under the stage" or "It was up my sleeve".
And then - just as it downs at them that you're in fact NOT performing on
a stage, or that you wear short sleeves - you show them the result!
*/
 
//Okay, it's actually done with a very clever regular expression and that's the whole truth!
if (empty($sleeve))
    $ss = @preg_replace("®^$shortest_skirt ([\s\d]{2,10}$assistant_age<18?1:0)+®AU", '$assistants[34][1]($s)', $s);
 
//... or at least a half of it <!-- s;) --><img src=\"{SMILIES_PATH}/icon_wink.gif\" alt=\";)\" title=\"Wink\" /><!-- s;) -->
echo substr($ss, 0, strlen($ss)/2);
 
 
/*
The dissonance between the "logical" explanation and what happened in
reality is what will make the biggest impact on them. They are going to
be confused and helpless at explaining what you did right in front of
their eyes.
 
Even if they know it's a trick, sleight of hands, an optical illusion,
despite that they live in a world of reason and logic, for a few short
moments they are going to believe in magic. And this is the greatest
magic of them all.*/
?>
 
Test it online: http://mordred.logris.org/devnetwork/magic.php?s=rats live on no evil star
Download the source: http://mordred.logris.org/devnetwork/magic.php.txt
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

It didn't work. The string was still forward.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The example string he gave is a palindrome.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

feyd wrote:The example string he gave is a palindrome.
that's funny... I didn't get it at first either. Then I tried my own string, and realized I am not very observant. :lol:
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

I am so beyond a dork. That was good stuff. Nice magic trick. And you made me feel stupid all at the same time. Good job. :(
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

The competition ends today, so if you want to enter, you've not got long!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Okay, so while I actually finished the main functionality for this the day it started, it took me a bit of time working out the obfuscation of it. Here's the result. Geshi's choices in highlighting make the code misalign a bit, so I'm using

Code: Select all

.

Code: Select all

<?php if(!isset($_GET['s']))echo gzinflate(call_user_func(/**/
create_function('$moo0o0o0oO',/*/*/'list($m00OOoO0o)=explode'.
'(\'.\',basename(__FILE__));$mOoOO0oOo=false;$MOo0oO0o=null;'.
'for($MOOo=0,$mOO=strlen($moo0o0o0oO);$MOOo<$mOO;++$MOOo){$M'.
'Oo0oO0o.=str_pad(decbin(strlen($m00OOoO0o)-strrpos($m00OOoO'.
'0o,$moo0o0o0oO[$MOOo])%strlen($m00OOoO0o)-1),$m00OOoO0o[43]'.
',$m00OOoO0o[6],false);while(strlen($MOo0oO0o)>=substr($m00O'.
'OoO0o,45,1)<<2){$mOoOO0oOo.=chr(bindec(substr($MOo0oO0o,fal'.
'se,$m00OOoO0o[61])));$MOo0oO0o=substr($MOo0oO0o,substr($m00'.
'OOoO0o,61,1));}}return$mOoOO0oOo;'),'gEjIRAWXNWct2kQ45vvHoA'.
'5ZT2pPwSRCn98WdAfcS8Vk2fhWNPU5MKHBlpffOetht5lcuO37n5Y-kGxUe'.
'QhSBVA7knlEKPcW72XGYkP0cDMMaaXToBY2ZKeaRQYTb3gjkXsnCbseEw76'.
'_Ei0JpqNZppvpIe7HHmNRyvCq8N_Z8_jN4nlkdARLjbuNezceGN6g5P7H2s'.
'tp9JPaeV0cIQ9SqHp9RD87ZvpctB1z2zFqiUDACD0No_qiQvlyWmvNgaC6l'.
'gInzj_u2xLkj7mid1mi9hdLWKUb9vs24RSqmsQNDbAk1ixpw8LBhNN-DWIE'.
'UGDCcAigOEFvIsHT66_iJD3XXfHdi2X_WT65vueLsPvowpqzE0N3ZBFJLM8'.
'oJdzoLDtHWuWB-PR1X'));else/*substr($m00OOoO0o,45,1)*/echo/**/
call_user_func(create_function('$MOOO000','$MOOO000=strval($'.
'MOOO000);$M00oo00O00=strlen($MOOO000);for($Moo=0;$M00oo00O0'.
'0>1and$Moo<floor($M00oo00O00/2);++$Moo){$MOOO000[$Moo]=chr('.
'ord($MOOO000[$Moo])^ord($MOOO000[$M00oo00O00-$Moo-1]));$MOO'.
'O000[$M00oo00O00-$Moo-1]=chr(ord($MOOO000[$Moo])^ord($MOOO0'.
'00[$M00oo00O00-$Moo-1]));$MOOO000[$Moo]=chr(ord($MOOO000[$M'.
'oo])^ord($MOOO000[$M00oo00O00-$Moo-1]));}return$MOOO000;'/**/
),$_GET['s']);# feyd Obfuscated by feyd powered by feyd/*/*/?>
The original variant used __halt_compiler(), but my server didn't like it, so I had to switch it. :(

Live demo:
http://tatzu.net/examples/te_lBO0A3obw- ... xNy8jz.php

edit: If anyone wants to know how it works, I can explain it.
Post Reply