2
I am developing a php extension with PHP-CPP, where I need to make a include of a php file within the extension, I am doing this to protect the code. I’m trying this way:
Php::Value HomeController () {
std::string source = "";
source += "<?php\r\n";
source += "namespace App\\Http\\Controllers\\ajax;\r\n";
source += "use Illuminate\\Http\\Request;\r\n";
source += "use App\\Http\\Requests;\r\n";
source += "use App\\Http\\Controllers\\Controller;\r\n";
source += "class HorarioController extends Controller {\r\n";
source += "protected $page = \"ajax.horario\";\r\n";
source += "public function index(){\r\n";
source += "return $this->view;\r\n";
source += "}\r\n";
source += "}\r\n";
Php::Value val = Php::call("base64_encode", source);
std::string retorno = val;
retorno = "data://text/plain;base64,"+retorno;
return retorno;
}
but if you remove "date://text/Plain;Base64," and use base64_decode you have access to my class.
I tried that way too:
void HomeControllerInclude () {
std::string source = "";
source += "<?php\r\n";
source += "namespace App\\Http\\Controllers\\ajax;\r\n";
source += "use Illuminate\\Http\\Request;\r\n";
source += "use App\\Http\\Requests;\r\n";
source += "use App\\Http\\Controllers\\Controller;\r\n";
source += "class HorarioController extends Controller {\r\n";
source += "protected $page = \"ajax.horario\";\r\n";
source += "public function index(){\r\n";
source += "return $this->view;\r\n";
source += "}\r\n";
source += "}\r\n";
Php::Value val = Php::call("base64_encode", source);
std::string retorno = val;
retorno = "data://text/plain;base64,"+retorno;
Php::call("include", retorno);
}
But I get the following mistake: Invalid call to include
Note: I am using this method because it is the safest I know, the others have dozens of methods to do reverse engineering.
EDITION:
I ended up finding a function in PHP-CPP that does include, is the function Php::include()
it works perfectly with php files, but when I have use include with the data://text/plain;base64,
do not even receive an error message and does not include, which will be?
Php::Value HomeControllerInclude () {
std::string source = "";
source = "<?php class novo { public static function coco() { return 20; } }";
Php::Value val = Php::call("base64_encode", source);
std::string retorno = val;
retorno = "data://text/plain;base64,"+retorno;
return include(retorno);
}
I’m not sure, but I think the error occurs because
include
is not a function but a PHP "language-Construct".– Guilherme Nascimento
True, I ended up finding a PHP-CPP function that does include, but I ended up encountering a problem, I’ll edit the question.
– Pedro Soares