Last active
October 1, 2016 09:11
-
-
Save ahsankhatri/2f0d6ed9048c9f1e27df430897241eab to your computer and use it in GitHub Desktop.
Analyze called function with non-standard php feature to enhance functionality on expected result by caller-identifier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo ''; /* sdfds */ echo ''; ;; ! phpMagic(); // echo $i; ?> <?php | |
;;; +phpMagic(); // $increment with 1; | |
@phpMagic(); // $increment with 1; | |
/* $decrement with 1 ;;; */-phpMagic();// $decrement with 1; | |
/* comment ;;; */ \phpMagic(); /* another comment ;;; */ \phpMagic(); // $decrement with 1; | |
function phpMagic() { | |
$poped = array_pop(debug_backtrace()); | |
$fullLine = file($poped['file'])[$poped['line']-1]; | |
foreach (explode(';', $fullLine) as $statements) { | |
if (preg_match('%(.\s*'.$poped['function'].')\s*\(%', $statements, $match) ) { | |
$statement = trim($match[1]); | |
} | |
} | |
// called with substr( $statement, 0, 1 ); ! @ + - \ | |
echo $statement . '<br />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment