【发布时间】:2013-03-06 10:54:49
【问题描述】:
我想用shellcode显示一个hello world,c代码很简单:
#include <stdio.h>
char shellcode[] = "\xeb\x17\x59\x31\xc0\xb0\x04\x31\xdb\x43\x31\xd2\xb2\x0f\xcd\x80\xb0\x01\xbb\x00\x00\x00\x00\xcd\x80\xe8\xe4\xff\xff\xff\x48\x65\x6c\x6c\x6f\x20\x73\x68\x65\x6c\x6c\x21\x0a\x0d";
int main(int argc, char **argv){
int (*func)();
func = (int (*)()) shellcode;
(int)(*func)();
return 0;
}
问题应该在汇编文件中,这里是:
BITS 32
jmp short one
;write hello world on standard output
two:
pop ecx ;i get string address
xor eax,eax
mov al,4
xor ebx,ebx
inc bl ;bl should be 1
xor edx,edx
mov dl,15
int 0x80
;exit with status 0
mov al,1
xor ebx,ebx
int 0x80
one:
call two
db "Hello shell!",0x0a,0x0d
代码运行良好,但显示“hello shell!”后不退出,反而像死循环一样一直显示这句话。
【问题讨论】:
-
我不是
int 0x80的专家,但你确定第一个系统调用不会破坏eax的前24 位(第二个系统调用必须为零)?跨度>
标签: c assembly x86 system-calls shellcode