地址空间布局随机化的C编译器 [英] Address Space Layout Randomization in C Compilers

查看:151
本文介绍了地址空间布局随机化的C编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我没有记错,ASLR将在C编译器中的局部变量每次我运行程序时有不同的地址。但是,当我在Turbo C ++和开发-CPP IDE试了一下,它只是返回一个类似的地址局部变量。在code我尝试:

If I am not mistaken, ASLR will make the local variables in C compilers have a different address each time I run the program. But when I tried it in Turbo C++ and Dev-CPP IDE, it just returns a similar address for local variables. The code i tried:

#include <stdio.h>
#include <conio.h>

int main()
{
 int x = 10;
 int *ptr = &x;
 printf("%d", ptr);
 getch();
 return 0;
}

之前,我认为在局部变量的地址是相同的,因为它是在相同的堆栈区域分配,因此在同一存储器地址。但是,当我在计算器这里找到一个线程约ASLR,它让我做这些。我想这是因为编译器。任何人都可以揭示出这个光?

Before, I thought the address of the local variables are the same because it is allocated in the same stack area and thus the same memory address. But when i found a thread here in stackoverflow about ASLR, it made me did these. I guess this is because of the compilers. Can anyone shed a light on this?

编辑:

林。

推荐答案

看来你使用的是Windows。

It appears you are using windows.

维基

微软的Windows Vista(发布2007年1月),后来有ASLR
  对于只有那些可执行文件和动态链接库启用
  具体联系启用ASLR到。
  出于兼容性考虑,它不会被默认启用其他
  应用程序。
  通常情况下,只有旧的软件不兼容,ASLR可以完全
  通过编辑注册表项启用
  HKLM \\系统\\ CurrentControlSet \\控制\\会话管理器\\内存
  管理\\ MoveImages。

Microsoft's Windows Vista (released January 2007) and later have ASLR enabled for only those executables and dynamic link libraries specifically linked to be ASLR-enabled. For compatibility, it is not enabled by default for other applications. Typically, only older software is incompatible and ASLR can be fully enabled by editing a registry entry "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management\MoveImages".

基于主机的入侵prevention系统,如WehnTrust和
  臭氧还提供了ASLR的Windows XP和Windows Server 2003
  操作系统。 WehnTrust是开源的完整细节
  臭氧的实现是不可用

Host-based intrusion prevention systems such as WehnTrust and Ozone also offer ASLR for Windows XP and Windows Server 2003 operating systems. WehnTrust is open-source Complete details of Ozone's implementation is not available

请确保您启用了ASLR,观察预期行为。

Make sure you enable the ASLR to observe the expected behaviour.

这篇关于地址空间布局随机化的C编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