Shellcode分段错误

时间:2015-01-18 10:31:31

标签: assembly x86 att

我开始在linux上学习shellcode。在汇编代码下面链接时,我遇到了分段错误。愿你帮我解决这个问题。提前致谢。

root@KaliLinux:~/Desktop# cat Untitled\ Document
1       .text
2
3       .globl _start
4
5       _start:
6
7                               jmp GetString
8
9                       ShellCode:
10                                      popl %esi

弹出字符串的地址。

11                                      xorl %eax,%eax
12                                      movb %al, 0x9(%esi)

将NULL写入字符串的第10个元素。但我在这里得到了分段错误。

13                                      movl %esi, 0xa(%esi)
14                                      movl %eax, 0xe(%esi)
15                                      movb $11, %al
16                                      movl %esi, %ebx
17                                      leal 0xa(%esi), %ecx
18                                      leal 0xe(%esi), %edx
19                                      int $0x80
20
21
22                      GetString:
23                              call ShellCode
24                              String:
25                                      .ascii "/bin/bashABBBBCCCC"

GDB输出

(gdb) break 11
Breakpoint 1 at 0x8048057: file exeshellused.a, line 11.
(gdb) run
Starting program: /home/OSEZEN/exeshellused
Breakpoint 1, ShellCode () at exeshellused.a:11
11                                      xorl %eax,%eax
(gdb) x/1s $esi
0x8048073 <String>:      "/bin/bashABBBBCCCC"

确认我得到了字符串的地址。

(gdb) s
12                                      movb %al, 0x9(%esi)
(gdb) info registers
eax            0x0      0
ecx            0x0      0
edx            0x0      0
ebx            0x0      0
esp            0xbffff590       0xbffff590
ebp            0x0      0x0
esi            0x8048073        134512755
edi            0x0      0
eip            0x8048059        0x8048059 <ShellCode+3>
eflags         0x246    [ PF ZF IF ]
cs             0x73     115
ss             0x7b     123
ds             0x7b     123
es             0x7b     123
fs             0x0      0
gs             0x0      0
(gdb) s
Program received signal SIGSEGV, Segmentation fault.
ShellCode () at exeshellused.a:12
12                                      movb %al, 0x9(%esi)

0 个答案:

没有答案
相关问题