首页 > 其他 > 详细

隐藏DLL

时间:2014-03-29 08:09:00      阅读:293      评论:0      收藏:0      [点我收藏+]

先来推广一下QQ群:61618925。欢迎各位爱好编程的加入。

在外挂或者病毒中,经常需要隐藏掉自己注入的DLL,以免被发现。下面就是一个隐藏DLL的通用模块,用的时候只需要加入到相关模块中即可。

详细代码如下:

bubuko.com,布布扣
#include <iostream>

using namespace std;

void HideModule(char *szModule)
{
    DWORD *PEB = NULL;
    DWORD *Ldr = NULL;
    DWORD *Flink = NULL;
    DWORD *p = NULL;
    DWORD *BaseAddress = NULL;
    DWORD *FullDllName = NULL;

    //定位PEB
    __asm
    {
        //fs位置保存着teb
        //fs:[0x30]位置保存着peb
        mov eax,fs:[0x30]
        mov PEB,eax
    }

    HMODULE hMod = GetModuleHandleA(szModule);

    //得到LDR
    Ldr = *((DWORD **)((unsigned char *)PEB + 0x0c));
    //第二条链表
    Flink = *((DWORD **)((unsigned char *)Ldr + 0x0c));
    p = Flink;

    do 
    {
        BaseAddress = *((DWORD **)((unsigned char *)p + 0x18));
        FullDllName = *((DWORD **)((unsigned char *)p + 0x28));

        if ((DWORD*)hMod == BaseAddress)
        {
            **((DWORD **)(p + 1)) = (DWORD)*((DWORD **)p);
            *(*((DWORD **)p) + 1) = (DWORD)*((DWORD **)(p + 1));
            break;
        }

        p = *((DWORD **)p);
    } while (Flink != p);

    Flink = *((DWORD **)((unsigned char *)Ldr + 0x14));
    p = Flink;
    do 
    {
        BaseAddress = *((DWORD **)((unsigned char *)p + 0x10));
        FullDllName = *((DWORD **)((unsigned char *)p + 0x20));
        if (BaseAddress == (DWORD *)hMod)
        {
            **((DWORD **)(p + 1)) = (DWORD)*((DWORD **)p);
            *(*((DWORD **)p) + 1) = (DWORD)*((DWORD **)(p + 1));
            break;
        }
        p = *((DWORD **)p);
    } while (Flink != p);

    Flink = *((DWORD **)((unsigned char *)Ldr + 0x1c));
    p = Flink;
    do 
    {
        BaseAddress = *((DWORD **)((unsigned char *)p + 0x8));
        FullDllName = *((DWORD **)((unsigned char *)p + 0x18));
        if (BaseAddress == (DWORD *)hMod)
        {
            **((DWORD **)(p + 1)) = (DWORD)*((DWORD **)p);
            *(*((DWORD **)p) + 1) = (DWORD)*((DWORD **)(p + 1));
            break;
        }
        p = *((DWORD **)p);
    } while (Flink != p);
}


int main(int argc, char **argv)
{
    HideModule("kernel32.dll");
    HideModule("ntdll.dll");
    HideModule("MSVCR90.dll");
    HideModule("KERNELBASE.dll");
    getchar();
    return 0;
}
bubuko.com,布布扣

用我之前博客中的进程管理器查看本进程的DLL,可以发现找不到相应的DLL。

隐藏DLL,布布扣,bubuko.com

隐藏DLL

原文:http://www.cnblogs.com/qiyueliuguang/p/3631957.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!