2016-11-03 10 views
0

, 나는 종류의 새로운 나는 다음과 같은을 execve 86 - 분할 고장 나는 누군가가이 일에 저를 도울 수있는이에 세그멘테이션 오류가 계속

char* Args[] = { "/bin/sh", "-c", "/bin/bash" }; 
    execve("/bin/sh", Args, NULL) 
을 복제하는 것을 시도하고있다

global _start 

section .text 
_start: 

push dword 0x0068732F ; Push /sh 
push dword 0x6E69622F ; Push /bin 
mov eax, esp   ; Store Pointer To /bin/sh In EAX 

push dword 0x0000632D ; Push -c 
mov ebx, esp   ; Store Pointer To -c In EBX 

push dword 0x00000068 ; Push h 
push dword 0x7361622F ; Push /bas 
push dword 0x6E69622F ; Push /bin 
mov ecx, esp   ; Store Pointer To /bin/bash In ECX 

push dword 0x0  ; NULL 
push ecx    ; Push /bin/bash Pointer 
push ebx    ; Push -c Pointer 
push eax    ; Push /bin/sh Pointer 

mov ebx, eax   ; Move /bin/sh Pointer To EAX 
mov ecx, esp   ; Store /bin/sh -c /bin/bash Pointer in ECX 
xor edx, edx   ; Store 0 In EDX 

mov al, 0xb   ; sys_execve 
int 0x80    ; system call 

을 ASM하기입니다

미리 감사드립니다.

+0

코드에서 SEGV 신호를 발생시키는 행은 무엇입니까? 디버거는 그 시점에서 멈추고 레지스터와 메모리를 검사하여 어떤 일이 일어나고 있는지 이해할 수 있도록해야합니다. –

+0

@TobySpeight 알 수없는 라인을 얻는 것 – 0xDeMoN

+0

@mewa 가능한 한 당신이 나를 보여줄 수 있는지에 관해 당신이 벌써 말했던 것처럼 내가 당신이 벌써 말했던 것처럼 – 0xDeMoN

답변

2

주석에서 지적한 것처럼 인수는 NULL로 끝나야합니다.

또한 mov al, 0xb은 (32 비트) eax 레지스터의 하위 8 비트 만 설정합니다. 앞서 스택의 주소를 eax mov eax, esp에로드했으며 스택이 커지기 때문에 eax에 저장된 값은 에 훨씬 가까워서 0이됩니다. 나중에 mov al, 0xb 일 때 마지막으로 F을 대체하고 eax정확히0xb 일 필요가 있습니다.

따라서 값을 전체 eax 레지스터로 옮기거나 미리 24 비트가 0으로 설정되어 있는지 확인해야합니다 (예 : xor eax, eax).

global _start 

section .text 
_start: 

push dword 0x0068732F ; Push /sh 
push dword 0x6E69622F ; Push /bin 
mov eax, esp   ; Store Pointer To /bin/sh In EAX 

push dword 0x0000632D ; Push -c 
mov ebx, esp   ; Store Pointer To -c In EBX 

push dword 0x00000068 ; Push h 
push dword 0x7361622F ; Push /bas 
push dword 0x6E69622F ; Push /bin 
mov ecx, esp   ; Store Pointer To /bin/bash In ECX 

push 0    ; <----- NULL args terminator 
push ecx    ; Push /bin/bash Pointer 
push ebx    ; Push -c Pointer 
push eax    ; Push /bin/sh Pointer 

mov ebx, eax   ; Move /bin/sh Pointer To EAX 
mov ecx, esp   ; Store /bin/sh -c /bin/bash Pointer in ECX 
xor edx, edx   ; Store 0 In EDX 
;xor eax, eax  ; <----- either xor eax, eax or mov into eax 
mov eax, 11   ; sys_execve 
int 0x80    ; system call