Closed HaxorGaruda closed 5 years ago
https://www.php.net/manual/en/book.bcompiler.php
Seems it's the same with old PHP compiler. I haven't test it yet, but it seems possible
There is no wiki for this, but the usage is simple. You download the source code to your server with git clone command, You do phpize, configure and make (As its mentioned at README) Then you need to alter your php.ini to make PHP recognize bcgen as zend extension. You basically add zend_extension=/path/to/bcgen.so at the top your php.ini file.
Now do /path/to/php -v
If you can see Zend BCGen that means bcgen is configured correctly.
Now you need to create a compiler file. Simply create a file and put these in
<?php
function make_bytecode($sname, $tname) { check_bcgen(); bcgen_compile_file($sname, $tname); } function check_bcgen() { if (!extension_loaded("Zend BCgen")) die("skip Zend BCgen isn't loaded"); }
$dir = dirname(FILE).'/'; make_bytecode($dir.'filetobecompiled.php', $dir.'compiledfile.phb');
Executing this should give you a compiled PHP file. This works on me.
`<?php
function make_bytecode($sname, $tname) { check_bcgen(); bcgen_compile_file($sname, $tname); } function check_bcgen() { if (!extension_loaded("Zend BCgen")) die("skip Zend BCgen isn't loaded"); }
$dir = dirname(FILE).'/'; // Dirname with 2 underscores. GitHub recognizes them as bolt text. make_bytecode($dir.'filetobecompiled.php', $dir.'compiled.phb');`
Now, compiled file is at compiled.phb.
<?php function make_bytecode($sname, $tname) { check_bcgen(); bcgen_compile_file($sname, $tname); } function check_bcgen() { if (!extension_loaded("Zend BCgen")) die("skip Zend BCgen isn't loaded"); } $dir = dirname(FILE).'/'; // Dirname with 2 underscores. GitHub recognizes them as bolt text. make_bytecode($dir.'filetobecompiled.php', $dir.'compiled.phb');
Now, compiled file is at compiled.phb.
So the function is different from old bcompiler?? can the spl_file_autoload() work?
Anyway can the bytecode reversed back to be php source code? Thanks.
BCGen is different than Bcompiler. You can't use the same functions for Bcgen. I mentioned the simple usage above. I don't think spl_file_autoload() would work. I studied Bcgen's source code and I couldn't see anything related to that.
Bytecode can be reversed to the PHP source. There are several people doing this. But you can try adding more security to make it harder for anyone to reverse engineer your code. You can never 100% protect your code from getting decompiled. If you are giving someone the file that has your codes, Encoded or in cleartext, it doesn't matter. Even if you use some professional solution like ionCube or SourceGuardian, they can also be decoded back to cleartext. Try implementing SaaS.
So not every PHP code/function will run on it(bcgen)? I see, so in the end if someone has this code, they can reverse it. I see, but worth to try.
Regrads, Benyamin Limanto Sent from my ASUS A43SV with Mail for Windows 10
From: Emre Oksum Sent: 19 May 2019 2:18 To: vjardin/bcgen Cc: Benyamin Limanto; Comment Subject: Re: [vjardin/bcgen] wiki page (#12)
BCGen is different than Bcompiler. You can't use the same functions for Bcgen. I mentioned the simple usage above. I don't think spl_file_autoload() would work. I studied Bcgen's source code and I couldn't see anything related to that. Bytecode can be reversed to the PHP source. There are several people doing this. But you can try adding more security to make it harder for anyone to reverse engineer your code. You can never 100% protect your code from getting decompiled. If you are giving someone the file that has your codes, Encoded or in cleartext, it doesn't matter. Even if you use some professional solution like ionCube or SourceGuardian, they can also be decoded back to cleartext. Try implementing SaaS. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Well, yes but no. As long as I see, every function that works on core PHP, also works on bcgen. But you are right about reverse engineering. Thats how it is.
Most technologies can be analyzed for reverse engineering. It is just about the level of deep protection you are looking for.
close , now i switch to sourceguardian...
BCGen is different than Bcompiler. You can't use the same functions for Bcgen. I mentioned the simple usage above. I don't think spl_file_autoload() would work. I studied Bcgen's source code and I couldn't see anything related to that. Bytecode can be reversed to the PHP source. There are several people doing this. But you can try adding more security to make it harder for anyone to reverse engineer your code. You can never 100% protect your code from getting decompiled. If you are giving someone the file that has your codes, Encoded or in cleartext, it doesn't matter. Even if you use some professional solution like ionCube or SourceGuardian, they can also be decoded back to cleartext. Try implementing SaaS.
Anyway is it possible to add some more layer to scramble the bytecode with some passphrase or it's a lame idea? Thanks
Thats a good idea since other compilers like ionCube, SourceGuardian etc. Uses this to protect the bytecode inside the encoded PHP file. These methods are used to protect the bytecode from curious eyes:
You can implement one of these and make bytecode decrypted first before interpretation.
Thats why you won't see any strings inside bytecode unlike BCGen in ionCube and other compilers.
`<?php
function make_bytecode($sname, $tname) { check_bcgen(); bcgen_compile_file($sname, $tname); } function check_bcgen() { if (!extension_loaded("Zend BCgen")) die("skip Zend BCgen isn't loaded"); }
$dir = dirname(FILE).'/'; // Dirname with 2 underscores. GitHub recognizes them as bolt text. make_bytecode($dir.'filetobecompiled.php', $dir.'compiled.phb');`
Now, compiled file is at compiled.phb.
Hi, I'm not understanding where I have to put this code to make it work. Should I put it in a blank file in /path/to/php as you said in the previous comment or in the dir with my project?
Thanks in advance.
<?php function make_bytecode($sname, $tname) { check_bcgen(); bcgen_compile_file($sname, $tname); } function check_bcgen() { if (!extension_loaded("Zend BCgen")) die("skip Zend BCgen isn't loaded"); } $dir = dirname(**FILE**).'/'; // Dirname with 2 underscores. GitHub recognizes them as bolt text. make_bytecode($dir.'filetobecompiled.php', $dir.'compiled.phb');
Now, compiled file is at compiled.phb.Hi, I'm not understanding where I have to put this code to make it work. Should I put it in a blank file in /path/to/php as you said in the previous comment or in the dir with my project?
Thanks in advance.
Hi,
The code you quoted is the code for BCGen encoder. You use this code in order to encode a file containing PHP code into BCGen Bytecode. You don't need this code when distributing your encoded file to different places, just on your development environment.
sorry i never use bcompiler or bcgen, any page or site how to use this ? thanks ..