linux - 有限制的 Shellcode

标签 linux assembly nasm system-calls shellcode

对于一个任务,我需要创建简单的 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/

相关文章:

c - 为什么GDB和Objdump的指令地址是一样的?

汇编 Win32 _printf 代码崩溃

在实模式下结合 NASM、BCC 和 Ld86 : has bad magic number

node.js - 如何将 32 位 node.js(8.5.0) 安装到 64 位 ubuntu(17.0)?

c - 在 ARM7TDMI 上获取参数地址时 GCC 是否损坏?

assembly - 将 64 位 NASM 与 MinGW-64 链接会导致 "File format not recognized"错误

x86-64 - movlps 的 NASM 64 位立即地址给出 "dword data exceeds bounds"

linux - 在 linux 中使用最大内存的程序

linux - 根据另一个位置的目录列表从一个位置删除一堆目录?

linux - 共享库卸载的钩子(Hook)函数