Linux针对执行Shellcode的安全措施 [英] Linux's security measures against executing shellcode

查看:243
本文介绍了Linux针对执行Shellcode的安全措施的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm learning the basics of computer security and I'm trying to execute some shellcode I've written. I followed the steps given here

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
$

因为我有了暂停程序,所以我只是将objdump输出复制到c文件中.

Since I got my pause program to work, I just copied the objdump output to a c file.

test.c:

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

但这会产生段错误.现在,这只能归因于Arch Linux(?)的安全措施.那我该如何工作呢?

But this produces a segfault. Now, this can only be due to security measures of Arch Linux (?). So how can I get this to work?

推荐答案

s所在的页面没有执行权限映射.由于您使用的是x86_64,因此您肯定在硬件方面获得了NX支持.默认情况下,这些天的代码和数据位于非常独立的页面中,数据没有执行权限.

The page s lives in isn't mapped with execute permissions. Since you're on x86_64 you definitely have NX support in hardware. By default these days code and data live in very separate pages, with data not having the execute permission.

您可以使用 mmap() 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