asm_execve.s:
.section .data
file_to_run:
.ascii "/ bin / sh"
.section .text
.globl main
main:
pushl% ebp
movl% esp,% ebp
subl $ 0x8,% esp # array of two pointers. array [0] = file_to_run array [1] = 0
movl file_to_run,% edi
movl% edi, -0x4 (% ebp)
movl $ 0, -0x8 (% ebp)
movl $ 11,% eax # sys_execve
movl file_to_run,% ebx # file to execute
leal -4 (% ebp),% ecx # command line parameters
movl $ 0,% edx # environment block
int $ 0x80
leave
ret
Makefile:
NAME = asm_execve
$ (NAME): $ (NAME) .s
gcc -o $ (NAME) $ (NAME) .s
The program is running, but sys_execve is not called:
alex@alex32 : ~ / project $ make
gcc -o asm_execve asm_execve.s
alex@alex32 : ~ / project $ ./asm_execve
alex@alex32 : ~ / project $
Expected Result:
alex@alex32 : ~ / project $ ./asm_execve
$ exit
alex@alex32 : ~ / project $
This build program should work like the following C code:
char * data [2];
data [0] = "/ bin / sh";
data [1] = NULL;
execve (data [0], data, NULL);
Is there something wrong with the system call parameters?
source share