僵尸进程的一点玩法

闲聊 闲聊 1227 人阅读 | 0 人回复

<
僵尸过程的一面弄法



序言

那几天正在看WRK的工夫,偶尔间发明的一个工具,顺背以后,发明了个僵尸过程的弄法。如今菜鸡一枚,有道的不准确的处所,请各人多多斧正!
被疏忽的RundownProtection

看过WRK的同学们该当对那个属性没有陌生,每当要对某个过程举办操纵的工夫,总会有一个属性检查,揭上部门代码
  1.     ProcessToLock = FromProcess;
  2.     if (FromProcess == PsGetCurrentProcess()) {
  3.         ProcessToLock = ToProcess;
  4.     }
  5.     //
  6.     // Make sure the process still has an address space.
  7.     //
  8.     if (ExAcquireRundownProtection (&ProcessToLock->RundownProtect) == FALSE) {
  9.         return STATUS_PROCESS_IS_TERMINATING;
  10.     }
复造代码
那是RundownProtect的构造体,能够看到正在一般状况下是为0的
  1.   [Type: _EX_RUNDOWN_REF]
  2.     [+0x000] Count            : 0x0 [Type: unsigned __int64]
  3.     [+0x000] Ptr              : 0x0 [Type: void *]
复造代码
看到WRK的正文以后,便欲探究一下ExAcquireRundownProtection
ExAcquireRundownProtection

  1. .text:00000001400FA630 48 8B 01                                      mov     rax, [rcx]
  2. .text:00000001400FA633 A8 01                                         test    al, 1           ; 判定RunRef.count的位0能否为1,即是则跳转
  3. .text:00000001400FA635 75 13                                         jnz     short loc_1400FA64A ; 返回FALSE
  4. .text:00000001400FA635
  5. .text:00000001400FA637 44 8D 04 12                                   lea     r8d, [rdx+rdx]  ; 参数
  6. .text:00000001400FA637
  7. .text:00000001400FA63B
  8. .text:00000001400FA63B                               loc_1400FA63B:                          ; CODE XREF: ExAcquireRundownProtectionEx+18↓j
  9. .text:00000001400FA63B 49 8D 14 00                                   lea     rdx, [r8+rax]   ; 参数
  10. .text:00000001400FA63F F0 48 0F B1 11                                lock cmpxchg [rcx], rdx ; Compare and Exchange
  11. .text:00000001400FA644 74 07                                         jz      short loc_1400FA64D ; 返回TRUE
  12. .text:00000001400FA644
  13. .text:00000001400FA646 A8 01                                         test    al, 1           ; Logical Compare
  14. .text:00000001400FA648 74 F1                                         jz      short loc_1400FA63B ; 轮回
  15. .text:00000001400FA648
  16. .text:00000001400FA64A
  17. .text:00000001400FA64A                               loc_1400FA64A:                          ; CODE XREF: ExAcquireRundownProtectionEx+5↑j
  18. .text:00000001400FA64A 32 C0                                         xor     al, al          ; 返回FALSE
  19. .text:00000001400FA64C C3                                            retn                    ; Return Near from Procedure
  20. .text:00000001400FA64C
  21. .text:00000001400FA64D                               ; ---------------------------------------------------------------------------
  22. .text:00000001400FA64D
  23. .text:00000001400FA64D                               loc_1400FA64D:                          ; CODE XREF: ExAcquireRundownProtectionEx+14↑j
  24. .text:00000001400FA64D B0 01                                         mov     al, 1           ; 返回TRUE
  25. .text:00000001400FA64F C3                                            retn                    ; Return Near from Procedure
复造代码
颠末一番顺背后,发明当RundownProtection的第一个成员的第整位(两进造)为0时,则函数返回TRUE,不然返回FALSE。
使用

