All pastes #401969 Raw Edit

Someone

public text v1 · immutable
·published 2007-03-19 17:11 UTC
rendered paste body
write.asm 
//it writes BBBB to the stdout out exit(0)

xor     eax,eax
xor     ebx,ebx
xor     edx,edx
push    dword 0x42424242
mov     ecx, esp
mov     bl, 0x1
mov     dl, 0x4
mov al, 0x4
int 0x80

xor ebx, ebx
mov al, 0x1
int 0x80


#nasm write.asm
the output file is write


a program which dumps the hex of the shellcode in an array

# ./s-proc -p write


char shellcode[] =
        "\x66\x31\xc0\x66\x31\xdb\x66\x31\xd2\x66\x68\x42\x42\x42\x42"
        "\x66\x89\xe1\xb3\x01\xb2\x04\xb0\x04\xcd\x80\x66\x31\xdb\xb0"
        "\x01\xcd\x80";

#cat run_shellcode.c
const char c0de[] =
        "\x66\x31\xc0\x66\x31\xdb\x66\x31\xd2\x66\x68\x43\x43\x44\x45"
        "\x66\x89\xe1\xb3\x01\xb2\x04\xb0\x04\xcd\x80\x66\x31\xdb\xb0"
        "\x01\xcd\x80";

int main()
{
   char buf[sizeof(c0de)];
   strcpy(buf, c0de);
   ((void(*)())buf)();
}

#gcc run_shellcode.c -o run_shellcode
#./run_shellcode
Segmentation fault

my platform is debian sarge kernel Linux adsl2 2.6.8-mppe #1 Mon Oct 17 14:25:27 EEST 2005 i686 GNU/Linux

i tried to debug it and saw that it starts to run the shellcode in a segment called .debug003.then segfaults.

how can i run  this C program?