コード例 #1
2
ファイル: blencode.php プロジェクト: illuusio/pecl-php-blenc
    }
    if (!file_exists('backup/' . basename($argv[1]))) {
        $backup_file = 'backup/' . basename($argv[1]);
    } else {
        $backup_file = 'backup/' . basename($argv[1]) . '.' . date('Y_m_d_H_i_s', time());
    }
    copy($argv[1], $backup_file);
    echo "{$B1} BLENC {$B0} backup file : {$backup_file}\n";
    $contents = php_strip_whitespace($argv[1]);
    $contents = convert_html($contents);
    file_put_contents('/tmp/blencode-txt', $contents);
    $contents = minify('/tmp/blencode-txt');
    $aS = array('<?php', '?>', '<?');
    $aR = array('', '', '');
    $contents = trim(str_replace($aS, $aR, $contents));
    echo "{$B1} BLENC {$B0} size of content: " . strlen($contents) . "\n";
    echo "{$B1} BLENC {$B0} MD5: " . md5($contents) . "\n";
    file_put_contents('/tmp/blencode-log', "---\nFILE: {$argv['1']}\nSIZE: " . strlen($contents) . "\nMD5: " . md5($contents) . "\n", FILE_APPEND);
    if ($key != '') {
        $key = blenc_encrypt($contents, $argv[1] . 'enc', $key);
    } else {
        $key = blenc_encrypt($contents, $argv[1] . 'enc');
    }
    echo "{$B1} BLENC {$B0} redistributable key: {$key}\n";
    file_put_contents('key_file.blenc', $key . "\n", FILE_APPEND);
    unlink($argv[1]);
    symlink($argv[1] . 'enc', $argv[1]);
    $result = @system('sort -k1 -u -o key_file.blenc key_file.blenc');
    echo "{$B1} BLENC {$B0} redistributable key file key_file.blenc updated.\n";
    echo "{$B1} BLENC {$B0} done.\n";
}
コード例 #2
2
ファイル: blenc_encode.php プロジェクト: virbo/phpdesktop
<?php

define("BLENC_ENCRYPTION_KEY", "ChangeThisToSomethingElse");
error_reporting(-1);
print '<style type="text/css">@import url("style.css");</style>';
print "<a href='javascript:history.go(-1)'>Go back</a><br>";
if (!extension_loaded("blenc")) {
    $link = "https://github.com/cztomczak/phpdesktop/wiki/" . "Source-code-protection#blenc-encoder";
    printf("ERROR: blenc extension not loaded.<br><br>\r\n            BLENC encoder is a PECL extension that permits to protect\r\n            PHP source scripts.\r\n            This extension is not distributed by default with\r\n            phpdesktop binaries.\r\n            See instructions on how to use BLENC encoder with\r\n            phpdesktop on the SourceCodeProtection wiki page:<br>\r\n            <a href='%s'>%s</a>", $link, $link);
    exit;
}
$source_code = file_get_contents("blenc_myscript.php");
// The encoded source passed to blenc_encrypt() cannot contain
// any php tags. We are removing php tags at the beginning and
// end of file. Also checking that there are no other php tag
// openings/closings.
$source_code = preg_replace('#^<' . '\\?php\\s+#', '', $source_code);
$source_code = preg_replace('#\\s+\\?' . '>\\s*$#', '', $source_code);
if (preg_match('#<' . '\\?#', $source_code) || preg_match('#\\?' . '>#', $source_code)) {
    print "Script to be encoded can only contain PHP code.";
    print " Only a single php opening tag at the beginning of file";
    print " and a single php closing tag at the end of file are allowed.";
    print " This is a limitation as of BENC encoder 1.1.4b.";
    exit;
}
$redist_key = blenc_encrypt($source_code, "blenc_myscript_encoded.php", BLENC_ENCRYPTION_KEY);
$key_file = ini_get('blenc.key_file');
file_put_contents($key_file, $redist_key);
print "DONE. See";
print " <a href='blenc_myscript_encoded.php'>blenc_myscript_encoded.php</a>";
コード例 #3
2
 function BLENCiT()
 {
     $files = MagicalHelpers::findit('*.{php}', GLOB_BRACE, TARGET_DIR . '/');
     /**
      * BLENC blowfish unencrypted key
      * blenc.key
      * @link http://giuseppechiesa.it/_dropplets/php-blenc-quick-start-guide
      */
     if (Input::has('unencrypted_key')) {
         $unencrypted_key = Input::get('unencrypted_key');
     } else {
         $unencrypted_key = md5(time());
     }
     //$key = md5(time());
     $html = "";
     foreach ($files as $file) {
         $file_name = basename($file);
         $source_code = file_get_contents($file);
         //This covers old-asp tags, php short-tags, php echo tags, and normal php tags.
         $contents = preg_replace(array('/^<(\\?|\\%)\\=?(php)?/', '/(\\%|\\?)>$/'), array('', ''), $source_code);
         $html .= "<br> BLENC blowfish unencrypted key: {$unencrypted_key}" . PHP_EOL;
         $html .= "<br> BLENC file to encode: " . $file_name . PHP_EOL;
         //file_put_contents('blencode-log', "---\nFILE: $file_name\nSIZE: ".strlen($contents)."\nMD5: ".md5($contents)."\n", FILE_APPEND);
         if (!is_dir(TARGET_DIR . '/blenc')) {
             mkdir(TARGET_DIR . '/blenc', 0777);
         }
         $redistributable_key = blenc_encrypt($contents, TARGET_DIR . '/blenc/' . $file_name, $unencrypted_key);
         $html .= "<br> BLENC size of content: " . strlen($contents) . PHP_EOL;
         /**
          * Server key
          * key_file.blenc
          */
         file_put_contents(TARGET_DIR . '/blenc/' . 'key_file.blenc', $redistributable_key . PHP_EOL);
         $html .= "<br> BLENC redistributable key file key_file.blenc updated." . PHP_EOL;
         //exec("cat key_file.blenc >> /usr/local/etc/blenckeys");
     }
     return $html;
 }
コード例 #4
2
ファイル: 002.php プロジェクト: illuusio/pecl-php-blenc
<?php

ini_set("blenc.key_file", "ext/blenc/tests/keys.txt");
$key = blenc_encrypt(file_get_contents("input.php"), "ext/blenc/tests/output.phpe");
file_put_contents("ext/blenc/tests/keys.txt", $key);
include_once "ext/blenc/tests/output.phpe";
unlink("ext/blenc/tests/keys.txt");
unlink("ext/blenc/tests/output.phpe");