linux 编译汇编生成 elf 文件,可执行流

2018-03-18  本文已影响8人  that_is_this
  1. 编写 shellcode
.text 
    .global _start
    
_tiny_exit:
    movl $0,%ebx
    movl $1,%eax
    int $0x80
    
_tiny_msg:
    .ascii "Hello world!\n"
    
_get_rip:
    mov (%esp), %ecx
    ret
    
_start:
    push %esp
    push %ebp
    mov %esp, %ebp
    push %edx
    push %ecx
    push %ebx
    push %eax
    
    mov $14, %edx
    call _get_rip
    add $-36,%ecx
    mov $1,%ebx
    mov $4, %eax
    int $0x80

    pop %eax
    pop %ebx
    pop %ecx
    pop %edx
    pop %ebp
    pop %esp
    
    jmp _tiny_exit
  1. 对应的是 32 位
as --32 -o inject.o inject.s
ld -m elf_i386 -o inject inject.o
上一篇 下一篇

猜你喜欢

热点阅读