Well... I'm not very familiar with scripts. I ASSume the "hash bang" (#!) is handled by the shell (bash). I don't think it'll work with sys_execve. I can't get it to. Can you? I was getting "permission denied" trying it from the command line. Okay, maybe I have to be root? Made myself root - same problem! I don't know what's going on there.
This is pretty much the same thing I posted before. It seems to work. Are you having any luck with it? I'm having trouble with even a simple cut-and-paste! Hope I didn't butcher it too badly!
Best,
Frank
; nasm -f elf32 myfile.asm
; ld -o myfile myile.o -melf_i386
section .bss
.
elb resb 10
section .data
file db "b.sh", 0
file1 db "p.py", 0
ex db "/bin/bash", 0
ex1 db "/usr/bin/python", 0
cline dd ex ; argv[0]
dd file ; argv[1]
dd 0 ; zero terminated!
cline1 dd ex1
dd file1
dd 0
section .text
global _start
_start:
; prompt the poor befuddled user?
mov eax, 3
mov ebx, 0
mov ecx, elb
mov edx, 10
int 0x80
mov ebp, 0x0A303031 ; "100"NL (little endian!)
cmp ebp, [elb]
je jamp
; int 0x80 ; why?
jmp tojamp
jamp:
mov eax, 11
mov ebx, ex ;executable file
mov ecx, cline
xor edx, edx
int 0x80
mov ebx, 42 ; just for debugging (echo $?)
jmp stop
tojamp:
mov eax, 11
mov ebx, ex1 ;executable file1
mov ecx, cline1
xor edx, edx
int 0x80
mov ebx, 41 ; just for debugging
jmp stop
stop:
mov eax, 1
int 0x80