阅读:3502回复:19
快过年了,放段irpHook的代码~
NTSTATUS FASTCALL
NewpIofCallDriver( IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp ) { NTSTATUS stat; DbgPrint("Hacked Great!"); //Code Deleted __asm { mov ecx,DeviceObject mov edx,Irp Call old_piofcalldriver mov stat,eax } return stat; } NTSTATUS DriverIoControl( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { PIO_STACK_LOCATION pisl; NTSTATUS ns = STATUS_UNSUCCESSFUL; ULONG BuffSize, DataSize; PVOID pBuff, pData,pInout; KIRQL OldIrql; ULONG i; pisl = IoGetCurrentIrpStackLocation (Irp); BuffSize = pisl->Parameters.DeviceIoControl.OutputBufferLength; pBuff = Irp->AssociatedIrp.SystemBuffer; Irp->IoStatus.Information = 0; switch(pisl->Parameters.DeviceIoControl.IoControlCode) { case IOCTL_DISABLE: { //Code Deleted ns = STATUS_SUCCESS; break; } case IOCTL_ENABLE: { //Code Deleted ns = STATUS_SUCCESS; break; } } Irp->IoStatus.Status = ns; IoCompleteRequest(Irp, IO_NO_INCREMENT); return ns; } NTSTATUS DriverCreateClose( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { Irp->IoStatus.Information = 0; Irp->IoStatus.Status = STATUS_SUCCESS; IoCompleteRequest(Irp, IO_NO_INCREMENT); return STATUS_SUCCESS; } VOID DriverUnload(IN PDRIVER_OBJECT DriverObject) { IoDeleteSymbolicLink(&SymbolicLinkName); IoDeleteDevice(deviceObject); } NTSTATUS DriverClose( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { return DriverCreateClose(DeviceObject,Irp); } NTSTATUS IoComplete( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp) { IoCompleteRequest(Irp,IO_NO_INCREMENT); return STATUS_SUCCESS; } void HookpIofCallDriver() { KIRQL oldIrql; ULONG addr = (ULONG)IofCallDriver; __asm { mov eax,addr mov esi,[eax+2] mov eax,[esi] mov old_piofcalldriver,eax } oldIrql = KeRaiseIrqlToDpcLevel(); __asm{ mov eax,cr0 mov oData,eax and eax,0xffffffff mov cr0,eax mov eax,addr mov esi,[eax+2] mov dword ptr [esi],offset NewpIofCallDriver mov eax,oData mov cr0,eax } KeLowerIrql(oldIrql); return ; } NTSTATUS DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath) { NTSTATUS status; PDRIVER_DISPATCH *ppdd; ULONG i; PCWSTR dDeviceName = L"\\Device\\irphook"; PCWSTR dSymbolicLinkName = L"\\DosDevices\\irphook"; RtlInitUnicodeString(&DeviceName, dDeviceName); RtlInitUnicodeString(&SymbolicLinkName, dSymbolicLinkName); status = IoCreateDevice(DriverObject, 0, &DeviceName, FILE_DEVICE_UNKNOWN, 0, TRUE, &deviceObject); if (!NT_SUCCESS(status)) return status; status = IoCreateSymbolicLink(&SymbolicLinkName, &DeviceName); #ifdef DEBUG DriverObject->DriverUnload = DriverUnload; #endif DriverObject->DriverUnload =0; ppdd = DriverObject->MajorFunction; for(i =0;i<=IRP_MJ_MAXIMUM_FUNCTION;i++) ppdd = IoComplete; ppdd [IRP_MJ_CREATE] = DriverCreateClose; ppdd [IRP_MJ_DEVICE_CONTROL ] = DriverIoControl; g_drvobj = DriverObject; HookpIofCallDriver(); return status; } |
|
最新喜欢:hljwb
|
沙发#
发布于:2007-02-13 18:47
完整代码就免了吧~哈哈,Bin更不放了~
|
|
|
板凳#
发布于:2007-02-13 19:48
呜啦啦。。。传说中的Hook IoCallDriver~~
|
|
|
地板#
发布于:2007-02-13 20:07
2k/nt/xp上可以用~但是Windows 2003需要另外方法~
|
|
|
地下室#
发布于:2007-02-13 20:20
呵呵,大家情人节快乐拉
|
|
|
5楼#
发布于:2007-02-13 23:13
hook IofCallDriver以前这个版里有人发过,只不过论坛数据丢失了~
|
|
6楼#
发布于:2007-02-13 23:36
引用第5楼xyzreg于2007-02-13 23:13发表的“”: 他那个hook太恶心~忍不住的恶心 |
|
|
7楼#
发布于:2007-02-14 09:32
2K3和VISTA下用同样的处理即可,不过64BIT下的不知道该如何做......
|
|
|
8楼#
发布于:2007-02-14 11:58
引用第7楼wowocock于2007-02-14 09:32发表的“”: pIofCallDriver的位置不是那么容易取得的阿~ |
|
|
9楼#
发布于:2007-02-14 12:23
很容易,再说32位下还有什么不能搞定的,相对64BIT,感觉32位下的都好办.....
|
|
|
10楼#
发布于:2007-02-14 12:56
贴个正式通用版的代码:
void HookInWin2003() { kernelbase=(DWORD)getkmod("ntoskrnl.exe"); if(kernelbase==0) { kernelbase=(DWORD)getkmod("ntkrnlmp.exe"); if(kernelbase)DbgPrint("ntkrnlmp multi-processor type kernel detected.\n"); } if(kernelbase==0) { kernelbase=(DWORD)getkmod("ntkrnlpa.exe"); if(kernelbase)DbgPrint("ntkrnlpa PAE type kernel detected.\n"); } if(kernelbase==0) { kernelbase=(DWORD)getkmod("ntkrpamp.exe"); if(kernelbase)DbgPrint("ntkrpamp multi-processor & PAE type kernel detected.\n"); } if(kernelbase==0) return ; hkIoCallDriver = kdetourex((UCHAR*)searchkexport(kernelbase,(DWORD)&("IoCallDriver")),(UCHAR*)HackIoCallDriver); if(!hkIoCallDriver) return; hkPoCallDriver = kdetourex((UCHAR*)searchkexport(kernelbase,(DWORD)&("PoCallDriver")),(UCHAR*)HackPoCallDriver); if(!hkPoCallDriver) return; hkIofCallDriver = kdetourex_savreg((UCHAR*)searchkexport(kernelbase,(DWORD)&("IofCallDriver")),(UCHAR*)HackpIofCallDriver);//savreg不改变寄存器,嘿嘿~ return ; } //Bin也贴上来了,不过精简过了——这样子谁要想用,得自己逆向嘿嘿~ |
|
|
11楼#
发布于:2007-02-14 15:46
把 kdetourex、searchkexport kdetourex_savreg放出来让大家见识一下,前面hook的通用方法谁都存了一大堆。大过年的,谁都想乐呵乐呵,idapro又不是电视,已经懒得看了。C代码比汇编看着舒服。
不过还得谢谢楼主,做了一件利国利民,功在当代,利在千秋的大好事。应该大力弘扬楼主“特别能吃苦”、“特别能战斗”、”特别能攻关““特别能奉献”的驱动开发精神。 |
|
12楼#
发布于:2007-02-14 16:32
idapro和电视机差不多吧~
|
|
|
13楼#
发布于:2007-02-14 17:07
逆都不用逆,直接把汇编扣出来,内嵌到自己的代码里面。。。
|
|
|
14楼#
发布于:2007-02-14 17:18
引用第13楼xikug于2007-02-14 17:07发表的“”: ....大邪恶~ |
|
|
15楼#
发布于:2007-02-14 22:29
引用第12楼killvxk于2007-02-14 16:32发表的“”: 经典..... |
|
|
16楼#
发布于:2007-02-15 13:34
引用第13楼xikug于2007-02-14 17:07发表的“”: |
|
17楼#
发布于:2007-02-15 17:05
叫楼上的逆了就跟看电视机一样
|
|
|
18楼#
发布于:2007-02-16 08:58
准备好刀子,看准MJ,xyzreg,wowocock,cardmagic,doskey准备放血~
|
|
|
19楼#
发布于:2007-02-28 10:38
pIofCallDriver 的地址在 2003 下咋取 ?
|
|
|