In x86_64 the standard way is to use RIP-relative addressing instead of CALL
like in x86. Even then, call/pop is not a recommended way1
通常你会使用lea rax, [rip]
将 RIP 放入 RAX(实际上编码为lea rax, [rip + 0]
末尾有四个字节作为立即数)。然而自从LEA
不会取消引用内存地址,您只需将任何常量位移添加到 RIP 中,然后再减去它
0: 48 8d 05 04 03 02 01 lea rax,[rip+0x1020304]
7: 48 2d 04 03 02 01 sub rax,0x1020304
您可以选择任何没有零或 0xFF 字节的立即值。如果你想要指令的地址lea
(7个字节长)你可以相应地修复sub rax, 0x01020304 - 7
1The recommended way http://blogs.msdn.com/b/oldnewthing/archive/2004/12/16/317157.aspx is
GetCurrentAddress:
mov eax, [esp]
ret
...
call GetCurrentAddress
mov [currentInstruction], eax
以避免调用堆栈和返回堆栈缓冲区 (RSB) 之间不匹配。但在 shellcode 中可能并不重要