execve的外壳code的Linux分割故障 [英] execve shellcode linux segmentation fault

查看:202
本文介绍了execve的外壳code的Linux分割故障的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试着运行这个shell code,但它抛出我:分段错误错误
外壳code是以下内容:

Im trying to run this shellcode but it throws me: "Segmentation fault" error The shellcode is the following:

壳code.asm:

global _start
_start:

jmp short ca
doit:
pop ebx
xor eax, eax
cdq
mov byte [ebx+7], al
mov long [ebx+8], ebx
mov long [ebx+12], eax
lea ecx, [ebx+8]
mov byte al, 0x0b

int 0x80
ca:
call doit
db '/bin/sh'

NASM -f精灵壳code.asm':

我编译
与它联系起来:LD -m elf_i386 -s -o壳code壳code.o

i compile it with : 'nasm -f elf shellcode.asm' and link it with: ' ld -m elf_i386 -s -o shellcode shellcode.o

我想,当我使用MOV [EBX + X],人/ EAX / EBX错误的是
因为当我从codeŸ抹掉它得不到任何错误

I think the error is when I use mov [ebx+x], al/eax/ebx because when I erase it from the code y get no error

感谢您

推荐答案

您的问题是,的.text 部分是默认情况下不写。做最简单的就是把你的code到标记为可写一个新的自定义栏目。加入这一行你的汇编文件的顶部:

Your problem is that the .text section is not writable by default. The easiest thing to do is put your code into a new custom section that is marked as writable. Add this line at the top of your asm file:

section .shellcode  progbits alloc exec write align=16

您也可以通过 -N 开关连接器。

You could also pass the -N switch to the linker.

另外,你可以使其使用堆栈创建参数改写壳code。

Alternatively, you could rewrite the shellcode so that it uses the stack to create the arguments.

这篇关于execve的外壳code的Linux分割故障的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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