pk-fr / yakpro-po

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

Lambda captured variables are not scrambled #8

Closed mologie closed 8 years ago

mologie commented 8 years ago

Test case:

<?php
$mapTable = [1=>2, 2=>3, 3=>4];
$input    = [1, 2, 3];
$result   = array_map(function ($elem) use ($mapTable) {
    return $mapTable[$elem];
}, $input);
// $result is now [2, 3, 4]

Example output:

$ yakpro-po testUseScrambling.php --no-strip-indentation --no-shuffle-statements 
<?php

$pc7UO = array(1 => 2, 2 => 3, 3 => 4);
$Vb40o = array(1, 2, 3);
$MO9uG = array_map(function ($lCrNn) use($mapTable) {
    return $pc7UO[$lCrNn];
}, $Vb40o);

The obfuscator should have emitted $pc7UO instead of $mapTable for the code to be equivalent to the input.

pk-fr commented 8 years ago

fixed in 1.8.2 (I hope lol) small test cases like you do are very efficient for targeting fixes. thanks again

mologie commented 8 years ago

Thanks, that did the trick.