Linux的安全措施反对执行shellcode

Ram*_*Ram 2 x86-64 linux-kernel archlinux shellcode

我正在学习计算机安全的基础知识,并且我正在尝试执行一些我写过的shellcode.我按照这里给出的步骤

http://dl.packetstormsecurity.net/papers/shellcode/own-shellcode.pdf

http://webcache.googleusercontent.com/search?q=cache:O3uJcNhsksAJ:dl.packetstormsecurity.net/papers/shellcode/own-shellcode.pdf+own+shellcode&cd=1&hl=nl&ct=clnk&gl=nl

$ cat pause.s
xor %eax,%eax
mov $29,%al     
int $0x80       
$ as -o pause.o pause.s
$ ld -o pause pause.o
ld: warning: cannot find entry symbol _start; defaulting to <<some address here>>
$ ./pause 
^C
$ objdump -d ./pause
pause:     file format elf64-x86_64
Disassembly of section .text:
      08048054 <.text>:
      8048054: 31 c0     xor    %eax,%eax
      8048056: b0 1d     mov    $0x1d,%al
      8048058: cd 80     int    $0x8
$
Run Code Online (Sandbox Code Playgroud)

由于我让暂停程序工作,我只是将objdump输出复制到ac文件.

test.c的:

int main()
{
    char s[] = "\x31\xc0\xb0\x1d\xcd\x80";
    (*(void(*)())s)();
}
Run Code Online (Sandbox Code Playgroud)

但这会产生段错误.现在,这只能归功于Arch Linux(?)的安全措施.那我怎么能让它运作起来呢?

Fle*_*exo 7

s生活中的页面未使用执行权限进行映射.因为你在x86_64上,你肯定在硬件上有NX支持.默认情况下,这些天代码和数据存在于非常独立的页面中,数据没有执行权限.

您可以解决这跟要么mmap()mprotect()分配或改变页面有PROT_EXEC权限.