So, after compiling and executing my program, I get the following error message that reads: “Segmentation Error” and strace error message:
--- SIGSEGV (Segmentation fault) @ 0 (0) --- +++ killed by SIGSEGV +++ Segmentation fault
Question: any ideas how I can fix this error and display a message in the shell code?
Build Code:
;r3v.asm ;r3v3rs3c - 3x_z3r0 [SECTION .text] global _start _start: jmp short ender starter: xor eax, eax xor ebx, ebx xor edx, edx xor ecx, ecx mov al, 4 mov bl, 1 pop ecx mov dl, 18 int 0x80 xor ebx, ebx int 0x80 ender: call starter db 'r3v3rs3c'
Build it with: nasm -f elf r3v.asm Link it with: ld -o r3v r3v.o Reset it with: objdump -d r3v Extract the shell code into the test program:
char code[] = "\xeb\x15\x31\xc0\x31\xdb\x31\xd2\x31\xc9\xb0\x04\xb3\x01\x59\xb2\x12\xcd\x80\31\xdb\xcd\x80\xe8\xe6\xff\xff\xff\x72\x33\x76\x33\x72\x73\x33\x63"; ; int main(int argc, char **argv) { int (*exeshell)(); exeshell = (int (*)()) code; (int)(*exeshell)(); }
Then I compile with: gcc shelltest.c -o shelltest Run it with: ./ shelltest and the output shows “Segmentation Error”.
source share