2016-04-09 13 views
0

Ich arbeite mich durch this tutorial, aber es ist für 32-Bit-Prozessoren geschrieben. Ich habe diese Notiz auf 64 bit linux syscall gefunden. Ich kann es kompilieren, ausführen und objdump.Wie ShellCode in Linux mit x64-Prozessor.

Meine Frage ist, warum der folgende Code einen Segmentierungsfehler generiert.

/* shellcodetest.c */ 

char code[] = "\x48\x31\xc0\xb0\x3c\x48\x31\xff\x0f\x05"; 
int main(int argc, char **argv){ 
    int (*func)(); 
    func = (int (*)()) code; 
    (int)(*func)(); 
} 

/*  
exitt:  file format elf64-x86-64  

Disassembly of section .text: 

0000000000400078 <_start>: 
    400078: 48 31 c0    xor %rax,%rax 
    40007b: b0 3c     mov $0x3c,%al 
    40007d: 48 31 ff    xor %rdi,%rdi 
    400080: 0f 05     syscall 
*/ 

Als Referenz syscall 60 (\ x3c) ist exit(). Das sollte also nur exit aufrufen (0);

Antwort