【问题标题】:Redirect output of a program that executes shellcode重定向执行 shellcode 的程序的输出
【发布时间】:2015-02-26 14:21:30
【问题描述】:

我有一个执行 shellcode 的小程序:

#include<stdio.h>
#include<string.h>
#include<stdlib.h>

char shellcode[]="here is the bytecode";


int main(int main, char *argv[]) {
      void (*ret)();
      ret = (void (*)())shellcode;
      (void)(*ret)();
}

我编译它:gcc -o file file.c -fno-stack-protector -z execstack。 然后我尝试将输出重定向到一个文件:./file &gt; tmp.txt 但它不起作用。这两个都不是:./file 2&gt; tmp.txt./file &amp;&gt; tmp.txt

输出总是打印到屏幕上,从不打印到文件中。谁能帮我?我真的需要那个 shellcode 的输出。

【问题讨论】:

  • shellcode 是做什么的?它如何打印输出?
  • 它工作了@ccarton!非常感谢;)

标签: c bash shell io-redirection shellcode


【解决方案1】:

如果重定向 stdout 和 stderr 不起作用,则程序可能直接访问终端。要捕获直接终端输出,您需要启动程序并连接 pseduo-tty。最简单的方法(我知道)是使用 ssh。试试:

ssh -qt localhost "./file" &gt; tmp.txt 2&gt;&amp;1

您需要安装 ssh 密钥以避免输入登录凭据。

编辑:糟糕,我的重定向顺序错误。菜鸟失误。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    相关资源
    最近更新 更多