重定向执行 shellcode 的程序的输出
Redirect output of a program that executes shellcode
我有这个执行 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 > tmp.txt
但它不起作用。这都不是:./file 2> tmp.txt
或 ./file &> tmp.txt
输出总是打印到屏幕上,从不打印到文件中。谁能帮我?我真的需要那个 shellcode 的输出。
如果重定向 stdout 和 stderr 不起作用,则程序可能直接访问终端。要捕获直接终端输出,您需要在连接 pseduo-tty 的情况下启动程序。最简单的方法(据我所知)是使用 ssh。尝试:
ssh -qt localhost "./file" > tmp.txt 2>&1
您需要安装 ssh 密钥以避免必须输入登录凭据。
编辑:糟糕,我的重定向顺序错误。菜鸟错误。
我有这个执行 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 > tmp.txt
但它不起作用。这都不是:./file 2> tmp.txt
或 ./file &> tmp.txt
输出总是打印到屏幕上,从不打印到文件中。谁能帮我?我真的需要那个 shellcode 的输出。
如果重定向 stdout 和 stderr 不起作用,则程序可能直接访问终端。要捕获直接终端输出,您需要在连接 pseduo-tty 的情况下启动程序。最简单的方法(据我所知)是使用 ssh。尝试:
ssh -qt localhost "./file" > tmp.txt 2>&1
您需要安装 ssh 密钥以避免必须输入登录凭据。
编辑:糟糕,我的重定向顺序错误。菜鸟错误。