A29-7 #18 Example code: Invisibility 翻译

例子代码:隐藏
-------------
作者:yoda
E-mail: LordPE@gmx.net
个人主页:www. y0da.cjb.net
日期:2002.07.06
测试系统: WinME 和 Win2000
翻译:bisonal23(05.06.09)

说明:
-----
这个示例说明怎样隐藏基于Windows操作系统中的一个进程,使该进程可以躲避ProcDump (G-RoM, Lorian& Stone)或者 ProcessExplorer (SysInternals)等任务查看器的检查。
它可以防止程序被“dump”。
在NT和9x下实现它的方式是有很大差异的。

Win 95/98/ME
------------
在9x下我们可以通过简单的挂接目标的Toolhelp32  API函数: Process32First/Process32Next来达到我们的目的。如果钩子程序检测到传唤器正在询问我们的进程,我们就执行另一个Process32Next来调用指定的TH32句柄。
另外我们利用未公开的但是大家很熟悉的RegisterServiceProcess API函数:
BOOL STDCALL RegisterServiceProcess(DWORD dwProcessID, BOOL bHide);
来清除CTRL+ALT+DEL弹出的对话框中的进程。这样像ProcDump, LordPE, ProcessExplorer就会成功的被欺骗。在我的系统上,MS Spy能抓拍到我们进程的名称,但是不能得到除了PID外的其他额外信息。

Win NT/2k/XP
------------
这里事情变得机警了。因为一个ring3的进程几乎没有权限向KMD传递一个动作。
首先我们挂接NtQuerySystemInformation。一个进程调用这个函数并且说明询问类5(SystemProcessInformation; thx EliCZ),我们修改返回的进程信息结构链。事实上我没有在整个结构上写得更多。我扩展了在我们进程块前面的进程块中SYSTEM_PROCESS_INFORMATION.SizeOfBlock结构项。
这个挂接不是通过重定位API函数的入口,而是通过修改ServiceDescriptorTable,它的地址可以从NtOsKrnl!KeServiceDescriptorTable导出的一个结构中获得:
SSDT STRUCT
 pSSAT              LPVOID  ?      ; System Service Address Table   ( LPVOID[] )
 Obsolete           DWORD   ?      ; or maybe: API ID base
 dwAPICount         DWORD   ?
 pSSPT              LPVOID  ?      ; System Service Parameter Table ( BYTE[] )
SSDT ENDS

由于这些Native API的ID对于不同的NT操作系统,不同的补丁包都是不同的,我们需要找出NtQuerySystemInformation的ID。为了这个目的,我们传递NtDll!NtQuerySystemInformation的地址给驱动程序,将在那里析取Native API的ID……
NtDll!NtQuerySystemInformation:
  mov eax, 97h                   ; EAX == Native API ID
  lea edx, [esp+arg_0]           ; EDX ->参数列表
  int 2Eh                        ; 执行 Native API 调用
  retn 10h

Native API ID是我们在NtOsKrnl!KeServiceDescriptorTable.SSDT.pSSAT找到的函数地址链的索引。我们只要交换我们目标API函数地址和我们挂接程序的线性地址。在我们的例子里:pSSAT[ 0x97 ]。当我们完成上面的,用户再也不会在NT的CTRL+ALT+DEL对话框的进程列表中看到Invisibility.exe。接下来的问题是在TaskMgr.exe的窗口里还有我们进程的一个入口。TaskMgr.exe内部使用user32!EnumWindows API 函数来得到窗口句柄和窗口名称,因此它能在窗口列表里显示名字/图标。
由于我不想单独挂接每一个进程的User32.dll和了解每一个新创建的进程,我只需要挂接NT内核某处的系统进程。EnumWindows对于拥有多参数的无输出函数只是一个大概的枚举,被枚举的函数也可以用User32!EnumChildWindows枚举出来。这个函数使用以下三个Native API函数:
Win32k!NtUserBuildHwndList:          - 第一次调用
                                     -只调用一次
                                     - ID: 0x112E 在我的系统里
                                    
Win32k!NtUserInternalGetWindowText:  - 被调用几次
                                     - ID: 0x11B1在我的系统里
                                    
Win32k!NtUserQueryWindow:            -被调用几次
                                     - ID: 0x11D2在我的系统里
                                    

挂接NtUserBuildHwndList对于实现我们的目的听起来不错。NtUserBuildHwndList有7个参数,它的函数原形大概如下: 
NTSTATUS NTAPI
NtUserBuildHwndList(                                                   ;我的猜测
 IN  ARGUMENT_1,                                                       
 IN  hParentHwnd,
 IN  BOOL,
 IN  ARGUMENT_4,
 IN  SpaceForHandlesInBufferCount,
 OUT pOutputBuffer,
 OUT pbResult
);
                                  
