mmap() 系统调用的 prot 参数如何为 0x1007?

How can prot argument of mmap() syscall be 0x1007?

在分析 Metasploit 的 linux/x64/shell/reverse_tcp 负载时,我意识到它使用值 0x1007 作为 mmap() 系统调用的 prot 参数。

mmap() 手册页说 prot 参数是 PROT_NONE 或以下一个或多个标志的按位或:PROT_EXEC、PROT_READ、PROT_WRITE PROT_NONE。根据 /usr/include/x86_64-linux-gnu/bits/mman.h 文件,上述标志的值分别为 0x4、0x1、0x2 和 0x0。这怎么加起来就是 0x1007?

系统调用签名是:

void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset);

我所指的代码部分是:

global _start
section .text
_start:

xor rdi,rdi                    
push byte +0x9                
pop rax                       
cdq                             
mov dh,0x10                    
mov rsi,rdx                     
xor r9,r9                       
push byte +0x22                
pop r10                        
mov dl,0x7                     
loadall286    

如@MichaelPetch 所述,mmap() 系统调用忽略了最高有效字节。它仅用于通过使用 mov dh,0x10 和 mov rsi,rdx 指令为长度参数赋值。