进程伪装
修改指定进程环境块中的进程路径以及命令行信息,从而达到进程 伪装的效果。
- 获取进程的句柄
- 内联汇编获取peb
- 修改命令行和imagepath
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #include<windows.h> #include<winternl.h>
BOOL DisguiseProcess(wchar_t *lpwszPath, wchar_t *lpwszCmd);
int main() { wchar_t *lpwszPath = L"c:\\windows\\system32\\calc.exe"; wchar_t *lpwszCmd = L"yeanhoo's calc"; DisguiseProcess(lpwszPath, lpwszCmd); system("pause"); }
BOOL DisguiseProcess(wchar_t *lpwszPath, wchar_t *lpwszCmd) { HANDLE hProcess = GetModuleHandle(NULL);
PPEB peb = { 0 }; USHORT usCmdLen = 0; USHORT usPathLen = 0; __asm { mov eax,fs:[30h] mov peb,eax }
usCmdLen = 2 + 2 * wcslen(lpwszCmd); (*peb).ProcessParameters->CommandLine.Buffer = lpwszCmd; (*peb).ProcessParameters->CommandLine.Length = usCmdLen;
usPathLen = 2 + 2 * wcslen(lpwszPath); (*peb).ProcessParameters->ImagePathName.Buffer = lpwszPath; (*peb).ProcessParameters->ImagePathName.Length = usPathLen;
return TRUE; }
|
