问题描述
只是好奇。这显然是不实际编程一个很好的解决方案,但说我要拍一个可执行的祝福(十六进制编辑器)。
Just curious. This obviously isn't a very good solution for actual programming, but say I wanted to make an executable in Bless (a hex editor).
我的体系是x86。什么是一个非常简单的程序,我可以做什么呢?一个Hello World?一个无限循环?类似<一个href=\"http://stackoverflow.com/questions/11743662/writing-an-executable-manually-machine-$c$c-with-hex-editor\">this的问题,但在Linux中。
My architecture is x86. What's a very simple program I can make? A hello world? An infinite loop? Similar to this question, but in Linux.
推荐答案
正如我在评论中提到,你基本上将编写自己的小精灵头可执行消除不需要的部分。还有几个必要的部分。在不公平地解释这个过程中的文档。为了好玩,这里有几个例子:
As mentioned in my comment, you will essentially be writing your own elf-header for the executable eliminating the unneeded sections. There are still several required sections. The documentation at Muppetlabs-TinyPrograms does a fair job explaining this process. For fun, here are a couple of examples:
/斌/等效真(45字节):
00000000 7F 45 4C 46 01 00 00 00 00 00 00 00 00 00 49 25 |.ELF..........I%|
00000010 02 00 03 00 1A 00 49 25 1A 00 49 25 04 00 00 00 |......I%..I%....|
00000020 5B 5F F2 AE 40 22 5F FB CD 80 20 00 01 |[_..@"_... ..|
0000002d
您的经典世界,你好! (160字节):
00000000 7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00 |.ELF............|
00000010 02 00 03 00 01 00 00 00 74 80 04 08 34 00 00 00 |........t...4...|
00000020 00 00 00 00 00 00 00 00 34 00 20 00 02 00 28 00 |........4. ...(.|
00000030 00 00 00 00 01 00 00 00 74 00 00 00 74 80 04 08 |........t...t...|
00000040 74 80 04 08 1f 00 00 00 1f 00 00 00 05 00 00 00 |t...............|
00000050 00 10 00 00 01 00 00 00 93 00 00 00 93 90 04 08 |................|
00000060 93 90 04 08 0d 00 00 00 0d 00 00 00 06 00 00 00 |................|
00000070 00 10 00 00 b8 04 00 00 00 bb 01 00 00 00 b9 93 |................|
00000080 90 04 08 ba 0d 00 00 00 cd 80 b8 01 00 00 00 31 |...............1|
00000090 db cd 80 48 65 6c 6c 6f 20 77 6f 72 6c 64 21 0a |...Hello world!.|
000000a0
不要忘了让他们的可执行...
Don't forget to make them executable...
这篇关于如何在Linux中使用十六进制编辑器可执行ELF文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!