我尝试使用ptrace解析可执行文件中的所有Calls和Rets.符合x64opcode,我找到了调用的操作码:0xe8和Rets:0xc3,0xc2,0xca,0xcb.
自从我解析它们后,我发现了更多的Rets而不是Calls.
有我跟踪的程序:
void func()
{
write(1, "i", 1);
}
int main(int ac)
{
func();
return(0);
}
Run Code Online (Sandbox Code Playgroud)
有我的示踪剂:
int tracer(t_info *info)
{
int status;
long ptr;
int ret = 0;
int call = 0;
waitpid(info->pid, &status, 0);
while (WIFSTOPPED(status))
{
ptrace(PTRACE_GETREGS, info->pid, NULL, info->regs);
ptr = ptrace(PTRACE_PEEKDATA, info->pid, info->regs->rip);
if (((ptr & 0x000000ff) == 0xe8)) // Opcode for call
{
call++;
}
else if (((ptr & 0x000000ff) == 0xc3) // Opcodes for …Run Code Online (Sandbox Code Playgroud)