尝试使用python上的脚本调试程序(带缓冲区溢出)我需要恢复程序可能发送的所有消息。
在Linux上,在终端上正常调用./a.out AAA响应
你的论点是:AAA
溢出输入:./a.out AAAAAAA回应
你的论点是:AAAAAAA
分段故障
我按如下方式构建python代码
import sys, string, os
from subprocess import Popen, PIPE
processName = os.getcwd() + "/a.out"
argument = "AAAAAAAAA"
p = Popen([processName, argument], stdout=PIPE, stderr=PIPE)
output, error = p.communicate()
print(":: %d %s %s" % (p.returncode, output, error))
但是我无法获得Segmentation故障消息
就我搜索而言,都没有找到所需的参数
该过程实际上并不打印Segmentation fault
。当你从shell运行a.out
时,这实际上是由shell本身产生的。因此,它不是您的程序生成的消息。
见What actually prints "Segmentation fault"?
但是,您可以通过将p.returncode
与-signal.SIGSEGV
模块中的signal
进行比较来检查流程的返回代码,以查看它是否因分段错误而停止,有关详细信息,请参阅下面链接的问题。