* Example of execve
@ 2003-04-29 19:31 Slack Traq
2003-04-29 21:39 ` Brian Raiter
2003-04-29 22:57 ` Gigi Sullivan
0 siblings, 2 replies; 3+ messages in thread
From: Slack Traq @ 2003-04-29 19:31 UTC (permalink / raw)
To: linux-assembly
Hello.
Can anyone give me an example of how can i implement
the execve syscall under asm, because I don't know how
to pass arrays as parameters.
Thank you in advance,
Slack Ware
__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: Example of execve
2003-04-29 19:31 Example of execve Slack Traq
@ 2003-04-29 21:39 ` Brian Raiter
2003-04-29 22:57 ` Gigi Sullivan
1 sibling, 0 replies; 3+ messages in thread
From: Brian Raiter @ 2003-04-29 21:39 UTC (permalink / raw)
To: linux-assembly
> Can anyone give me an example of how can i implement
> the execve syscall under asm, because I don't know how
> to pass arrays as parameters.
You don't pass arrays per se to execve(). execve() takes pointers to
arrays. Just construct the array somewhere in your data
segment. Simple example:
section .data
str1: db "foo", 0
str2: db "bar", 0
str3: db "baz", 0
array: dd str1, str2, str3, 0
section .text
push str1 ; filename
push array ; argv
push dword 0 ; envp
call execve
b
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Example of execve
2003-04-29 19:31 Example of execve Slack Traq
2003-04-29 21:39 ` Brian Raiter
@ 2003-04-29 22:57 ` Gigi Sullivan
1 sibling, 0 replies; 3+ messages in thread
From: Gigi Sullivan @ 2003-04-29 22:57 UTC (permalink / raw)
To: Slack Traq; +Cc: linux-assembly
Aiee :)
Hello!
On Tue, Apr 29, 2003 at 12:31:12PM -0700, Slack Traq wrote:
> Can anyone give me an example of how can i implement
> the execve syscall under asm, because I don't know how
> to pass arrays as parameters.
> Thank you in advance,
>
> Slack Ware
Here below you can find a simple example (nasm syntax)
about executing an execve syscall. For the sake of simplicity
there are no sanity checks, however.
; execve(2) syscall asm example
; nasm syntax
SECTION .text
_start:
mov ebx, array
lea ecx, [array+8]
lea edx, [array+12]
mov eax, 0xb
int 0x80
SECTION .data
array db '/bin/sh', 0
dd array
dd 0
This way we're not calling any glibc function but we're issuing
the 0x80 interrupt software. The ELF obtained it's fully relocatable
since we're running a syscall ...
Hope this helps a bit and that is what you're looking for.
bye,
GG sullivan
--
Lorenzo Cavallaro `Gigi Sullivan' <sullivan@sikurezza.org>
Until I loved, life had no beauty;
I did not know I lived until I had loved. (Theodor Korner)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-04-29 22:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-04-29 19:31 Example of execve Slack Traq
2003-04-29 21:39 ` Brian Raiter
2003-04-29 22:57 ` Gigi Sullivan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox