pk-fr / yakpro-po

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

!is_dir_writeable gets encrypted even if it's a primitive #57

Closed andthink closed 4 years ago

andthink commented 4 years ago

Hi I got a fatal error trying to encrypt e file with this function in it because yakpro renames !is_dir_writeable() to vcLmF()

My original code

<?php

class Tbuy_Imageflow_Model_From_Imageflow extends Tbuy_Flow_Model_From_Abstract
{
    const PROCESSED_IMAGES_DIR = 'processed';

    protected function getProcessedImagesDir() {
        $processed_images_dir = $this->getImagesPath().
            self::PROCESSED_IMAGES_DIR . DS .
            date('Y', time()) . DS .
            date('m', time()) . DS .
            date('d', time()) . DS;
        if (!is_dir($processed_images_dir)) {
            mkdir($processed_images_dir, 0777, true);
        }

        if (!is_dir_writeable($processed_images_dir)) {
            Mage::helper('imageflow')->log("Can not move processed photo to processed dir. Directory is not writable: {$processed_images_dir}");

            return null;
        }

        return $processed_images_dir;
    }

}

The converted code

<?php

class Tbuy_Imageflow_Model_From_Imageflow extends Tbuy_Flow_Model_From_Abstract
{
    const PROCESSED_IMAGES_DIR = "\x70\162\x6f\x63\x65\x73\x73\x65\144";
    protected function getProcessedImagesDir()
    {
        goto kGds_;
        kknU7:
        mkdir($SlSU7, 0777, true);
        goto gZmxS;
        hocLc:
        Gw1y_:
        goto nPOXa;
        f8qY3:
        return null;
        goto hocLc;
        kGds_:
        $SlSU7 = $this->getImagesPath() . self::PROCESSED_IMAGES_DIR . DS . date("\x59", time()) . DS . date("\155", time()) . DS . date("\144", time()) . DS;
        goto zREWq;
        gZmxS:
        lOHav:
        goto rvtAR;
        zREWq:
        if (is_dir($SlSU7)) {
            goto lOHav;
        }
        goto kknU7;
        rvtAR:
        if (vcLmF($SlSU7)) {
            goto Gw1y_;
        }
        goto D0fGD;
        D0fGD:
        Mage::helper("\x69\155\141\147\x65\x66\154\x6f\167")->log("\103\x61\156\x20\x6e\157\x74\x20\x6d\157\x76\x65\x20\160\x72\157\x63\x65\163\x73\x65\144\40\x70\150\x6f\x74\157\40\x74\157\x20\160\x72\157\143\145\163\163\145\x64\40\144\151\x72\56\40\x44\x69\x72\x65\x63\164\157\162\x79\x20\x69\x73\40\156\157\164\40\x77\162\151\164\x61\x62\x6c\x65\x3a\x20{$SlSU7}");
        goto f8qY3;
        nPOXa:
        return $SlSU7;
        goto p2_w3;
        p2_w3:
    }
}

This is the configuration used

yakpro-po.cnf

I've worked around it by setting

$conf->t_ignore_functions = ['is_dir_writeable']

Thank you very much Andrea

pk-fr commented 4 years ago

not a bug: is_dir_writeable() is not a php function!

andthink commented 4 years ago

ahhh thanks! Totally missed that :-)