9908006 发表于 2010-5-23 01:07:01

利用Fltmgr加载驱动

//VC-ConsoleWithApi
#include<stdio.h>
#include<windows.h>
typedef struct _tagLOAD
{
   WORD Len;
   WCHAR ServiceName;
} LOAD , *PLOAD;
#define MAGIC_IOCTL 0x00088004

VOID WINAPI make_reg( LPWSTR szDriverName, LPWSTR szDriverPath )
{
   
   DWORD dwType = SERVICE_KERNEL_DRIVER;
   DWORD dwStart = SERVICE_DEMAND_START;
   HKEY hKey;
   WCHAR szMain = {0};
   WCHAR szImgPath = {0};
   wchar_t szRegPath={0};
   
   wsprintfW( szMain,
      L"%s%s",
      L"SYSTEM\\CurrentControlSet\\Services\\",
      szDriverName );
   
   wsprintfW( szImgPath,
      L"%s%s",
      L"\\??\\",
      szDriverPath);
   
   if( RegCreateKeyW( HKEY_LOCAL_MACHINE, szMain, &hKey ) == ERROR_SUCCESS )
   {
      RegSetValueExW( hKey,
         L"DisplayName",
         0,
         REG_SZ,
         (LPBYTE)szDriverName,
         (DWORD)lstrlenW(szDriverName)*2);
      
      RegSetValueExW( hKey,
         L"ImagePath",
         0,
         REG_EXPAND_SZ,
         (LPBYTE)szImgPath,
         (DWORD)lstrlenW(szImgPath)*2);
      
      RegSetValueExW( hKey,
         L"Type",
         0,
         REG_DWORD,
         (LPBYTE)&dwType,
         (DWORD)sizeof(dwType) );
      
      RegSetValueExW( hKey,
         L"Start",
         0,
         REG_DWORD,
         (LPBYTE)&dwStart,
         (DWORD)sizeof(dwStart) );
      
   }   
}

int main( int argc , char *argv[] )
{
   HANDLE hDevice;
   LOAD service_to_load;
   BOOL err;
   DWORD dwRet=0;
   WCHAR drvPath;
   memset( drvPath , 0 , 512 );
   GetCurrentDirectoryW( MAX_PATH , drvPath );
   lstrcatW( drvPath , L"\\aaa.sys" );
   make_reg( L"aaa" , drvPath );
   hDevice = CreateFile ("\\\\.\\FltMgr" , GENERIC_READ | GENERIC_WRITE , FILE_SHARE_READ | FILE_SHARE_WRITE , NULL , OPEN_EXISTING , FILE_ATTRIBUTE_NORMAL , NULL );
   if( hDevice == INVALID_HANDLE_VALUE )
   {
      printf("CreateFile failed with status : %d\n" , GetLastError() );
      goto __end;
   }
   wcscpy( service_to_load.ServiceName , L"aaa");
   service_to_load.Len = wcslen( service_to_load.ServiceName )*sizeof(WCHAR);
   err = DeviceIoControl( hDevice , MAGIC_IOCTL , &service_to_load , sizeof(service_to_load) , NULL , 0 , &dwRet , NULL );
   if( !err )
   {
      printf("sorry\n");
      goto __end;
   }
   printf(":)\n");
__end:
   CloseHandle( hDevice );
   return 0;
}

9908006 发表于 2010-5-23 01:07:28

不过,还是过不了360的驱动拦截

9908006 发表于 2010-5-23 01:08:03

360貌似很变态,是驱动就拦,除非有正规公司的数字签名

乔丹二世 发表于 2010-5-23 20:46:10

楼主大大能打个包下载吗?

9908006 发表于 2010-5-24 22:16:32

代码打包,直接编译即可

乔丹二世 发表于 2010-5-25 00:09:06

楼主好人啊!

马大哈 发表于 2010-5-25 10:04:41

前段时间不是出了个使用正规数字签名的流氓软件还是病毒么........

折腾得很多杀软头疼.

乔丹二世 发表于 2010-5-25 22:05:33

汗死,VC2008编译出现如下错误:
LoadDrivetByFltmgr.obj : error LNK2019: 无法解析的外部符号 __imp__RegSetValueExW@24,该符号在函数 "void __stdcall make_reg(wchar_t *,wchar_t *)" (?make_reg@@YGXPA_W0@Z) 中被引用
LoadDrivetByFltmgr.obj : error LNK2019: 无法解析的外部符号 __imp__RegCreateKeyW@12,该符号在函数 "void __stdcall make_reg(wchar_t *,wchar_t *)" (?make_reg@@YGXPA_W0@Z) 中被引用
LoadDrivetByFltmgr.obj : error LNK2019: 无法解析的外部符号 __imp__wsprintfW,

oopww 发表于 2010-5-25 22:38:53

不过360,,就是有点杯具!

9908006 发表于 2010-5-29 09:55:07

360现在拦截时,注册服务拦截一次,加载驱动再拦一次,变态,注册服务可以用猥琐流绕过,但是加载驱动时,如果驱动没有数字签名,总是会拦

本网站最菜的人 发表于 2010-5-29 22:32:52

upring 发表于 2015-12-2 11:11:35

好帖子都沉底了 支持一下顶起来吧

q895308300 发表于 2017-3-11 21:37:11

感谢分享
页: [1]
查看完整版本: 利用Fltmgr加载驱动