首页
论坛
课程
招聘
求助《加密与解密》的第12章里的RtlCreateInject的shellcode开始地址的计算问题
mb_xfwmkqca 2023-3-8 199
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
__declspec (naked)
VOID ShellCodeFun(VOID)
{
    __asm
    {
        call L001
L001:
        pop ebx
        sub ebx,5
        push dword ptr ds:[ebx]INJECT_DATA.lpParameter //lpParameter
        call dword ptr ds:[ebx]INJECT_DATA.lpThreadStartRoutine //ThreadProc
        xor eax,eax
        push eax
        push -2 //CurrentThread
        call dword ptr ds:[ebx]INJECT_DATA.AddrOfZwTerminateThread //ZwTerminateThread
        nop //no return
        nop
        nop
        nop
        nop
    }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
BYTE *pShellcodeStart = (BYTE*)ShellCodeFun;
 
BYTE *pShellcodeEnd = 0 ;
SIZE_T ShellCodeSize = 0 ;
if (pShellcodeStart[0] == 0xE9)
{
//Debug模式下,函数开头是一个跳转指令,这里取它的真正地址
    pShellcodeStart = pShellcodeStart + *(ULONG*)(pShellcodeStart +1 ) + 5;
}
 
//搜索Shellcode结束标志
pShellcodeEnd = pShellcodeStart;
while (memcmp(pShellcodeEnd,"\x90\x90\x90\x90\x90",5) != 0)
{
    pShellcodeEnd++;
}
 
ShellCodeSize = pShellcodeEnd - pShellcodeStart;
printf("[*] Shellcode Len = %d\n",ShellCodeSize);
memcpy(pOutShellCode,pShellcodeStart,ShellCodeSize);
 
}

shellcode如果是E9开头的话,那么求得的pShellcodeStart是不是应该是pop ebx的开始地址咧?如果是这样的话被写入内存的shellcode缺少了开头的call L001不就没法让ebx成为申请的内存基址了么。求大佬指点一下

收藏
0条回答