20-02-2010, 10:12 PM
السلام عليكم
واجهت مشكلة أثناء تحميل ZwCreateFileHook هذا كود الدريفر من موقع :rtfm: KMD
السؤال هنا أن صاحب الموضوع و المشاركين نجحو في تشغيله دون Bsod
على عكسي :frusty: لدا أعدة مراجعه الموضوع, هل من الممكن :
الداكرة المخصصة لـ SSDT داكرة للقراءة فقط , و نحن نريد التغير في مسار الإستدعاء :crazy:؟؟.
واجهت مشكلة أثناء تحميل ZwCreateFileHook هذا كود الدريفر من موقع :rtfm: KMD
PHP كود :
unit ZwCreateFileHook;
interface
uses
nt_status, ntoskrnl, native, winioctl,fcall, macros;
function _DriverEntry(pDriverObject: PDRIVER_OBJECT;
pusRegistryPath: PUNICODE_STRING): NTSTATUS; stdcall;
implementation
type
TfnZwCreateFile = function(FileHandle: PHANDLE; DesiredAccess: ACCESS_MASK;
ObjectAttributes: POBJECT_ATTRIBUTES; IoStatusBlock: PIO_STATUS_BLOCK;
AllocationSize: PLARGE_INTEGER; FileAttributes: ULONG; ShareAccess: ULONG;
CreateDisposition: ULONG; CreateOptions: ULONG; EaBuffer: PVOID;
EaLength: ULONG): NTSTATUS; stdcall;
var
m_UserTime : LARGE_INTEGER;
m_KernelTime : LARGE_INTEGER;
o_ZwCreateFile : TfnZwCreateFile;
g_pmdlSystemCall: PMDL;
MappedSystemCallTable: Pointer;
lpKeServiceDescriptorTable: PServiceDescriptorEntry;
function GetImportFunAddr(lpImportAddr: Pointer): Pointer; stdcall;
begin
Result := PPointer(PPointer(Cardinal(lpImportAddr) + 2)^)^;
end;
function SystemServiceName(AFunc: Pointer): PLONG; stdcall;
begin
Result := PLONG(Cardinal(lpKeServiceDescriptorTable^.ServiceTableBase) + (SizeOf(ULONG)
* PULONG(ULONG(AFunc) + 1)^));
end;
function NewZwCreateFile(FileHandle: PHANDLE; DesiredAccess: ACCESS_MASK;
ObjectAttributes: POBJECT_ATTRIBUTES; IoStatusBlock: PIO_STATUS_BLOCK;
AllocationSize: PLARGE_INTEGER; FileAttributes: ULONG; ShareAccess: ULONG;
CreateDisposition: ULONG; CreateOptions: ULONG; EaBuffer: PVOID;
EaLength: ULONG): NTSTATUS; stdcall;
begin
DbgPrint('NewZwCreateFile enter ...');
Result := o_ZwCreateFile(FileHandle, DesiredAccess, ObjectAttributes,
IoStatusBlock, AllocationSize, FileAttributes, ShareAccess,
CreateDisposition, CreateOptions, EaBuffer, EaLength);
DbgPrint('NewZw Leave.');
end;
procedure OnUnload(pDriverObject: PDRIVER_OBJECT); stdcall;
begin
DbgPrint('ROOTKIT: OnUnload called'#13#10);
InterlockedExchange(SystemServiceName(GetImportFunAddr(@ZwCreateFile)),
LONG(@o_ZwCreateFile));
if g_pmdlSystemCall <> nil then
begin
MmUnmapLockedPages(MappedSystemCallTable, g_pmdlSystemCall);
IoFreeMdl(g_pmdlSystemCall);
end;
end;
function _DriverEntry(pDriverObject: PDRIVER_OBJECT;
pusRegistryPath: PUNICODE_STRING): NTSTATUS;stdcall;
begin
lpKeServiceDescriptorTable := GetImportFunAddr(@KeServiceDescriptorTable);
pDriverObject^.DriverUnload := @OnUnload;
DbgPrint('ROOTKIT: load called'#13#10);
m_UserTime.QuadPart := 0;
m_KernelTime.QuadPart := 0;
o_ZwCreateFile :=
TfnZwCreateFile(SystemServiceName(GetImportFunAddr(@ZwCreateFile)));
g_pmdlSystemCall := MmCreateMdl(nil, lpKeServiceDescriptorTable^.ServiceTableBase,
lpKeServiceDescriptorTable^.NumberOfServices * 4);
if g_pmdlSystemCall = nil then
begin
Result := STATUS_UNSUCCESSFUL;
Exit;
end;
MmBuildMdlForNonPagedPool(g_pmdlSystemCall);
g_pmdlSystemCall^.MdlFlags := g_pmdlSystemCall^.MdlFlags or MDL_MAPPED_TO_SYSTEM_VA;
MappedSystemCallTable := MmMapLockedPages(g_pmdlSystemCall, KernelMode);
o_ZwCreateFile :=
TfnZwCreateFile(InterlockedExchange(SystemServiceName(GetImportFunAddr(@ZwCreateFile)),
LONG(@NewZwCreateFile)));
Result := STATUS_SUCCESS;
end;
end.
على عكسي :frusty: لدا أعدة مراجعه الموضوع, هل من الممكن :
الداكرة المخصصة لـ SSDT داكرة للقراءة فقط , و نحن نريد التغير في مسار الإستدعاء :crazy:؟؟.
I'M Fly Like A G6

