Вопрос

;fork
xor eax,eax
mov al,0x2
int 0x80
xor ebx,ebx
cmp eax,ebx
jz wget

;wait(NULL)
xor eax,eax
mov al,0x7
int 0x80

;rm /tmp/pubkey
cdq
push edx
push 0x79656b62
push 0x75702f70
push 0x6d742f2f  
mov ebx,esp
mov al,0xa
int 0x80

i have a problem with the above code because the unlink syscall exit with -38 (ENOSYS).
The sys_execve(wget) (the child) works correctly (the file is downloaded) but unlink doesn't.
I don't understand why i'm getting the ENOSYS error...

Это было полезно?

Решение

wait() returns the pid of the child process (or -1 on error). Since you're not clearing the AH register before the next syscall, chances are part of that value is still there, and you end up invoking an arbitrary system call instead of 0x0a.

Try setting EAX instead of AL:

mov ebx, esp
mov eax, 0x0a
int 0x80
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top