gpt4 book ai didi

machine-code - 如何在没有 EXE 或 ELF 等容器的情况下手动编写和执行纯机器代码?

转载 作者:行者123 更新时间:2023-12-03 06:05:32 25 4
gpt4 key购买 nike

我只需要一个 hello world 演示来看看机器代码实际上是如何工作的。

虽然windows的EXE和linux的ELF接近机器码,但它不是PURE

如何编写/执行PURE机器代码?

最佳答案

可以手动编写纯机器代码无需汇编

Linux/ELF:https://github.com/XlogicX/m2elf 。这仍然是一项正在进行的工作,我昨天才开始工作。

“Hello World”的源文件如下所示:

b8    21 0a 00 00   #moving "!\n" into eax
a3 0c 10 00 06 #moving eax into first memory location
b8 6f 72 6c 64 #moving "orld" into eax
a3 08 10 00 06 #moving eax into next memory location
b8 6f 2c 20 57 #moving "o, W" into eax
a3 04 10 00 06 #moving eax into next memory location
b8 48 65 6c 6c #moving "Hell" into eax
a3 00 10 00 06 #moving eax into next memory location
b9 00 10 00 06 #moving pointer to start of memory location into ecx
ba 10 00 00 00 #moving string size into edx
bb 01 00 00 00 #moving "stdout" number to ebx
b8 04 00 00 00 #moving "print out" syscall number to eax
cd 80 #calling the linux kernel to execute our print to stdout
b8 01 00 00 00 #moving "sys_exit" call number to eax
cd 80 #executing it via linux sys_call

WIN/MZ/PE:

shellcode2exe.py(采用 asciihex shellcode 并创建合法的 MZ PE exe 文件)脚本位置:

https://web.archive.org/web/20140725045200/http://zeltser.com/reverse-malware/shellcode2exe.py.txt

依赖关系:

https://github.com/radare/toys/tree/master/InlineEgg

摘录

python setup.py build




sudo python setup.py install

关于machine-code - 如何在没有 EXE 或 ELF 等容器的情况下手动编写和执行纯机器代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5267988/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com