我正在尝试研究 execve shellcode,
操作系统:Linux bt 2.6.39.4
root@bt:~/exploit# cat gshell.s
.globl _start
_start:
nop
jmp MyString
shell:
popl %esi
xorl %eax,%eax
movl %al,9(%esi)
movl %esi,10(%esi)
movl %eax,14(%esi)
movb $11,%al
movl %esi, %ebx
leal 0xa(%esi),%ecx
leal 0xe(%esi),%edx
int $0x80
movl $1,%eax
movl $0,%ebx
int $0x80
MyString:
call shell
shellvar:
.ascii "/bin/bashADDDDCCCC"
root@bt:~/exploit# as -gstabs -o gshell.o gshell.s
root@bt:~/exploit# ld -o gshell gshell.o
root@bt:~/exploit# ./gshell 分段错误(核心转储) root@bt:~/exploit#
广发银行:
(gdb) break *_start Breakpoint 1 at 0x8048054: 文件 gshell.s,第 6 行。
(gdb) r 启动程序:/root/exploit/gshell
程序收到信号 SIGSEGV,分段错误。shell () at gshell.s:14 14 movb %al,9(%esi)
(gdb) 打印 /x $esi $1 = 0x804807a (gdb) x/16cb $esi 0x804807a : 47 '/' 98 'b' 105 'i' 110 'n' 47 '/' 98 'b' 97 'a' 115 's' 0x8048082 : 104 'h' 65 'A' 68 'D' 68 'D' 68 'D' 68 'D' 67 'C' 67 'C' (gdb)
从上面的输出看来我已经成功地将 /bin/sh 地址放入 ESI 寄存器但是当我尝试将 0 移动到 9(%esi) --> 它会导致分段错误。甚至试图修改这个程序:movl $0 to $esi。想知道是否限制在 0x804807a 地址写入?哪个导致这个故障?以及如何继续成功运行这个 shellcode
谢谢,小杰克