Jump to content

PHP Obfuscation


mister5317

Recommended Posts

I found it a fun learning experience to make something as simple as "HELLO WORLD!" into a difficult process.

 

I obfuscated my PHP below to just echo "HELLO WORLD!". Anyone else have a better example to echo "HELLO WORLD!"?

 

<?php
// Output = HELLO WORLD!
function __e($_){echo$_;
}function __($_){__e(chr
($_));}function _a(){$__
=func_get_args();foreach
($__ as$k=>$v)$a[$k]=$v;
return$a;}foreach(_a(7,4
,+11,11,14,-33,22,14,17,
11,3,-32)as$k=>$v){__(65
+$v);}

 

Give it a shot, it more difficult to think of creative ways to make something out of the box like this. :)

Link to comment
Share on other sites

function _f($z){return($z==1?0:($z==2?1:_f($z-1)+_f($z-2)));}$_a=array(0x38,0x2d,0x3c,0x2a,0x3d,0x45,0x36,0x24,0x21,0x3c,0x2c,0x51);$_b=array(0x6f,0x66,0x6d,0x65,0x70,0x62,0x60,0x69,0x70);for($i=0,$a=sizeof($_a),$b=sizeof($_b);$i<$a;++$i)print(chr($_a[$i]^($_b[$i%$b]+_f($i%3+3))));

 

Ninja points to whomever finds the easter egg(s).

Link to comment
Share on other sites

If the obfuscation is formatted, it can be easily read, theirfore more easyier to deobfuscate  :P

 

<?php
  // Output = HELLO WORLD!
  function __e($_)
  {
      echo $_;
  }
  function __($_)
  {
      __e(chr($_));
  }
  function _a()
  {
      $__ = func_get_args();
      foreach ($__ as $k => $v)
          $a[$k] = $v;
      return $a;
  }
  foreach (_a(7, 4,  + 11, 11, 14, -33, 22, 14, 17, 11, 3, -32) as $k => $v) {
      __(65 + $v);
  }
?>

Link to comment
Share on other sites

A recursive function wrapped in an ugly ternary statement, numbers in hex representation and bit manipulation...  Wow!

 

Yeah, but it's a special recursive function, a particular type of bit manipulation and one of the number sequences have a special meaning and one of the number sequences have a special meaning if you fiddle a bit with it.

Link to comment
Share on other sites

The easter egg is 'phpfreaks'.

 

function _f($z){return($z==1?0:($z==2?1:_f($z-1)+_f($z-2)));}

$_a=array(0x38,0x2d,0x3c,0x2a,0x3d,0x45,0x36,0x24,0x21,0x3c,0x2c,0x51);

$_b=array(0x6f,0x66,0x6d,0x65,0x70,0x62,0x60,0x69,0x70);for($i=0,$a=sizeof($_a),$b=sizeof($_b);$i<$a;++$i)print(chr($_a[$i]^($_b[$i%$b]+_f($i%3+3))));

 

Here is how it works:

The function I defined is a recursive implementation of the Fibonacci sequence. The arrays $_a and $_b contain the strings HELLO WORLD! and phpfreaks. However, each character in $_b has been shifted upwards with the $i % 3 + 3th Fibonacci number. Then I applied a XOR shift on $_a with the Fibonacci shifted string.

 

The code I posted reverses this of course.

Link to comment
Share on other sites

Try this one on for size. Not all that complicated but it sure looks like a mess :P

 

$__="\142\141\163\145\66\64\137\144\145\143"
."\157\144\145";eval("\$_=$__('YS5mdW5jdGlvb
iAuZWNoby5iLmNoci5yZXR1cm4gLigzKy4pKjUubA');
");$_=explode('.',$_);function l($b){global 
$_;eval($$_[3]);}$_[8]("$_[1]$_[0]($$_[0]){ 
$_[2]$$_[0];}$_[1]$_[3]($$_[0]){ $_[5]$_[4](
$$_[0]);}");foreach(array(11.4,7.2,12.2,18.6
,6.6,3.4,20.8,12.8,19.8,18.6,10.6,3.6)as $__
){eval("\$c=($_[6]$__$_[7]);");$_[0]($_[3](
$c));}

 

EDIT: This was all done by hand by the way, as was my signature :P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.