<?php
$code = <<<CODE
ff\\bunction f() {}
CODE;
$funcs_internal = get_defined_functions()['internal'];
/* lets allow some secure funcs here */
unset ($funcs_internal[array_search('strlen', $funcs_internal)]);
unset ($funcs_internal[array_search('print', $funcs_internal)]);
unset ($funcs_internal[array_search('strcmp', $funcs_internal)]);
unset ($funcs_internal[array_search('strncmp', $funcs_internal)]);
$funcs_extra = array ('eval', 'include', 'require', 'function');
$funny_chars = array ('\.', '\+', '-', '\*', '"', '`', '\[', '\]');
$variables = array ('_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_FILES', '_ENV', 'HTTP_ENV_VARS', '_SESSION', 'GLOBALS');
$blacklist = array_merge($funcs_internal, $funcs_extra, $funny_chars, $variables);
$insecure = false;
foreach ($blacklist as $blacklisted) {
if (preg_match ('/' . $blacklisted . '/im', $code)) {
$insecure = $blacklisted;
break;
}
}
if ($insecure) {
var_dump($insecure);
} else {
eval ($code);
}
- Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
- Parse error: syntax error, unexpected identifier "f" in /in/MJCWE(32) : eval()'d code on line 1
Process exited with code 255. - Output for 7.0.0 - 7.0.31, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
- Parse error: syntax error, unexpected 'f' (T_STRING) in /in/MJCWE(32) : eval()'d code on line 1
Process exited with code 255. - Output for 5.6.38
- Parse error: syntax error, unexpected 'f' (T_STRING) in /in/MJCWE(32) : eval()'d code on line 1
preferences:
192.37 ms | 401 KiB | 216 Q