我使用带有g cc编译器的Linux。我尝试将二进制文件转换为文本文件并将其反向转换为可执行的二进制文件。我尝试使用./ .when文件运行反向操作。/filename文件出现错误::bash:./filename: cannot execute binary file: Exec format error.need对此问题的帮助以下是我执行的步骤:
save hello.c file // in main() only print "hello world"
gcc hello.c -o hello //get executable file
xxd -b hello | cut -d" " -f 2-7 | tr "\n" " " > output.txt // convert binary file to text file
sed -i 's/^\(.\)\{9\}//g' output.txt
sed -i 's/\(.\)\{16\}$//g' output.txt
for i in $(cat output.txt) ; do printf "\x$i" ; done > reversebinfile //convert text file into binary file
chmod 777 reversebinfile
./reversebinfile
get error : bash: ./shay: cannot execute binary file: Exec format error发布于 2017-11-01 18:34:36
xxd的输出已经是一个文本文件,为什么还要cut和sed它呢?
此外,xxd -r还会反转该转换:
xxd hello > output.txt
xxd -r output.txt > reversebinfilehttps://stackoverflow.com/questions/47052680
复制相似问题