首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从文本文件创建二进制可执行文件

从文本文件创建二进制可执行文件
EN

Stack Overflow用户
提问于 2017-11-01 18:24:37
回答 1查看 66关注 0票数 0

我使用带有g cc编译器的Linux。我尝试将二进制文件转换为文本文件并将其反向转换为可执行的二进制文件。我尝试使用./ .when文件运行反向操作。/filename文件出现错误::bash:./filename: cannot execute binary file: Exec format error.need对此问题的帮助以下是我执行的步骤:

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2017-11-01 18:34:36

xxd的输出已经是一个文本文件,为什么还要cutsed它呢?

此外,xxd -r还会反转该转换:

代码语言:javascript
复制
xxd hello > output.txt
xxd -r output.txt > reversebinfile
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47052680

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档