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);
}