环境变量地址随机化 [英] Randomization of environment variable addresses

查看:141
本文介绍了环境变量地址随机化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用bash。我一直在使用关掉ASLR在Ubuntu 11.04

I am using bash. I have switched off ASLR in Ubuntu 11.04 using

#sysctl -w kernel.randomize_va_space=0

和我已经使用出口从shell变量

And I have exported a variable from the shell using

$ export MYSHELL=/bin/sh

我写了一个C程序得到的地址 MYSHELL

void main(){
char* shell = getenv("MYSHELL");
if (shell)
    printf("0x%x\n", (unsigned int)shell);
}

据吐出 0xbffffe82
当我用它作为我的攻击对于RET到的libc,地址变更(虽然一个非常小的偏移量)的一部分。
为什么会出现这种情况?

此外,当我改变的二进制文件的文件名,并使用previously成功的地址,它不会工作,它已被重新定位到不同的地址。为什么?换句话说,什么是二进制文件的名称和环境变量地址的关系?这是由一个bash的保护功能?我如何关闭这个选项?

Also when I change the filename of the binary and use the previously successful address, it won't work, and it has been relocated to a different address. Why? In other words, What is the relation of binary names and environment variable addresses? Is this a protection feature by bash? How do I switch this off?

请注意:这不是功课

推荐答案

在程序启动时堆栈布局文件的这里。为什么改变程序(长真)的名称更改布局它应该是显而易见的。

Stack layout at program startup is documented here. It should be obvious why changing the name of the program (length really) changes the layout.

这篇关于环境变量地址随机化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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