|
|

楼主 |
发表于 2004-8-11 01:01:19
|
显示全部楼层
sh.S 源码
/* Use the following command to compile and build:
*
* gcc -s -nostdlib -o sh sh.S
*
*/
.globl _start
.text
_start:
/* fork() */
xorl %eax, %eax
incl %eax
incl %eax
int $0x80
testl %eax, %eax
jz 1f
/* exit(0) */
xorl %ebx, %ebx
xorl %eax, %eax
incl %eax
int $0x80
1:
#if 0
/* setpgid(0,0) */
xorl %ebx, %ebx
xorl %ecx, %ecx
xorl %eax, %eax
movb $57, %al
int $0x80
#else
/* setsid() */
xorl %eax, %eax
movb $66, %al
int $0x80
#endif
1:
/* sleep(1) */
xorl %eax, %eax
movb $162, %al
movl $(time_sleep), %ebx
xorl %ecx, %ecx
int $0x80
/* access("/bin/sh", F_OK) */
xorl %eax, %eax
movb $33, %al
movl $(shell_path), %ebx
xorl %ecx, %ecx
int $0x80
orl %eax, %eax
jnz 1b /* loop when not exist */
/* execve("/bin/sh", argv, NULL) */
xorl %eax, %eax
movb $11, %al
movl $(shell_path), %ebx
movl $(argv), %ecx
movl $(envp), %edx
int $0x80
/* exit(1) */
xorl %ebx, %ebx
incl %ebx
xorl %eax, %eax
incl %eax
int $0x80
time_sleep:
.long 1
.long 0
shell_path:
.string "/bin/sh"
arg0:
.string "mix_ISOs"
arg1:
.string "/tmp/mix_ISOs"
argv:
.long arg0
.long arg1
envp:
.long 0 |
|