检测当前进程是否被挂起


KTHREAD的结构:
   +0x16c SuspendApc       : _KAPC
   +0x19c SuspendSemaphore : _KSEMAPHORE
   +0x1b0 ThreadListEntry  : _LIST_ENTRY
   +0x1b8 FreezeCount      : Char
   +0x1b9 SuspendCount     : Char


在调用SuspendThread时,SuspendCount 自加1;如果大于0表示挂起了。调用ResumeThread时,SuspendCount 自减1;如果等于0,系统会恢复线程。

当挂起和恢复时,FreezeCount必须为0,否则挂起和恢复操作都直接pass了 .所以,可以修改 SuspendCount 和  FreezeCount来达到反挂起的目的。


证据:

应用层或内核调用ZwSuspendThread/Process

最后会执行到NtSuspendThread/Process


IDA:

以NtSuspendProcess为例子

NtSuspendProcess->PsSuspendProcess->PsSuspendThread->KeSuspendThread->


NtSuspendProcess

PAGE:006D5143 ; int __stdcall NtSuspendProcess(HANDLE Handle)
PAGE:006D5143 _NtSuspendProcess@4 proc near           ; DATA XREF: .text:0045CCF4o
PAGE:006D5143
PAGE:006D5143 AccessMode      = byte ptr -8
PAGE:006D5143 Object          = dword ptr -4
PAGE:006D5143 Handle          = dword ptr  8
PAGE:006D5143
PAGE:006D5143                 mov     edi, edi
PAGE:006D5145                 push    ebp
PAGE:006D5146                 mov     ebp, esp
PAGE:006D5148                 push    ecx
PAGE:006D5149                 push    ecx
PAGE:006D514A                 mov     eax, large fs:124h
PAGE:006D5150                 mov     al, [eax+13Ah]
PAGE:006D5156                 push    esi
PAGE:006D5157                 push    0               ; HandleInformation
PAGE:006D5159                 mov     [ebp+AccessMode], al
PAGE:006D515C                 lea     eax, [ebp+Object]
PAGE:006D515F                 push    eax             ; Object
PAGE:006D5160                 push    dword ptr [ebp+AccessMode] ; AccessMode
PAGE:006D5163                 push    ds:_PsProcessType ; ObjectType
PAGE:006D5169                 push    800h            ; DesiredAccess
PAGE:006D516E                 push    [ebp+Handle]    ; Handle
PAGE:006D5171                 call    _ObReferenceObjectByHandle@24 ; 根据句柄获得Object
PAGE:006D5176                 mov     esi, eax        ; mov esi pEprocess
PAGE:006D5178                 test    esi, esi
PAGE:006D517A             
  • 1
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值