我的shellcode有什么问题?
问题描述:
对不起,这个问题已经被提出并解释了上千次,但我不明白为什么这段代码给了我一个分段错误。 与nasm编译为elf 64并且喜欢ld。我的shellcode有什么问题?
BITS 64 ;
xor rax, rax ;
mov rax, 0x3b ; LinuxX64 exevce
push 0x68732f2f ;
push 0x6e690b2f ;
pop rbx ; Argv[0] /bin//sh
xor rcx, rcx ;
push rcx ;
push rbx ;
pop rcx ; Argv[1] /bin//sh0
xor rsi, rsi ; just need any GP register
push rsi ;
pop rdx ; Argv[2] 0
syscall ;
答
很多事情是错的实际,首先在64位,参数均作为RDI,RSI,RDX,RCX,通过若再我们必须使用堆栈。
BITS 64 ;
xor rax, rax ;
mov al, 0x3b ; EXECVE -> al other wise we get null bytes
xor rcx, rcx ;
push rcx ; PUSH A NULL BYTE
mov rdi, 0x68732f2f6e69622f ; /*
push rdi ; use the stack to fill rdi '"/bin//sh"0'
mov rdi, rsp ; */
xor sil, sil ; Argv[2] -> sil otherwise we ge null bytes
syscall ;
也许一些引用无效/无法访问的内存?无论如何,出于好奇,这与信息安全有什么关系? –
您是否尝试过附加调试器并跟踪哪个指令准确地给出段错误? – Sjoerd
我在系统调用之前使用了gdb,我的参数(在rbx rcx中)位于不可访问的内存地址中。 我该如何处理这个问题?我会尝试使用lea命令 – Yvain