对于一个任务,我需要创建简单的 shellcode,但它不允许包含\x80。
注意:要在 Linux 上进行系统调用,如写入或退出,您需要以下行:int 0x80
,它最终会生成包含\x80 的 shellcode。
不过我需要进行系统调用,所以我现在的想法是使用一个变量作为中断向量号。例如 0x40 然后乘以 2,所以最后在 shellcode 中会有一个\x40 而不是\x80。
问题是 int 没有将变量作为参数,我试过这个来测试:
section .data
nr db 0x80
section .text
global _start
_start:
xor eax, eax
inc eax
xor ebx, ebx
mov ebx, 0x1
int [nr]
得到
error: invalid combination of opcode and operands
我怎样才能让我的想法付诸实现?或者您对这个问题有不同的解决方案吗?
附言。 sysenter 和 syscall 不工作 -> 非法指令
我在 x86-32 位机器上使用 nasm。
最佳答案
也许是这样的,但永远不要在严肃的代码中使用它!
format ELF executable
use32
entry start
segment executable writeable
start:
;<some code>
inc byte [ here + 1 ] ;<or some other math>
jmp here
here:
int 0x7f
segment readable writeable
(这是 fasm 代码)
关于linux - 有限制的 Shellcode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34110045/