假如我们修正RundownProtect为1,那末能否能够完成任何API会见此过程皆失利呢,接下去做一下尝试。
  1. kd> dt _EPROCESS fffffa8002402710
  2. nt!_EPROCESS
  3.    +0x000 Pcb              : _KPROCESS
  4.    +0x160 ProcessLock      : _EX_PUSH_LOCK
  5.    +0x168 CreateTime       : _LARGE_INTEGER 0x01d7a08a`1c139093
  6.    +0x170 ExitTime         : _LARGE_INTEGER 0x0
  7.    +0x178 RundownProtect   : _EX_RUNDOWN_REF
  8.    +0x180 UniqueProcessId  : 0x00000000`0000057c Void
  9.    +0x188 ActiveProcessLinks : _LIST_ENTRY [ 0xfffffa80`02b6e5b8 - 0xfffffa80`027b1528 ]
  10.    +0x198 ProcessQuotaUsage : [2] 0x2680
  11.    +0x1a8 ProcessQuotaPeak : [2] 0x2c20
  12.    +0x1b8 CommitCharge     : 0x1f8
  13.    +0x1c0 QuotaBlock       : 0xfffffa80`010724c0 _EPROCESS_QUOTA_BLOCK
  14.    +0x1c8 CpuQuotaBlock    : (null)
  15.    +0x1d0 PeakVirtualSize  : 0x6002000
  16.    +0x1d8 VirtualSize      : 0x50e7000
  17.    +0x1e0 SessionProcessLinks : _LIST_ENTRY [ 0xfffffa80`02af5b40 - 0xfffffa80`027b1580 ]
  18.    +0x1f0 DebugPort        : (null)
  19.    +0x1f8 ExceptionPortData : 0xfffffa80`01fd5c90 Void
  20.    +0x1f8 ExceptionPortValue : 0xfffffa80`01fd5c90
  21.    +0x1f8 ExceptionPortState : 0y000
  22.    +0x200 ObjectTable      : 0xfffff8a0`021b6d70 _HANDLE_TABLE
  23.    +0x208 Token            : _EX_FAST_REF
  24.    +0x210 WorkingSetPage   : 0x22102
  25.    +0x218 AddressCreationLock : _EX_PUSH_LOCK
  26.    +0x220 RotateInProgress : (null)
  27.    +0x228 ForkInProgress   : (null)
  28.    +0x230 HardwareTrigger  : 0
  29.    +0x238 PhysicalVadRoot  : 0xfffffa80`00d95bc0 _MM_AVL_TABLE
  30.    +0x240 CloneRoot        : (null)
  31.    +0x248 NumberOfPrivatePages : 0x18c
  32.    +0x250 NumberOfLockedPages : 0
  33.    +0x258 Win32Process     : 0xfffff900`c2ffd010 Void
  34.    +0x260 Job              : 0xfffffa80`00d27220 _EJOB
  35.    +0x268 SectionObject    : 0xfffff8a0`02aeb6e0 Void
  36.    +0x270 SectionBaseAddress : 0x00000000`00400000 Void
  37.    +0x278 Cookie           : 0xf2b3718a
  38.    +0x27c UmsScheduledThreads : 0
  39.    +0x280 WorkingSetWatch  : (null)
  40.    +0x288 Win32WindowStation : 0x00000000`0000005c Void
  41.    +0x290 InheritedFromUniqueProcessId : 0x00000000`00000524 Void
  42.    +0x298 LdtInformation   : (null)
  43.    +0x2a0 Spare            : (null)
  44.    +0x2a8 ConsoleHostProcess : 0
  45.    +0x2b0 DeviceMap        : 0xfffff8a0`015bff10 Void
  46.    +0x2b8 EtwDataSource    : (null)
  47.    +0x2c0 FreeTebHint      : 0x00000000`7efa0000 Void
  48.    +0x2c8 FreeUmsTebHint   : 0x00000001`00000000 Void
  49.    +0x2d0 PageDirectoryPte : _HARDWARE_PTE
  50.    +0x2d0 Filler           : 0
  51.    +0x2d8 Session          : 0xfffff880`009c9000 Void
  52.    +0x2e0 ImageFileName    : [15]  "Dbgview.exe"
  53.    +0x2ef PriorityClass    : 0x2 &#39;&#39;
  54.    +0x2f0 JobLinks         : _LIST_ENTRY [ 0xfffffa80`00d27248 - 0xfffffa80`00d27248 ]
  55.    +0x300 LockedPagesList  : (null)
  56.    +0x308 ThreadListHead   : _LIST_ENTRY [ 0xfffffa80`024b6f80 - 0xfffffa80`02515860 ]
  57.    +0x318 SecurityPort     : (null)
  58.    +0x320 Wow64Process     : 0x00000000`7efde000 Void
  59.    +0x328 ActiveThreads    : 3
  60.    +0x32c ImagePathHash    : 0xdecf2e47
  61.    +0x330 DefaultHardErrorProcessing : 1
  62.    +0x334 LastThreadExitStatus : 0n0
  63.    +0x338 Peb              : 0x00000000`7efdf000 _PEB
  64.    +0x340 PrefetchTrace    : _EX_FAST_REF
  65.    +0x348 ReadOperationCount : _LARGE_INTEGER 0x0
  66.    +0x350 WriteOperationCount : _LARGE_INTEGER 0x0
  67.    +0x358 OtherOperationCount : _LARGE_INTEGER 0x0
  68.    +0x360 ReadTransferCount : _LARGE_INTEGER 0x0
  69.    +0x368 WriteTransferCount : _LARGE_INTEGER 0x0
  70.    +0x370 OtherTransferCount : _LARGE_INTEGER 0x0
  71.    +0x378 CommitChargeLimit : 0
  72.    +0x380 CommitChargePeak : 0x226
  73.    +0x388 AweInfo          : (null)
  74.    +0x390 SeAuditProcessCreationInfo : _SE_AUDIT_PROCESS_CREATION_INFO
  75.    +0x398 Vm               : _MMSUPPORT
  76.    +0x420 MmProcessLinks   : _LIST_ENTRY [ 0xfffffa80`02b6e850 - 0xfffffa80`027b17c0 ]
  77.    +0x430 HighestUserAddress : 0x00000000`7fff0000 Void
  78.    +0x438 ModifiedPageCount : 7
  79.    +0x43c Flags2           : 0x2d014
  80.    +0x43c JobNotReallyActive : 0y0
  81.    +0x43c AccountingFolded : 0y0
  82.    +0x43c NewProcessReported : 0y1
  83.    +0x43c ExitProcessReported : 0y0
  84.    +0x43c ReportCommitChanges : 0y1
  85.    +0x43c LastReportMemory : 0y0
  86.    +0x43c ReportPhysicalPageChanges : 0y0
  87.    +0x43c HandleTableRundown : 0y0
  88.    +0x43c NeedsHandleRundown : 0y0
  89.    +0x43c RefTraceEnabled  : 0y0
  90.    +0x43c NumaAware        : 0y0
  91.    +0x43c ProtectedProcess : 0y0
  92.    +0x43c DefaultPagePriority : 0y101
  93.    +0x43c PrimaryTokenFrozen : 0y1
  94.    +0x43c ProcessVerifierTarget : 0y0
  95.    +0x43c StackRandomizationDisabled : 0y1
  96.    +0x43c AffinityPermanent : 0y0
  97.    +0x43c AffinityUpdateEnable : 0y0
  98.    +0x43c PropagateNode    : 0y0
  99.    +0x43c ExplicitAffinity : 0y0
  100.    +0x440 Flags            : 0x144d0801
  101.    +0x440 CreateReported   : 0y1
  102.    +0x440 NoDebugInherit   : 0y0
  103.    +0x440 ProcessExiting   : 0y0
  104.    +0x440 ProcessDelete    : 0y0
  105.    +0x440 Wow64SplitPages  : 0y0
  106.    +0x440 VmDeleted        : 0y0
  107.    +0x440 OutswapEnabled   : 0y0
  108.    +0x440 Outswapped       : 0y0
  109.    +0x440 ForkFailed       : 0y0
  110.    +0x440 Wow64VaSpace4Gb  : 0y0
  111.    +0x440 AddressSpaceInitialized : 0y10
  112.    +0x440 SetTimerResolution : 0y0
  113.    +0x440 BreakOnTermination : 0y0
  114.    +0x440 DeprioritizeViews : 0y0
  115.    +0x440 WriteWatch       : 0y0
  116.    +0x440 ProcessInSession : 0y1
  117.    +0x440 OverrideAddressSpace : 0y0
  118.    +0x440 HasAddressSpace  : 0y1
  119.    +0x440 LaunchPrefetched : 0y1
  120.    +0x440 InjectInpageErrors : 0y0
  121.    +0x440 VmTopDown        : 0y0
  122.    +0x440 ImageNotifyDone  : 0y1
  123.    +0x440 PdeUpdateNeeded  : 0y0
  124.    +0x440 VdmAllowed       : 0y0
  125.    +0x440 CrossSessionCreate : 0y0
  126.    +0x440 ProcessInserted  : 0y1
  127.    +0x440 DefaultIoPriority : 0y010
  128.    +0x440 ProcessSelfDelete : 0y0
  129.    +0x440 SetTimerResolutionLink : 0y0
  130.    +0x444 ExitStatus       : 0n259
  131.    +0x448 VadRoot          : _MM_AVL_TABLE
  132.    +0x488 AlpcContext      : _ALPC_PROCESS_CONTEXT
  133.    +0x4a8 TimerResolutionLink : _LIST_ENTRY [ 0x00000000`00000000 - 0x00000000`00000000 ]
  134.    +0x4b8 RequestedTimerResolution : 0
  135.    +0x4bc ActiveThreadsHighWatermark : 6
  136.    +0x4c0 SmallestTimerResolution : 0
  137.    +0x4c8 TimerResolutionStackRecord : (null)
