【问题标题】:Inject Shellcode - program running and need to inject hexcode from maybe pythonInject Shellcode - 程序正在运行并且需要从 python 注入 hexcode
【发布时间】:2014-10-16 03:45:45
【问题描述】:

所以我有一个易受攻击的程序,可以使用缓冲区溢出来利用它。经过分析,我得到了所有相关值(缓冲区大小、要注入的地址等) 问题是我需要自动化给它的输入。

这正是发生的事情:

  1. 程序要求正常输入 --(此处不存在漏洞)
  2. 它要求第二个输入——这是用 shellcode 注入的

我尝试从文件中发送输入(通过使用有效负载说 python -c 'print '.. blah blah 来编写它),但文件以某种方式发送 ascii 表示并与所需的输入混淆

我尝试过的事情:写了一个这样的 shell 脚本:

echo -e "<first input>\r";
python -c 'print "A"*100 + "<shell code>"+"<ret>";

之后我将此文件作为输入发送:$ ./vuln &lt; File

当程序提示输入第二个输入时,我是否从 python 发送输出?

【问题讨论】:

    标签: python buffer-overflow exploit shellcode


    【解决方案1】:

    您可以使用expect,这是一个用于自动与公开文本终端界面的程序交互的程序。

    脚本应如下所示:

    #!/usr/bin/expect
    spawn programUnderTest
    expect firstPrompt
    send firstInput
    expect secondPrompt
    send secondInput
    

    【讨论】:

      猜你喜欢
      • 2017-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-09-14
      相关资源
      最近更新 更多