看流星社区

 找回密码
 注册账号
查看: 1575|回复: 0

使用EPROCESS下Win32Process枚举进程

[复制链接]

该用户从未签到

发表于 2017-6-1 12:17:21 | 显示全部楼层 |阅读模式


此方法硬编码很多!!!
EPROCESS下win32Process其实是一个tagPROCESSINFO 结构

  1. //#include <ntddk.h>
  2. #include <ntifs.h>
  3. NTKERNELAPI PVOID PsGetProcessWin32Process( IN PEPROCESS Process );
  4. NTKERNELAPI PEPROCESS IoThreadToProcess(IN PETHREAD Thread);
  5. NTKERNELAPI UCHAR* PsGetProcessImageFileName(PEPROCESS Process);
  6. //win7x64 通过win32Process枚举进程 传入explorer.exe的EPROCESS 必须是explorer.exe
  7. VOID EnumWindows(PEPROCESS explorer)
  8. {
  9.         //NTSTATUS status;
  10.     PEPROCESS gui_process;
  11.     ULONG_PTR win32_process,tag_desk_top,tag_desk_info,tag_desk_wnd,tag_wnd;
  12.     ULONG_PTR tag_thread_info,ethread;//eprocess;
  13.         PEPROCESS tmp_process;
  14.         ULONG_PTR strName = 0;
  15.         ULONG_PTR h = 0;
  16.         //ULONG_PTR pstrAppName = 0;
  17.         ULONG_PTR ProcessID = 0;
  18.         //_LARGE_UNICODE_STRING
  19.        
  20.         //status = PsLookupProcessByProcessId((HANDLE)1384,&gui_process);
  21.         if(explorer == NULL)
  22.                 return;
  23.         gui_process = explorer;
  24.     KeAttachProcess(gui_process);
  25.     do
  26.     {
  27.                 //win32_process = *(ULONG_PTR*)((ULONG_PTR)gui_process + 0x258);//tagPROCESSINFO
  28.                 win32_process = (ULONG_PTR)PsGetProcessWin32Process(gui_process);
  29.             if(win32_process == 0 )
  30.             {
  31.                         DbgPrint("win32_process");
  32.                     break;
  33.             }
  34.                 tag_desk_top = *(ULONG_PTR*)(win32_process+0x110);//tagDESKTOP
  35.                 if(tag_desk_top == 0)
  36.                 {
  37.                         DbgPrint("tag_desk_top");
  38.                         break;
  39.                 }
  40.                 tag_desk_info = *(ULONG_PTR*)(tag_desk_top+0x8);//tagDESKTOPINFO
  41.                 if(tag_desk_info == 0)
  42.                 {
  43.                         DbgPrint("tag_desk_info");
  44.                         break;
  45.                 }
  46.                 tag_desk_wnd = *(ULONG_PTR*)(tag_desk_info+0x10);//struct _tagWND* spwnd;
  47.                 if(tag_desk_wnd == 0)
  48.                 {
  49.                         DbgPrint("tag_desk_wnd");
  50.                         break;
  51.                 }
  52.                
  53.                 tag_wnd = *(ULONG_PTR*)(tag_desk_wnd+0x60);///*0x060*/     struct _tagWND* spwndChild;   
  54.                 if(tag_wnd == 0)
  55.                 {
  56.                         DbgPrint("tag_wnd");
  57.                         break;
  58.                 }
  59.                 while(tag_wnd)
  60.                 {
  61.                         h = *(ULONG_PTR*)tag_wnd;
  62.                         if(h != 0)
  63.                         {
  64.                                 DbgPrint("hwnd:0x%llx----tag_wnd:0x%llx\n",h,tag_wnd);
  65.                         }
  66.                         tag_thread_info = *(ULONG_PTR*)(tag_wnd+0x10);
  67.                         if(tag_thread_info == 0)
  68.                         {
  69.                                 tag_wnd = *(ULONG_PTR*)(tag_wnd+0x48);///*0x048*/     struct _tagWND* spwndNext;   
  70.                                 continue;
  71.                         }
  72.                         ///*0x1A0*/     struct _UNICODE_STRING* pstrAppName;    常年为NULL
  73.                         /*pstrAppName = tag_thread_info + 0x1a0;
  74.                         if(pstrAppName != 0)
  75.                         {
  76.                                 DbgPrint("pstrAppName:%wZ\n",pstrAppName);
  77.                         }*/
  78.                         ethread = *(ULONG_PTR*)(tag_thread_info);
  79.                         if(ethread == 0)
  80.                         {
  81.                                 tag_wnd = *(ULONG_PTR*)(tag_wnd+0x48);///*0x048*/     struct _tagWND* spwndNext;   
  82.                                 continue;
  83.                         }
  84.                         //eprocess = *(ULONG_PTR*)(ethread+0x210);//_KTHREAD +0x210         Process          : Ptr64 _KPROCESS
  85.                         tmp_process = IoThreadToProcess((PETHREAD)ethread);
  86.                         if(tmp_process == NULL)
  87.                         {
  88.                                 tag_wnd = *(ULONG_PTR*)(tag_wnd+0x48);///*0x048*/     struct _tagWND* spwndNext;   
  89.                                 continue;
  90.                         }
  91.                         ///*0x0D8*/     struct _LARGE_UNICODE_STRING strName;
  92.                         strName = *(ULONG_PTR*)(tag_wnd + 0xd8 +0x8);
  93.                         if(strName != 0)
  94.                                 DbgPrint("strName:%S",strName);
  95.                         ProcessID = (ULONG_PTR)PsGetProcessId(tmp_process);
  96.                         DbgPrint("\nProcessID:%d\n",ProcessID);
  97.                         //DbgPrint("%s\n",eprocess+0x2e0);
  98.                         DbgPrint("ProcessName:%s\n",PsGetProcessImageFileName(tmp_process));
  99.                         tag_wnd = *(ULONG_PTR*)(tag_wnd+0x48);///*0x048*/     struct _tagWND* spwndNext;
  100.                 }
  101.        
  102.     }while(0);
  103.         KeDetachProcess();
  104.    // ObDereferenceObject(gui_process);
  105. }
  106. VOID DriverUnload(PDRIVER_OBJECT pDriverObject)
  107. {
  108.         UNREFERENCED_PARAMETER(pDriverObject);
  109.         DbgPrint("[kernel]88!\n");
  110. }
  111. NTSTATUS DriverEntry(PDRIVER_OBJECT pDriverObject, PUNICODE_STRING pRegPath)
  112. {
  113.         UNREFERENCED_PARAMETER(pRegPath);
  114.         pDriverObject->DriverUnload = DriverUnload;
  115.         EnumWindows((PEPROCESS)0xfffffa801a596b30);
  116.         return STATUS_SUCCESS;
  117. }
复制代码


测试图:有一些是没有strName的






   





点击按钮快速添加回复内容: 支持 高兴 激动 给力 加油 苦寻 生气 回帖 路过 感恩
您需要登录后才可以回帖 登录 | 注册账号

本版积分规则

小黑屋|手机版|Archiver|看流星社区 |网站地图

GMT+8, 2024-3-19 11:31

Powered by Kanliuxing X3.4

© 2010-2019 kanliuxing.com

快速回复 返回顶部 返回列表