Skip to content

Instantly share code, notes, and snippets.

@alexandernst
Created March 21, 2014 09:09
Show Gist options
  • Save alexandernst/9682418 to your computer and use it in GitHub Desktop.
Save alexandernst/9682418 to your computer and use it in GitHub Desktop.
Detect eval calls using PHP's parser
<?php
//Usage: php detect.php /path/to/file.php
$data = file_get_contents($argv[1]);
$tokens = token_get_all($data);
foreach($tokens as $token){
if($token[0]==T_EVAL){
echo "Eval found in file " . $argv[1] . " on line: " . $token[2] . "\n";
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment