注册表是启动程序藏身之处最多的地方,主要有以下几项:
1.Run键
Run键是病毒最青睐的自启动之所,该键位置是[HKEY_CURRENT_
USER\Software\Microsoft\Windows\CurrentVersion\Run]和[HKEY_
LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Run],其下的所有程序在每次启动登录时都会按顺序自动执行。
还有一个不被注意的Run键,位于注册表[HKEY_CURRENT_
USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\Run]
和[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
Policies\Explorer\Run],也要仔细查看。
2.RunOnce键
RunOnce位于[HKEY_CURRENT_USER\Software\Microsoft\Windows\
CurrentVersion\RunOnce]和[HKEY_LOCAL_MACHINE\Software\Microsoft\
Windows\CurrentVersion\RunOnce]键,与Run不同的是,RunOnce下的程序仅会被自动执行一次。
3.RunServicesOnce键
RunServicesOnce键位于[HKEY_CURRENT_USER\Software\Microsoft\
Windows\CurrentVersion\RunServicesOnce]和[HKEY_LOCAL_MACHINE\
Software\Microsoft\Windows\CurrentVersion\RunServicesOnce]下,其中的程序会在系统加载时自动启动执行一次。
4.RunServices键
RunServices继RunServicesOnce之后启动的程序,位于注册表[HKEY_CURRENT_USER\
Software\Microsoft\Windows\CurrentVersion\RunServices]和
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
RunServices]键。
5.RunOnceEx键
该键是Windows XP/2003特有的自启动注册表项,位于[HKEY_
CURRENT_USER\\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnceEx]和
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\
RunOnceEx]。
6.load键
[HKEY_CURRENT_USER\Software\Microsoft\WindowsNT\CurrentVersion\Windows]下的load键值的程序也可以自启动。
7.Winlogon键
该键位于位于注册表[HKEY_CURRENT_USER\SOFTWARE\
Microsoft\Windows NT\CurrentVersion\Winlogon]和[HKEY_LOCAL_MACHINE\
SOFTWARE\Microsoft\Windows
NT\CurrentVersion\Winlogon],注意下面的Notify、Userinit、Shell键值也会有自启动的程序,而且其键值可以用逗号分隔,从而实现登录的时候启动多个程序。
8.其他注册表位置
还有一些其他键值,经常会有一些程序在这里自动运行,如:[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\Shell]
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\ShellServiceObjectDelayLoad]
[HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\System\Scripts]
[HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System\Scripts]
小提示:
注册表的[HKEY_LOCAL_MACHINE]和[HKEY_CURRENT_USER]键的区别:前者对所有用户有效,后者只对当前用户有效。
=================================================================
工程1 修改IE主页(实测 此进程运行会被QQ管家拦截)
// StartPage.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include <stdio.h>
//https://www.baidu.com/
//https://news.qq.com/
//用于修改字符串类型键值
void CreateStringReg(HKEY hRoot,char *szSubKey,char* ValueName,char *Data)
{
HKEY hKey;
//打开注册表键,不存在则创建它
long lRet=RegCreateKeyEx(hRoot,szSubKey,0,NULL,REG_OPTION_NON_VOLATILE,KEY_ALL_ACCESS,NULL,&hKey,NULL);
if (lRet!=ERROR_SUCCESS)
{
printf("error no RegCreateKeyEx %s\n", szSubKey);
return ;
}
//修改注册表键值,没有则创建它
lRet=RegSetValueEx(hKey,ValueName,0,REG_SZ,(BYTE*)Data,strlen(Data));
if (lRet!=ERROR_SUCCESS)
{
printf("error no RegSetValueEx %s\n", ValueName);
return ;
}
RegCloseKey(hKey);
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
//要修改成的网址
char StartPage[255]="https://news.qq.com/";
//调用修改字符串类型键值的函数
CreateStringReg(HKEY_CURRENT_USER,"Software\\Microsoft\\Internet Explorer\\Main","Start Page",StartPage);
return 0;
}