首页
社区
课程
招聘
[求助]hook ZwQuerySystemInformation 问题
发表于: 2009-12-8 19:00 5153

[求助]hook ZwQuerySystemInformation 问题

2009-12-8 19:00
5153
hook了ZwQuerySystemInformation

新函数试图修改进程名字。(原来隐藏进程修改的,hook成功的)
可是加载驱动后,任务管理器里面的进程名都变空白了。
自己在用户层调用ZwQuerySystemInformation (5,。。)后程序崩溃了。
请问问题出在哪里?

NTSTATUS NewZwQuerySystemInformation(
            IN ULONG SystemInformationClass,
            IN PVOID SystemInformation,
            IN ULONG SystemInformationLength,
            OUT PULONG ReturnLength)
{
    NTSTATUS rc;
    CHAR aProcessName[PROCNAMELEN];        
    GetProcessName( aProcessName );
    rc = ((ZWQUERYSYSTEMINFORMATION)(OldZwQuerySystemInformation)) (
            SystemInformationClass,
            SystemInformation,
            SystemInformationLength,
            ReturnLength );
    if( NT_SUCCESS( rc ) )
    {
      
        if(0 == memcmp(aProcessName, "_root_", 6))
        {
            DbgPrint("rootkit: detected system query from _root_ process\n");
        }
        else if( 5 == SystemInformationClass )
        {
            
            struct _SYSTEM_PROCESSES *curr = (struct _SYSTEM_PROCESSES *)SystemInformation;
            DbgPrint("rootkit: NewZwQuerySystemInformation() from %s\n", aProcessName);
            while(curr)
            {   
                                if(curr->ProcessName.Length!=0)
                        {
                                DbgPrint("%ws\n",curr->ProcessName.Buffer);
                    curr->ProcessName.Length=14;
                                curr->ProcessName.Buffer=L"CMD.EXE";
                       
               
               
            }
                         
                if(curr->NextEntryDelta) ((char *)curr += curr->NextEntryDelta);
                else curr = NULL;
                        }
                       
                  
                }
               
    }
    return(rc);
}

[课程]Android-CTF解题方法汇总!

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 722
活跃值: (123)
能力值: ( LV12,RANK:300 )
在线值:
发帖
回帖
粉丝
2
curr->ProcessName.Buffer=L"CMD.EXE";
Orz
楼主看来根本不懂这些ZwQueryXX函数的输出缓冲区内容是怎么编排的(输出给UNICODE_STRING的Buffer的内容是放在哪里的),更加夸张的是居然把输出给用户态的UNICODE_STRING中的Buffer指向驱动中的内核态地址,真是无语了。
2009-12-8 19:20
0
雪    币: 7651
活跃值: (523)
能力值: ( LV9,RANK:610 )
在线值:
发帖
回帖
粉丝
3
楼主回去打好基础再来吧~
2009-12-8 19:55
0
游客
登录 | 注册 方可回帖
返回
//