WEB开发网
开发学院网络安全安全技术 详解如何利用Windows设备驱动 阅读

详解如何利用Windows设备驱动

 2009-02-12 13:55:33 来源:WEB开发网   
核心提示: /*wdl.c*/#defineUNICODE#include#include#includevoidinstall_driver(SC_HANDLEsc,wchar_t*name){SC_HANDLEservice;wchar_tpath[512];wchar_t*fp;if(GetFu

   /*wdl.c*/
  #defineUNICODE
  #include 
  #include 
  #include 
  voidinstall_driver(SC_HANDLEsc,wchar_t*name)
  {
  SC_HANDLEservice;
  wchar_tpath[512];
  wchar_t*fp;
  if(GetFullPathName(name,512,path,&fp)==0)
  {
  printf("[-]Error:GetFullPathName()failed,error=%dn",GetLastError());
  return;
  }
  service=CreateService(sc,name,name,SERVICE_ALL_ACCESS,
  SERVICE_KERNEL_DRIVER,
  SERVICE_DEMAND_START,
  SERVICE_ERROR_NORMAL,path,NULL,NULL,NULL,
  NULL,NULL);
  if(service==NULL)
  {
  printf("[-]Error:CreateService()failed,error%dn",GetLastError());
  return;
  }
  printf("[+]Creatingservice-success.n");
  CloseServiceHandle(sc);
  if(StartService(service,1,(constunsignedshort**)&name)==0)
  {
  printf("[-]Error:StartService()failed,error%dn",GetLastError());
  if(DeleteService(service)==0)
  printf("[-]Error:DeleteService()failed,error=%dn",GetLastError());
  return;
  }
  printf("[*]Staringservice-success.n");
  CloseServiceHandle(service);
  }
  voiddelete_driver(SC_HANDLEsc,wchar_t*name)
  {
  SC_HANDLEservice;
  SERVICE_STATUSstatus;
  service=OpenService(sc,name,SERVICE_ALL_ACCESS);
  if(service==NULL)
  {
  printf("[-]Error:OpenService()failed,error=%dn",GetLastError());
  return;
  }
  printf("[+]Openingservice-success.n");
  if(ControlService(service,SERVICE_CONTROL_STOP,&status)==0)
  {
  printf("[-]Error:ControlService()failed,error=%dn",GetLastError());
  return;
  }
  printf("[+]Stoppingservice-success.n");
  if(DeleteService(service)==0){
  printf("[-]Error:DeleteService()failed,error=%dn",GetLastError());
  return;
  }
  printf("[+]Deletingservice-successn");
  CloseServiceHandle(sc);
  }
  intmain(intargc,char*argv[])
  {
  intm,b;
  SC_HANDLEsc;
  wchar_tname[MAX_PATH];
  printf("[+]WindowsdriverloaderbyPiotrBaniann");
  if(argc!=3)
  {
  printf("[!]Usage:wdl.exe(/l|/u)driver.sysn");
  printf("[!]/l-loadthedrivern");
  printf("[!]/u-unloadthedrivern");
  getch();
  return0;
  }
  if(strcmp(argv[1],"/l")==0)
  m=0;
  else
  m=1;//defaultuninstallmode
  sc=OpenSCManager(NULL,SERVICES_ACTIVE_DATABASE,
  SC_MANAGER_ALL_ACCESS);
  if(sc==NULL)
  {
  printf("[-]Error:OpenSCManager()failedn");
  return0;
  }
  b=MultiByteToWideChar(CP_ACP,0,argv[2],-1,name,MAX_PATH);
  if(m==0)
  {
  printf("[+]Tryingtoload:%sn",argv[2]);
  install_driver(sc,name);
  }
  if(m!=0)
  {
  printf("[+]Tryingtounload:%sn",argv[2]);
  delete_driver(sc,name);
  }
  getch();
  }
  /*wdl.cends*/

上一页  1 2 3 4 5 6 7  下一页

Tags:详解 如何 利用

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接