阅读:2313回复:2
进程创建监控代码在构思上存在严重缺陷,改用个循环链表保存一组数据(ring3fun,UserAddress,pevent)可能会好点, NTSTATUS newNtCreateProcessEx( OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN HANDLE ParentProcess, IN BOOLEAN InheritObjectTable, IN HANDLE SectionHandle OPTIONAL, IN HANDLE DebugPort OPTIONAL, IN HANDLE ExceptionPort OPTIONAL, IN HANDLE Unknown ) { ANSI_STRING ansiname; NTSTATUS rc; CHAR aProcessName[20]; PSECTION pSection=NULL; PSEGMENT pSegment=NULL; PCONTROL_AREA pControl=NULL; PFILE_OBJECT pFile=NULL; GetProcessName( aProcessName ); DbgPrint("create process from %s \n", aProcessName); rc=ObReferenceObjectByHandle( SectionHandle, 0, NULL, KernelMode, &pSection, NULL ) ; if(NT_SUCCESS(rc)) { pSegment=pSection->Segment; pControl=pSegment->ControlArea; pFile=pControl->FilePointer; RtlUnicodeStringToAnsiString(&ansiname, &(pFile->FileName), TRUE ); ansiname.Buffer[ansiname.Length+1]=0x00; ObDereferenceObject(pSection); if(!_stricmp(ansiname.Buffer,"\\windows\\system32\\dwwin.exe")) //这里可以改为去查询被我们信任的列表,省得每次都跳出个烦人的对话框问我们同意创建不 { return oldNtCreateProcessEx(ProcessHandle, DesiredAccess,ObjectAttributes ,ParentProcess,InheritObjectTable, SectionHandle , DebugPort , ExceptionPort , Unknown ); } if(!pring3 || !UserAddress) { return oldNtCreateProcessEx(ProcessHandle, DesiredAccess,ObjectAttributes ,ParentProcess,InheritObjectTable, SectionHandle , DebugPort , ExceptionPort , Unknown ); } pring3->wait=1; pring3->flag=0; memcpy(pring3->procname,ansiname.Buffer,ansiname.Length+1); memcpy(pring3->formname,aProcessName,20); KeResetEvent(pevent);// if(SendApcQuest(thandle,(PVOID)ring3fun,UserAddress)) KeWaitForSingleObject(pevent, Executive, KernelMode, TRUE, NULL); DbgPrint("---^_^---"); if(pring3->flag==0) { rc = oldNtCreateProcessEx(ProcessHandle, DesiredAccess,ObjectAttributes ,ParentProcess,InheritObjectTable, SectionHandle , DebugPort , ExceptionPort , Unknown ); return rc; } else { ZwClose(SectionHandle); rc=0xC00000A9; return rc; } } rc = oldNtCreateProcessEx(ProcessHandle, DesiredAccess,ObjectAttributes ,ParentProcess,InheritObjectTable, SectionHandle , DebugPort , ExceptionPort , Unknown ); //如果仅仅是想监视进程的创建,从ProcessHandle得到想要的信息,IS应该的监视进程应该是 //IS会恢复这个hook后再hook这个函数(为什么不保存我们的代码,然后hook呢),无奈的我们只能去PspCreateProcess(DS禁止进程创建会不会在这里呢^~^) //回到r3 return rc; } |
|
沙发#
发布于:2007-07-27 18:49
很不错:)
请问楼主:如何获得被创建进程的PID。就在主线程创建之前ntcreatethread之前 |
|
板凳#
发布于:2007-08-20 13:29
不错,学习中。。。。
|
|