Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Security 函数在x86中生成shell代码_Security_Assembly_X86_Spawn_Shellcode - Fatal编程技术网

Security 函数在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

我觉得这是一个非常基本的问题,但我似乎无法理解组装。我用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 $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的位置,谢谢,我会尝试一下!