小编Jor*_*ril的帖子

堆栈eip溢出x86 vs x86_64 easy C代码

让我跳过介绍并跳到好的部分.我正在阅读"道德黑客手册"并尝试一些示例代码(约为p175).

-------------------------------------------------- ---------------------------------------

目标:溢出堆栈中的EIP

示例代码:

##> cat overflow.c
main(){
    char str1[10];   // declare a 10byte string
    // next, copy 35 bytes of 'A' to 'str1'
    strcpy(str1,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
}
Run Code Online (Sandbox Code Playgroud)

-------------------------------------------------- ---------------------------------------

如果我在我的x86笔记本电脑上编译并运行它,那么结果就像预期的那样.

使用openSuse 12.1在X86上生成结果

##> uname -a
Linux linux-tzxm.site 3.1.0-1.2-desktop #1 SMP PREEMPT 
Thu Nov 3 14:45:45 UTC 2011 (187dde0) i686 i686 i386 GNU/Linux

##> cat /proc/sys/kernel/randomize_va_space 
1

##> gcc version 4.6.2 (SUSE Linux)
##> GNU gdb (GDB) SUSE (7.3-41.1.2)

##> gdb -q overflow

Reading symbols from /home/administrator/Programming/C/testProgs/overflow...done.

(gdb) run

Starting program: …
Run Code Online (Sandbox Code Playgroud)

c x86 assembly stack x86-64

10
推荐指数
1
解决办法
7727
查看次数

C中的字符串行为

我正在读C课程(这是荷兰语,所以可能你不会知道)并且有一个小练习来理解字符串行为.因此我创建了一个小的C程序来开始练习,但我的程序的第一个输出(对我来说)已经令人惊讶.

我的C程序的来源:

#include <string.h>
#include <stdio.h>

void printString(char *string)
{
    printf("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19\n");
    printf("%c ",string[0]);
    printf("%c ",string[1]);
    printf("%c ",string[2]);
    printf("%c ",string[3]);
    printf("%c ",string[4]);
    printf("%c ",string[5]);
    printf("%c ",string[6]);
    printf("%c ",string[7]);
    printf("%c ",string[8]);
    printf("%c ",string[9]);
    printf("%c  ",string[10]);
    printf("%c  ",string[11]);
    printf("%c  ",string[12]);
    printf("%c  ",string[13]);
    printf("%c  ",string[14]);
    printf("%c  ",string[15]);
    printf("%c  ",string[16]);
    printf("%d  ",string[17]);
    printf("%d  ",string[18]);
    printf("%d\n",string[19]);
}

void main(){

    char str[20];

    strcpy(str,"Dag grootmoeder!");
    printString(str);
}
Run Code Online (Sandbox Code Playgroud)

我用gcc编译(没有特殊的开关)并且多次运行程序:(对于会说英语的人Dag …

c arrays string

5
推荐指数
1
解决办法
160
查看次数

标签 统计

c ×2

arrays ×1

assembly ×1

stack ×1

string ×1

x86 ×1

x86-64 ×1