0x7fffffffeef8: xor %rsi,%rsi
0x7fffffffeefb: xor %rax,%rax <- now rax is 0
0x7fffffffeefe: movabs $0xff978cd091969dd1,%rbx <- rbx='/bin/dash'
0x7fffffffef08: neg %rbx
0x7fffffffef0b: push %rbx
0x7fffffffef0c: push %rsp
0x7fffffffef0d: pop %rdi <- rdi is string
0x7fffffffef0e: mov $0x3b,%al
0x7fffffffef10: syscall
(gdb) stepi
0x00007fffffffef08 in ?? ()
(gdb) stepi
0x00007fffffffef0b in ?? ()
(gdb) stepi
0x00007fffffffef0c in ?? ()
(gdb) stepi
0x00007fffffffef0d in ?? ()
(gdb) stepi
0x00007fffffffef0e in ?? ()
(gdb) stepi
0x00007fffffffef10 in ?? ()
(gdb) stepi
0x00007fffffffef12 in ?? ()
In 0x7fffffffef10
, syscall instruction exists. But when I use stepi command in GDB, I never execute /bin/dash
. I think this assembly should execute /bin/dash
. Did I misunderstand?
I uploaded full assembly code. I changed xor %eax, %eax
to xor %rax, %rax
I added xor %rdx, %rdx
in assembly code. But I can't get expected results.
process 1993 is executing new program: /bin/dash
[Inferior 1 (process 1993) exited normally]
(gdb)
Result is like this but what I wanted is $
instead of (gdb)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(void)
{
char str[256];
printf("Type sentence.\n");
gets(str);
printf("%s\n", str);
}
Above is program which shell code was inserted.
I use Linux 16.04, x64 architecture