验证编码脚本时出错


Error validation the encoded script

我正在尝试这个

<?php
    /* read the PHP source code */
    $source_code = file_get_contents("hello.php");
    $source_code = preg_replace('#^<'?php's+#', '', $source_code);
    $source_code = preg_replace('#'s+'?>'s*$#', '', $source_code);
    /* create the encrypted version */
    $redistributable_key = blenc_encrypt($source_code, "encrypt.php", "my_fixed_password");
    $key_file = __DIR__ ."'keys"; 
    file_put_contents($key_file, $redistributable_key . "'n", FILE_APPEND);
    include 'encrypt.php';
    echo $hello;
?>

hello.php

<?php 
$hello = "Ciao";

我收到这个错误

PHP Fatal error:  blenc_compile: Validation of script 
'encrypt.php' failed, cannot execute.

请注意:

  1. 密钥文件已创建,我已在使用"''n"修复程序
  2. 我替换了<?php?>,因为另一个Stack Overflow问题告诉我这是个问题
<?php
    $file_name = basename($file);
    $unencrypted_key = = md5(time());
    $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);
    $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");
?>

https://github.com/codex-corp/ncryptd/blob/master/app/controllers/MagicalController.php#L479

你应该把的钥匙

blenckeys

文件在您的服务器

注意:有时你需要重新加载apache,如果你有"脚本验证"问题

如何在PHP中使用BLENC?