Security 函数在x86中生成shell代码
我觉得这是一个非常基本的问题,但我似乎无法理解组装。我用x86编写了一个函数来生成一个shell,但它似乎什么也没做。有人能给我指一下正确的方向吗Security 函数在x86中生成shell代码,security,assembly,x86,spawn,shellcode,Security,Assembly,X86,Spawn,Shellcode,我觉得这是一个非常基本的问题,但我似乎无法理解组装。我用x86编写了一个函数来生成一个shell,但它似乎什么也没做。有人能给我指一下正确的方向吗 .global main .text create_shell: push %ebp movl %esp,%ebp subl $16,%esp xorl %edi,%edi xorl %ebx,%ebx xorl %esi,%esi pushl %edi movl $0x
.global main
.text
create_shell:
push %ebp
movl %esp,%ebp
subl $16,%esp
xorl %edi,%edi
xorl %ebx,%ebx
xorl %esi,%esi
pushl %edi
movl $0x2f62686e,%edi ;this and the next instruction movl is /bin/sh in hex
push %ebx
movl $0x2f7368,%ebx
add %ebx,%edi
int 0x80
mov $1,%eax
mov $0,%ebx
int 0x80
leave
ret
main:
call create_shell
ret
您应该使用调试器(gdb)来查看正在发生的事情。你也可以通过
strace
运行你的程序,它会显示所有的系统调用和参数。我可以告诉你int 0x80
是错误的。你想要int$0x80
并且GNU汇编程序中的注释使用
而不是代码>看不到在第一个int$0x80
之前设置EAX的位置,谢谢,我会尝试一下!