PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Wed Sep 30, 2020 3:03 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: Thu Aug 10, 2006 3:22 pm 
Offline
Moderator
User avatar

Joined: Mon Nov 03, 2003 7:13 pm
Posts: 5978
Location: Odessa, Ukraine
for some reason nobody used ;/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 3:33 pm 
Offline
Forum Commoner
User avatar

Joined: Mon Jun 05, 2006 9:53 am
Posts: 77


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 4:13 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 10, 2006 4:14 pm 
Offline
DevNet Master
User avatar

Joined: Mon Oct 25, 2004 9:29 pm
Posts: 3698
Location: New Jersey, US


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 2:30 pm 
Offline
Forum Contributor
User avatar

Joined: Wed Apr 07, 2004 11:57 am
Posts: 197
Location: Turku, Finland
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
Syntax: [ Download ] [ Hide ]
<?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';
}
 
?>


Syntax: [ Download ] [ Hide ]
<?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;
    }
}
?>

Syntax: [ Download ] [ Hide ]
 
<?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];
    }
}
?>

Syntax: [ Download ] [ Hide ]
 
<?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.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 3:02 pm 
Offline
Breakbeat Nuttzer
User avatar

Joined: Wed Mar 24, 2004 8:57 am
Posts: 13098
Location: Melbourne, Australia


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 11:36 pm 
Offline
Forum Newbie

Joined: Thu Sep 07, 2006 1:46 am
Posts: 6
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.

Syntax: [ Download ] [ Hide ]
 
<?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;}}
?>
 


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 12:16 am 
Offline
Site Administrator
User avatar

Joined: Tue Sep 09, 2003 6:04 pm
Posts: 14293
Location: Fremont, CA, USA


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 5:00 pm 
Offline
DevNet Resident
User avatar

Joined: Sun Sep 03, 2006 5:19 am
Posts: 1579
Location: Sofia, Bulgaria
(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.


Syntax: [ Download ] [ Hide ]
 
<?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:
Download the source:


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 6:09 pm 
Offline
Site Administrator
User avatar

Joined: Tue Sep 09, 2003 6:04 pm
Posts: 14293
Location: Fremont, CA, USA


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 6:18 pm 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 6:31 pm 
Offline
The Ninja Space Mod
User avatar

Joined: Fri Aug 05, 2005 1:53 pm
Posts: 6424
Location: Paradise, CA


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 08, 2006 6:33 pm 
Offline
Site Administrator
User avatar

Joined: Tue Sep 09, 2003 6:04 pm
Posts: 14293
Location: Fremont, CA, USA


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 4:11 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com


Top
 Profile  
 
 Post subject:
PostPosted: Sat Sep 09, 2006 10:22 am 
Offline
Neighborhood Spidermoddy
User avatar

Joined: Mon Mar 29, 2004 4:24 pm
Posts: 31559
Location: Bothell, Washington, USA


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 82 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group