|
|
|
进程监控
这样可否·!?? // 自定义函数的声明 NTSTATUS DispatchCreateClose(PDEVICE_OBJECT pDevObj, PIRP pIrp); void DriverUnload(PDRIVER_OBJECT pDriverObj); NTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp); VOID ProcessCallback(IN HANDLE hParentId, IN HANDLE hProcessId, IN BOOLEAN bCreate); // 驱动内部名称、符号连接名称、事件对象名称 #define DEVICE_NAME L"\\Device\\devNTProcDrv" #define LINK_NAME L"\\DosDevices\\slNTProcDrv" #define EVENT_NAME L"\\BaseNamedObjects\\NTProcDrvProcessEvent" typedef struct _DEVICE_EXTENSION // 设备对象的私有存储 { HANDLE hProcessHandle; // 事件对象句柄 PKEVENT ProcessEvent; // 用户和内核通信的事件对象指针 HANDLE hPParentId; // 在回调函数中保存进程信息,当用户程序请求时,传递过去 HANDLE hPProcessId; BOOLEAN bPCreate; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; PDEVICE_OBJECT g_pDeviceObject; // 驱动程序加载时调用DriverEntry例程 extern "C" NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObj, PUNICODE_STRING pRegistryString) { NTSTATUS status = STATUS_SUCCESS; // 初始化各个派遣例程 pDriverObj->MajorFunction[IRP_MJ_CREATE] = DispatchCreateClose; pDriverObj->MajorFunction[IRP_MJ_CLOSE] = DispatchCreateClose; pDriverObj->MajorFunction[IRP_MJ_DEVICE_CONTROL] = DispatchIoctl; pDriverObj->DriverUnload = DriverUnload; // 创建、初始化设备对象 // 设备名称 UNICODE_STRING ustrDevName; RtlInitUnicodeString(&ustrDevName, DEVICE_NAME); // 创建设备对象 PDEVICE_OBJECT pDevObj; status = IoCreateDevice(pDriverObj, sizeof(DEVICE_EXTENSION), // 为设备扩展结构申请空间 &ustrDevName, FILE_DEVICE_UNKNOWN, 0, FALSE, &pDevObj); if(!NT_SUCCESS(status)) { return status; } PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)pDevObj->DeviceExtension; // 创建符号连接名称 // 符号连接名称 UNICODE_STRING ustrLinkName; RtlInitUnicodeString(&ustrLinkName, LINK_NAME); // 创建关联 status = IoCreateSymbolicLink(&ustrLinkName, &ustrDevName); if(!NT_SUCCESS(status)) { IoDeleteDevice(pDevObj); return status; } // 保存到设备对象的指针,下面在进程回调函数中还要使用 g_pDeviceObject = pDevObj; // 为了用户模式进程能够监视,创建事件对象 UNICODE_STRING uszProcessEventString; RtlInitUnicodeString(&uszProcessEventString, EVENT_NAME); pDevExt->ProcessEvent = IoCreateNotificationEvent(&uszProcessEventString, &pDevExt->hProcessHandle); // 设置它为非受信状态 KeClearEvent(pDevExt->ProcessEvent); // 设置回调例程 status = PsSetCreateProcessNotifyRoutine(ProcessCallback, FALSE); return status; } void DriverUnload(PDRIVER_OBJECT pDriverObj) { DbgPrint("Driver Unload\n"); // 移除进程回调例程 PsSetCreateProcessNotifyRoutine(ProcessCallback, TRUE); // 删除符号连接名称 UNICODE_STRING strLink; RtlInitUnicodeString(&strLink, LINK_NAME); IoDeleteSymbolicLink(&strLink); // 删除设备对象 IoDeleteDevice(pDriverObj->DeviceObject); } // 处理IRP_MJ_CREATE、IRP_MJ_CLOSE功能代码 NTSTATUS DispatchCreateClose(PDEVICE_OBJECT pDevObj, PIRP pIrp) { pIrp->IoStatus.Status = STATUS_SUCCESS; // 完成此请求 IoCompleteRequest(pIrp, IO_NO_INCREMENT); return STATUS_SUCCESS; } // I/O控制派遣例程 NTSTATUS DispatchIoctl(PDEVICE_OBJECT pDevObj, PIRP pIrp) { DbgPrint(" ProcDrv: DispatchIoctl()... \n"); // 假设失败 NTSTATUS status = STATUS_INVALID_DEVICE_REQUEST; // 取得此IRP(pIrp)的I/O堆栈指针 PIO_STACK_LOCATION pIrpStack = IoGetCurrentIrpStackLocation(pIrp); // 取得设备扩展结构指针 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)pDevObj->DeviceExtension; // 取得I/O控制代码 ULONG uIoControlCode = pIrpStack->Parameters.DeviceIoControl.IoControlCode; // 取得I/O缓冲区指针和它的长度 PCALLBACK_INFO pCallbackInfo = (PCALLBACK_INFO)pIrp->AssociatedIrp.SystemBuffer; ULONG uInSize = pIrpStack->Parameters.DeviceIoControl.InputBufferLength; ULONG uOutSize = pIrpStack->Parameters.DeviceIoControl.OutputBufferLength; switch(uIoControlCode) { case IOCTL_NTPROCDRV_GET_PROCINFO: // 向用户程序返回有事件发生的进程的信息 { if(uOutSize >= sizeof(CALLBACK_INFO)) { pCallbackInfo->hParentId = pDevExt->hPParentId; pCallbackInfo->hProcessId = pDevExt->hPProcessId; pCallbackInfo->bCreate = pDevExt->bPCreate; status = STATUS_SUCCESS; } } break; } if(status == STATUS_SUCCESS) { pIrp->IoStatus.Information = uOutSize; } else { pIrp->IoStatus.Information = 0; } // 完成请求 pIrp->IoStatus.Status = status; IoCompleteRequest(pIrp, IO_NO_INCREMENT); return status; } // 进程回调函数 VOID ProcessCallback(IN HANDLE hParentId, IN HANDLE hProcessId, IN BOOLEAN bCreate) { DbgPrint("Call ProcessCallback()\n"); // 得到设备扩展结构的指针 PDEVICE_EXTENSION pDevExt = (PDEVICE_EXTENSION)g_pDeviceObject->DeviceExtension; // 安排当前值到设备扩展结构 // 用户模式应用程序将使用DeviceIoControl调用把它取出 pDevExt->hPParentId = hParentId; pDevExt->hPProcessId = hProcessId; pDevExt->bPCreate = bCreate; if(pDevExt->bPCreate) { DbgPrint("create: %d\n",pDevExt->hPProcessId); } else { DbgPrint("Kill: %d\n",pDevExt->hPProcessId); } // 触发这个事件,以便任何正在监听的用户程序知道有事情发生了。 // 用户模式下的应用程序不能重置KM事件,所以我们要在这里触发它 KeSetEvent(pDevExt->ProcessEvent, 0, FALSE); KeClearEvent(pDevExt->ProcessEvent); } |
|
类似360TimeProt的C代码谁有? 我翻山越岭找遍了大山也没搜到.
SSDT HOOK NtSetSystemTime就OK了哦·! .386 .model flat,stdcall option casemap:none include systest.inc _NTSetSystemTime typedef proto :PLARGE_INTEGER,:PLARGE_INTEGER NTSetSystemTime typedef ptr _NTSetSystemTime .data oldNtFunAddr NTSetSystemTime NULL ;旧函数地址 oldNtFunSrvID dd 0 ;旧NT函数服务号 tmpBuf db 512 dup(NULL) zwFunctionName UNICODE_STRING <> ;被HOOK函数名 .code MyZwSetSystemTime proc newTime:PLARGE_INTEGER,oldTime:PLARGE_INTEGER invoke DbgPrint,$CTA0("Reject Update Local Time\n") mov eax,STATUS_UNSUCCESSFUL ret MyZwSetSystemTime endp UnHook proc oldFunctionAddress:dword,oldFunctionPoint:dword ;卸载HOOK pushad invoke DbgPrint,$CTA0("UnHook \n") call WPOFF mov esi,oldFunctionAddress mov eax,oldFunctionPoint mov dword ptr[esi],eax ;还原旧的函数地址 call WPON popad ret UnHook endp SetHook proc NtServerID:dword,NewFunAddr:dword ;设置HOOK LOCAL oldAddr:dword invoke DbgPrint,$CTA0("SetHook \n") mov esi,NtServerID mov edi,dword ptr[esi] mov oldAddr,edi ;保存旧函数地址 mov edi,NewFunAddr ;自己的函数偏移 call WPOFF mov dword ptr[esi],edi ;替换成我们自己的函数 call WPON mov eax,oldAddr ret SetHook endp GetZwFunctionAddr proc uniZwFunName:PUNICODE_STRING ;获取ZW系列导出函数地址 LOCAL funAddr:dword call WPOFF invoke MmGetSystemRoutineAddress,uniZwFunName ;$CCOUNTED_UNICODE_STRING("ZwSetSystemTime") mov funAddr,eax call WPON mov eax,funAddr ret GetZwFunctionAddr endp GetNtFunctionServerID proc uniZwFunName:PUNICODE_STRING ;获取ZW对应的NT函数服务号 mov eax,KeServiceDescriptorTable ;获取KeServiceDescriptorTable的地址 mov esi,[eax] mov esi,[esi] ;获取KeServiceDescriptorTable->ServiceTableBase invoke GetZwFunctionAddr,uniZwFunName ;获取被HOOK函数的地址 inc eax movzx ecx,byte ptr[eax] ;取被HOOK函数服务号 sal ecx,2 add esi,ecx mov eax,esi ret GetNtFunctionServerID endp WPOFF proc ;关闭内存保护 cli mov eax,cr0 xor eax,10000h mov cr0,eax ret WPOFF endp WPON proc ;开启内存保护 mov eax, cr0 xor eax,10000h mov cr0, eax sti ret WPON endp DriverUnload proc pDriverObject:PDRIVER_OBJECT invoke DbgPrint,$CTA0("Driver UnLoad \n") invoke UnHook,oldNtFunSrvID,oldNtFunAddr ret DriverUnload endp DriverEntry proc pDriverObject:PDRIVER_OBJECT,pRegistryPath:PUNICODE_STRING pushad invoke DbgPrint,$CTA0("Load Driver Success\n") invoke RtlInitUnicodeString,addr zwFunctionName,$CTW0("ZwSetSystemTime") invoke GetNtFunctionServerID,addr zwFunctionName mov oldNtFunSrvID,eax invoke SetHook,oldNtFunSrvID,offset MyZwSetSystemTime mov oldNtFunAddr,eax invoke DbgPrint,$CTA0("Old NtFunction Address: 0x%08X \n"),oldNtFunAddr invoke DbgPrint,$CTA0("MyZwFunction Address: 0x%08X \n"),offset MyZwSetSystemTime ;输出自己的函数偏移 mov esi,pDriverObject mov [esi+34h],offset DriverUnload ;设置卸载例程 popad mov eax,STATUS_SUCCESS ret DriverEntry endp end DriverEntry |
|
|
|
[原创]从php源码中提取纯C编写的url编解码两函数
不知重庆有木考点哇·!? |
|
|
|
|
|
[求助]弱问,查找xp sp3 未导出函数,Help Me
lkd> dd PspTerminateProcess 805d3b5c 8b55ff8b a16456ec 00000124 3b08758b //可以用这些特征码 |
|
[求助]弱问,查找xp sp3 未导出函数,Help Me
可以根据WINDBG找到的硬编码暴力搜索内存 |
|
|
|
[求助]窗口消息攻击是如何实现的?
void SendBigMsg(HWND hWnd) { Sleep(500); for(int uMsg = 0; uMsg < 10000; uMsg++) { PostMessage(hWnd,uMsg,NULL,NULL); } } 这样就可以实现,函数传递窗口句柄,findwinow之类函数可以得到 |
|
|
|
[分享]秒杀360和QQ管家(等)的驱动代码
貌似~~内存清零~!~!呵呵~~ 不过有个疑问: NTSTATUS PsLookupProcessByProcessId(__in HANDLE ProcessId,__out PEPROCESS *Process); LZ声明的是第一入参是HANDLE 结构 NTSTATUS KillProcessByPID(HANDLE hProcess) 为何KillProcessByPID(XXX); //填写360Safe.exe的PID。 status=PsLookupProcessByProcessId(hProcess,&m_process); //得到指定进程ID的进程环境块 这里入参是PID~~~PID不是ULONG型的么 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值