When I load a page previously encrypted by BLENC on the web server, this shows:
Severity: Warning
Message: blenc_compile: Validation of script 'path\to\file\R2k_Controller.php' failed. MD5_FILE: 3f6958c4bee8ba0d4cb3a0e67e0e2bde MD5_CALC: 02998505e69466a2f7f3af5d4555a352
Severity: Error
Message: blenc_compile: Validation of script 'path\to\file\R2k_Controller.php' failed, cannot execute.
Using:
- PHP 5.6.14 x64 NTS
- Blenc 1.1.4b
- IIS 7.5
this is the code in which i encrypt:
$oDir = NULL;
if(PHP_SAPI === 'cli'){
$path = $argv[1];
$path2 = '';
if(count($argv)>1){
$oDir = new RecDir($path,false);
while (false !== ($archivo = $oDir->read())) {
if(strstr($archivo,".php") !== FALSE){
$path2=substr_replace($archivo,$path,strpos($archivo,$path),strlen($path));
$source_code = file_get_contents($path2);
blenc_encrypt($source_code, $argv[2] . $path2,$FKEY);
echo($archivo . " >>> " . $argv[2] . $path2 . PHP_EOL);
}
}
$oDir->close();
file_put_contents( $argv[2] ."blenc.key_file", $FKEY."\n");
}
else{
echo("Error: parametos incorrectos" . PHP_EOL);
}
}
else{
echo("<html><head>Error</head><body>Acceso denegado!</body></html>");
}
how can i solve this?
EDIT
check Repository for blenc I found this
for (zend_hash_internal_pointer_reset(php_bl_keys);
zend_hash_get_current_data(php_bl_keys, (void **)&key) == SUCCESS;
zend_hash_move_forward(php_bl_keys)) {
decoded = php_blenc_decode(encoded, *key, script_len - sizeof(blenc_header), &decoded_len TSRMLS_CC);
md5 = emalloc(33);
php_blenc_make_md5(md5, decoded, decoded_len TSRMLS_CC);
if(!strncmp(md5, header->md5, 32)) {
validated = TRUE;
efree(md5);
break;
}
zend_error(E_WARNING, "blenc_compile: Validation of script '%s' failed. MD5_FILE: %s MD5_CALC: %s\n",
file_handle->filename, header->md5, md5);
efree(md5);
md5 = NULL;
efree(decoded);
decoded_len = 0;
}
static void php_blenc_make_md5(char *result, void *data, unsigned int data_len TSRMLS_DC)
{
PHP_MD5_CTX context;
unsigned char digest[16];
PHP_MD5Init(&context);
PHP_MD5Update(&context, data, data_len);
PHP_MD5Final(digest, &context);
make_digest(result, digest);
}
b_byte *php_blenc_decode(void *input, unsigned char *key, int in_len, int *out_len TSRMLS_DC)
{
BLOWFISH_CTX ctx;
unsigned long hi, low;
int i;
b_byte *retval;
Blowfish_Init (&ctx, (unsigned char*)key, strlen(key));
if(in_len % 8) {
zend_error(E_WARNING, "Attempted to decode non-blenc encrytped file.");
return estrdup("");
} else {
retval = emalloc(in_len + 1);
}
memset(retval, '\0', sizeof(retval));
hi = 0x0L;
low = 0x0L;
for(i = 0; i < in_len; i+=8) {
hi |= (unsigned int)((char *)input)[i] & 0xFF;
hi = hi << 8;
hi |= (unsigned int)((char *)input)[i+1] & 0xFF;
hi = hi << 8;
hi |= (unsigned int)((char *)input)[i+2] & 0xFF;
hi = hi << 8;
hi |= (unsigned int)((char *)input)[i+3] & 0xFF;
low |= (unsigned int)((char *)input)[i+4] & 0xFF;
low = low << 8;
low |= (unsigned int)((char *)input)[i+5] & 0xFF;
low = low << 8;
low |= (unsigned int)((char *)input)[i+6] & 0xFF;
low = low << 8;
low |= (unsigned int)((char *)input)[i+7] & 0xFF;
Blowfish_Decrypt(&ctx, &hi, &low);
retval[i] = hi >> 24;
retval[i+1] = hi >> 16;
retval[i+2] = hi >> 8;
retval[i+3] = hi;
retval[i+4] = low >> 24;
retval[i+5] = low >> 16;
retval[i+6] = low >> 8;
retval[i+7] = low;
hi = 0x0L;
low = 0x0L;
}
retval[in_len] = '\0';
*out_len = strlen(retval);
return retval;
}
Can anyone explain what is going on here?