我使用Linux和g cc编译器。我尝试将二进制文件转换为文本文件并将其反转为可执行二进制文件。当我尝试使用./filename文件运行反向时,我得到错误:: bash:./ filename:无法执行二进制文件: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
答案 0 :(得分:1)
xxd
的输出已经是一个文本文件了,为什么你cut
和sed
呢?
此外,xxd -r
会撤消转化:
xxd hello > output.txt
xxd -r output.txt > reversebinfile