Example #1
0
<?php

$fileName = $_POST['fileName'];
$filePath = $_POST['filePath'];
$file = "../" . $filePath . '/' . $fileName;
include_once "obfuscator1.php";
include_once "obfuscator2.php";
include_once "obfuscateVariables.php";
//obfuscating variables
//$enc = new Encryption();
//$enc->parse ($file)->codeit($file);
//First encoder
$obfuscator = new PhpObfuscator();
$obfuscatedFile = $obfuscator->obfuscate($file);
if ($obfuscator->hasErrors()) {
    $errors = $obfuscator->getAllErrors();
    print_r($errors);
} else {
    //Second encoder
    $packer = new obfuscator();
    $packer->file($obfuscatedFile);
    $packer->strip = false;
    $packer->strip_comments = false;
    $packer->b64 = true;
    $packer->pack();
    $packer->save("../" . $filePath . "/obfuscated_" . $fileName);
    //obfuscating variables
    $enc = new Encryption();
    $enc->parse("../" . $filePath . "/obfuscated_" . $fileName)->codeit("../" . $filePath . "/obfuscated_" . $fileName);
    //deleting files
    unlink($obfuscatedFile);
 public function CiphersNonFW()
 {
     $files = MagicalHelpers::findit('*.{php}', GLOB_BRACE, TARGET_DIR . '/');
     if (Input::has('cipher_key')) {
         $unencrypted_key = Input::get('cipher_key');
     } else {
         $unencrypted_key = md5(time());
     }
     //$key = md5(time());
     $Cipher = new PhpObfuscator($unencrypted_key);
     $file_time = time();
     foreach ($files as $file) {
         $file_name = basename($file);
         $path = pathinfo($file);
         //$last_mod = filemtime($file);
         $source_code = file_get_contents($file);
         $comments = $Cipher->getFileDocBlock($source_code);
         $contents = trim(str_replace(array('<?php', '<?', '?>'), array('', '', ''), $source_code));
         /**
          * get filename correctly
          */
         $guard = '$SssdDwwq = pathinfo(__FILE__ ); if( (int) filemtime($SssdDwwq["dirname"]."/". $SssdDwwq["filename"]. ".php") != ' . $file_time . ') return die("fuckers");' . PHP_EOL;
         //$lock = 'if( $_SERVER["SERVER_NAME"] != "alryadah.sa" || $_SERVER["HTTP_HOST"] != "www.alryadah.sa" ) exit("Sorry, you can only use this on alryadah.sa.com");';
         $contents = $Cipher->normal_magic($guard . $contents);
         file_put_contents($path['dirname'] . '/' . $file_name, "<?php" . PHP_EOL . $comments . $contents . PHP_EOL . " ?>");
         touch($file, $file_time);
     }
 }