这个函数不是从win32k.sys中输出的。所以我们需要找到它的ServiceDescriptorTable。有一个未公开的不易访问的描述符叫ServiceDescriptorTableShadow。我在NtOsKrnl!KeServiceDescriptorTable输出地址下面的几个字节找到了这个函数。
内存片断……
0x0000: SSDT structure for Native API IDs < 0x1000     ; non-shadow SSDT
0x0010: 00000000 00000000 00000000 00000000            ; table terminator
0x0020: 00000000 00000000 00000000 00000000
0x0030: 00000000 00000000 00000000 00000000
0x0040: 00000000 00000000 00000000 00000000
0x0050: SSDT structure for Native API IDs <  0x1000    ; KeServiceDescriptorTableShadow !
0x0060: SSDT structure for Native API IDs >= 0x1000    ; SSDT for win32k.sys
0x0070: 00000000 00000000 00000000 00000000            ; table terminator
现在我们只需要NtUserBuildHwndList这个Native API函数的 ID。运气很好。
IDA显示:
[...]
sub_0_77E0678A proc near
  mov eax, 112Eh                         ; EAX == ID of win32k!NtUserBuildHwndList  !!!
  lea edx, [esp+arg_0]
  int 2Eh
  retn 1Ch
sub_0_77E0678A endp

EnumWindows proc near
  xor eax, eax
  push eax
  push eax
  push [esp+8+arg_4]
  push [esp+0Ch+arg_0]
  push eax
  push eax
  call sub_0_77E06607
  retn 8
EnumWindows endp
[...]

……因此我们可以通过上面EnumWindows直接取得API函数的Native API ID,代替程序在SSDTS.pSSAT[ 0x112E ]的地址我们就成功地挂接了程序。我们可以使用user32!GetWindowThreadProcessId来判断在KernelMode中返回的窗口句柄是否属于我们的进程,因为这个API值调用原始的NT结构而不是调用二级API。
修改这个API输出之后,TaskMgr.exe也不能在窗口列表中列举出隐藏消息对话框的标题。
ProcDump, ProcessExplorer也可以被欺骗。MS Snap可以列出隐藏窗口。
查看源代码可以得到更多的信息。

感谢
----------------------
EliCZ           - skilled tips as usual...thx man
DAEMON          - ditto...
-----------------------------完-------------------------------------
注:第一次翻译,难免有不少错误,恳请大家多多指正。翻译不好的地方请大家看原文,也可以发EMAIL给我:bisonal23@yahoo.com.cn一起讨论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
分析蓝牙打印”05-22 20:55:15.340 3861 3861 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@1702c5f 05-22 20:55:15.405 3861 3861 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendBroadcast:1005 android.content.ContextWrapper.sendBroadcast:444 com.zhiying.bluetoothmodelservice.MainActivity.sendBroadcast:643 com.zhiying.bluetoothmodelservice.MainActivity.onCreate:84 android.app.Activity.performCreate:7136 05-22 20:55:15.409 1936 5786 E ActivityManager: Sending non-protected broadcast android.newlink.exit.bluetoothSpeaker from system 3861:com.zhiying.bluetoothmodelservice/1000 pkg com.zhiying.bluetoothmodelservice 05-22 20:55:15.419 1936 5786 E ActivityManager: Sending non-protected broadcast android.newlink.exit.bluetoothSpeaker from system 3861:com.zhiying.bluetoothmodelservice/1000 pkg com.zhiying.bluetoothmodelservice 05-22 20:55:15.491 1797 1797 I MediaPlayerFactory: [getNameByPid:285] pid(3861), cmdline task_name(com.zhiying.bluetoothmodelservice). 05-22 20:55:15.561 3861 5918 W MediaPlayerNative: info/warning (710, 20) 05-22 20:55:15.562 3861 5918 W MediaPlayerNative: info/warning (710, 40) 05-22 20:55:15.610 3861 5918 W MediaPlayerNative: info/warning (710, 80) 05-22 20:55:15.628 3861 5918 W MediaPlayerNative: info/warning (710, 90) 05-22 20:55:15.628 3861 3861 I bt.sink.btconAc: true-------service-------- 05-22 20:55:15.628 3861 5918 W MediaPlayerNative: info/warning (710, 100) 05-22 20:55:15.629 3861 3861 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.startService:1531 android.content.ContextWrapper.startService:664 com.zhiying.bluetoothmodelservice.MainActivity.setBluetoothServiceStatus:354 com.zhiying.bluetoothmodelservice.MainActivity.initData:187 com.zhiying.bluetoothmodelservice.MainActivity.onCreate:89 05-22 20:55:15.649 3861 3861 I UartUtils: setState: true 05-22 20:55:15.649 3861 3861 I HiMW_TVClient: [invoke:53] =============invoke cmd = 0xf10a=======begin============= 05-22 20:55:15.653 3861 3861 I HiMW_TVClient: [invoke:65] =============invoke cmd = 0xf10a=======end=============== 05-22 20:55:15.654 3861 3861 W AudioManager: Use of stream types is deprecated for operations other than volume control 05-22 20:55:15.654 3861 3861 W AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case 05-22 20:55:15.655 1936 5786 I MediaFocusControl: requestAudioFocus() from uid/pid 1000/3861 clientId=android.media.AudioManager@3140a29 callingPack=com.zhiying.bluetoothmodelservice req=2 flags=0x0 sdk=29 05-22 20:55:15.658 3861 3861 D bt.sink.btconAc: onResume: 05-22 20:55:15.658 3861 3861 D bt.sink.btconAc: getBreathingScreenDatas: Could not find remote control icon properties 05-22 20:55:15.702 3861 3861 I bt.sink.btsevice: blueToothChange:关闭 05-22 20:55:15.706 3861 3861 D BluetoothAdapter: enable(): BT already enabled! 05-22 20:55:15.738 3861 3894 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0 05-22 20:55:15.738 3861 3894 I ConfigStore: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasHDRDisplay retriev
05-23

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值