在最近的Linux上执行进程堆栈中的代码 [英] Execute code in process's stack, on recent Linux

查看:52
本文介绍了在最近的Linux上执行进程堆栈中的代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ptrace在正在运行的进程的堆栈中编写一段二进制代码.但是,这会导致分段错误(信号11).

I want to use ptrace to write a piece of binary code in a running process's stack. However, this causes segmentation fault (signal 11).

我可以确保%eip寄存器将指针指向要在堆栈中执行的第一条指令.我猜想有某种机制可以使linux保护堆栈数据成为可执行文件.

I can make sure the %eip register stores the pointer to the first instruction that I want to execute in the stack. I guess there is some mechanism that linux protects the stack data to be executable.

那么,有谁知道如何禁用这种对堆栈的保护.具体来说,我正在尝试 Fedora 15.

So, does anyone know how to disable such protection for stack. Specifically, I'm trying Fedora 15.

非常感谢!

阅读所有答复后,我尝试了execstack,它实际上使堆栈中的代码可执行.谢谢大家!

After reading all replies, I tried execstack, which really makes code in stack executable. Thank you all!

推荐答案

这可能是由于 NX位在现代处理器上.您可以使用 execstack 为您的程序禁用此功能.

This is probably due to the NX bit on modern processors. You may be able to disable this for your program using execstack.

http://advosys.ca/viewpoints/2009/07/disnbling-the-nx-bit-for-specific-apps/

http://linux.die.net/man/8/execstack

这篇关于在最近的Linux上执行进程堆栈中的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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