pk-fr / yakpro-po

YAK Pro - Php Obfuscator
http://www.php-obfuscator.com
Other
1.29k stars 363 forks source link

Obfuscate project with composer autoload #13

Closed CrCs2O4 closed 8 years ago

CrCs2O4 commented 8 years ago

Hi, Pascal! First of all - thanks a lot for YAK Pro, it's the best php obfuscator, I saw on github.

Need some help to work it out with my current project, that use composer autoload https://getcomposer.org/doc/01-basic-usage.md#autoloading

Before obfuscation: vendor/composer/autoload_real.php

class ComposerAutoloaderInitcef6ac477e716f5e193a43f09eb4d6a4
{
    private static $loader;
    public static function loadClassLoader($class)
    {
        if ('Composer\Autoload\ClassLoader' === $class) {
            require __DIR__ . '/ClassLoader.php';
        }
    }
    public static function getLoader()
    {
        if (null !== self::$loader) {
            return self::$loader;
        }
        spl_autoload_register(array('ComposerAutoloaderInitcef6ac477e716f5e193a43f09eb4d6a4', 'loadClassLoader'), true, true);
        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
        spl_autoload_unregister(array('ComposerAutoloaderInitcef6ac477e716f5e193a43f09eb4d6a4', 'loadClassLoader'));

After obfuscation vendor/composer/autoload_real.php

class It72Z
{
    private static $nCiZ5;
    public static function BYb7h($FP2VQ)
    {
1        if ('Composer\\Autoload\\ClassLoader' === $FP2VQ) {
            require __DIR__ . '/ClassLoader.php';
        }
    }
    public static function b80JC()
    {
        if (null !== self::$nCiZ5) {
            return self::$nCiZ5;
        }
2        spl_autoload_register(array('ComposerAutoloaderInitcef6ac477e716f5e193a43f09eb4d6a4', 'loadClassLoader'), true, true);
        self::$nCiZ5 = $r2XDu = new \I_myr\xeXKb\z2cFF();
        spl_autoload_unregister(array('ComposerAutoloaderInitcef6ac477e716f5e193a43f09eb4d6a4', 'loadClassLoader'));

It need's to be:

1 if ('I_myr\xeXKb\z2cFF' === $FP2VQ) {
2 spl_autoload_register(array('It72Z', 'BYb7h'), true, true);

and so on. When I corrected this file myself and go deeper - there are more errors like this in files, that are automatic generated by composer.

So my question is - Did you try to obfuscate projects, that use composer? If yes, what settings I need to make in yakpro-po.cnf to make it work? Maybe add some standard composer classes in t_ignore_pre_defined_classes?

Thanks!

pk-fr commented 8 years ago

Hi,

I've never used composer so far... But the following is true with every piece of non-obfuscated software that your obfuscated software uses.

All shared items ( classes, vars, functions, etc.) has to be ignored using the $conf->t_ignore_xxx arrays of your yakpro-po.cnf file.

that means:

another option is to obfuscate all software pieces that you use along with your software...

CrCs2O4 commented 8 years ago

you need to try composer it's de facto standard dependency manager for php & would be great if YAK Pro correctly obfuscate it from the box without issues.

I'm trying to obfuscate all software pieces INCLUDING composer. The easiest way example (simple micro-framework):

<?php
require 'vendor/autoload.php';

Flight::route('/', function () {
    echo 'Hello World!';
});

Flight::start();

Thanks a lot!

pk-fr commented 8 years ago

Hi, thanks for your advice, I will have a look one day when I have time... but so far, I am overloaded, and do not have time to deal with 3rd party frameworks... somebody has already asked me for the same things concerning wordpress plugins...

If you want to create and maintain a repository with specific out of the box yakpro-po.cnf files for each available framework, it's up to you... ...and I will be very happy to provide a link to your repository!

Please read carefully the "YOU MUST BE AWARE OF THE FOLLOWING" and "Hints for preparing your Software to be run obfuscated" sections of https://github.com/pk-fr/yakpro-po/blob/master/README.md .

your specific yakpro-po.cnf file for a specific framework must be edited by the final user, adding to the t_ignore_xxx all item that are indirectly called by the framework. (for ex: all the function names you register using a string that represents the function name)

cheers, Pascal

dzpt commented 7 years ago

@CrCs2O4 Did you find the way to work with composer?