复造代码
我们看到0x178偏偏移处,找到了RundownProtect那个属性,接着修正为1(第0位为0的数皆可)。
  1. kd> ed fffffa8002402710+178 1
复造代码
接着我们进进假造机检察结果
150128qyhp4zz99p40cfzj.jpg

程序一般运转,没有会PG。
(测试情况Win7 X64 7600)
总结

那个函数另有许多用途,比方多线程同步等等,另有便是…做完才发明,曾经有年夜佬收过那个思绪了~
更早的一篇

免责声明:假如进犯了您的权益,请联络站少,我们会实时删除侵权内乱容,感谢协作!
1、本网站属于个人的非赢利性网站,转载的文章遵循原作者的版权声明,如果原文没有版权声明,按照目前互联网开放的原则,我们将在不通知作者的情况下,转载文章;如果原文明确注明“禁止转载”,我们一定不会转载。如果我们转载的文章不符合作者的版权声明或者作者不想让我们转载您的文章的话,请发帖留言提供原创证明,我们将积极配合您!
2、本网站转载文章仅为传播更多信息之目的,凡在本网站出现的信息,均仅供参考。本网站将尽力确保所提供信息的准确性及可靠性,但不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
3、任何透过本网站网页而链接及得到的资讯、产品及服务,本网站概不负责,亦不负任何法律责任。
4、本网站所刊发、转载的文章,其版权均归原作者所有,如其他媒体、网站或个人从本网下载使用,请在转载有关文章时务必尊重该文章的著作权,保留本网注明的“稿件来源”,并自负版权等法律责任。
回复

使用道具 举报

 
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则