0
私はg ccコンパイラでLinuxを使用しています。バイナリファイルをテキストファイルに変換して実行可能なバイナリファイルに変換しようとしました。./filenameファイルと逆のファイルを実行しようとするとエラーが発生します::bash:./filename:バイナリファイルを実行できません:Exec形式error.needこの問題のために役立つ ここで私が作った手順は以下のとおりです。テキストファイルからbinaty exeutableファイルを作成する
xxd
の出力は、既にテキストファイルです
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
がたくさんhi.thanks:
また、
xxd -r
は、変換を反転させます。 – shay@shayこれで問題が解決した場合は、* accepted *とマークすることを検討してください。答えの横にある「目盛り」をクリックしてください。詳細は「SOツアー」(http://stackoverflow.com/tour)をご覧ください。一般的には[ヘルプページ](http://stackoverflow.com/help)をお読みください。 –