CSAPP: Buffer Lab

CSAPP:Attack Lab —— 缓冲区溢出攻击实验 CSAPP:Attack Lab —— 缓冲区溢出攻击实验 X86-64寄存器和栈帧 Part I:Code Injection Attacks Part II:Return-Oriented Programming Attacks 阅读详情

介绍

该实验能够帮助你更好的理解IA-32的过程调用和程序栈的组织情况。在实验中我们需要对于文件夹中bufbomb可执行文件进行栈溢出攻击。


实验前准备

  1. 下载相应的buffer Lab实验文件,里面包含三个可执行文件
    相关实验代码的Github下载链接如下https://github.com/Davon-Feng/CSAPP-Labs 中的Buffer Lab
文件名 作用
bufbomb 栈溢出实验主要的攻击目标
makecookie 根据用户输入的userid生成唯一(很大可能)的4字节字符串
hex2raw 将用户构造的2进制字符串转换为字符串

2. makecookie使用方法
3. hex2raw使用方法
4. bufbomb的参数

在下载的Buffer lab文件夹中buflab.pdf中有以上四点的指导内容,在实验前要仔细阅读

注意:这个程序运行时要有一个userid参数,我的设置的是yzf, 不同的userid会对应不同的结果.我的答案如果换成别的userid的话就不成功.
而且也可能和机器有关,因为程序中一些变量的存放位置可能不同.


实验过程

level0:Candle

在bufbomb中getbuf()方法会被test()调用。两个函数的C语言程序如下所示

 /*Buffer size for getbuf*/
    #define NORMAL_BUFFER_SIZE 32

    int getbuf()
    {
        char bur[NORMAL_BUFFER_SIZE];
        Gets(buf);
        return 1;
    }

    void test()
    {
        int val;
        /* Put canary on stack to detect possible corruption*/
        volatile int local = uniqueval();

        val = getbuf();

        /*Check for corrupted stack*/
        if(local != uniqueval){
            printf("Sabotaged:the stack has been corrupted\n");
        }else if(val == cookie){
            printf("Boom!:getbuf returned 0x%x\n",val);
            validate(3);
        }else{
            printf("Dud:getbuf return 0x%x\n",val
CSAPP-LAB3-Attack 文章目录00 PrerequisitePart 1: Code injection1.1 phase_11.2 phase_21.3 phase_3Part2: Returned-Oriented Programming2.1 phase_42.2 Phase_5 00 Prerequisite 听见课堂上老爷子说: But to be a good person you also know what the bet have to know what the bad people do, so part 阅读详情

相关推荐

CSAPP LAB---buflab-handout(缓冲区溢出实验)

LAB5 基础准备: 题目解析: 首先阅读那长达11页的英文文档,获悉本实验为模拟缓冲区溢出。 使用tar xvf命令解压文件后,会有3个可执行的二进制文件bufbomb,hex2raw,makecookie。 bufbomb运行时会进入getbuf函数,其中通过调用Gets函数读取字符串。要求在已知缓冲区大小的情况下对输入的字符串进行定制完成特定溢出操作。getbuf函数如下所示:

The_V_的博客 2万+

CSAPP第三版实验刷题指南:从Data Lab到Cache Lab的进阶路径

计算机系统性能优化离不开底层原理的扎实理解,位运算、反汇编调试与内存管理是系统程序员的基本功。CSAPP第三版配套实验通过Data Lab的位操作挑战、Bomb Lab的GDB反汇编与缓冲区溢出分析、Shell Lab的进程控制、Malloc Lab的内存分配器实现以及Cache Lab的缓存模拟等九个项目,将课本知识转化为可验证的工程实践。沿着由位级数据表示到进程控制、内存分配、缓存优化的递进路径,学习者能有效提升调试能力、异常处理思维与系统设计素养。无论是高校课程实验、系统方向面试准备,还是日常工作中排

weixin_29174141的博客 231

CSAPP_buflab 解答详细过程(内含源程序包及文档)

经典的缓冲区溢出实验,buflab,CMU大学(卡耐基 梅隆大学)经典计算机课程实验之一, 里面含有实验完整内容及其源程序, 还有详细的解答过程, 很多国内大学的计算机课程都选用此实验作为其课程设计之一!

Unity中5分钟实现3D高斯泼溅渲染:从原理到实战部署

3D高斯泼溅(3D Gaussian Splatting)是一种新兴的神经渲染技术,它通过显式地使用大量3D高斯椭球来表示场景,革新了传统的体渲染和神经辐射场(NeRF)方法。其核心原理是将这些3D高斯投影到2D屏幕并进行快速光栅化与Alpha混合,从而绕过了耗时的光线步进,实现了极高的渲染效率。这项技术的价值在于,它能够在消费级GPU上达到实时甚至超实时的帧率,同时保持紧凑的数据表达和惊人的视觉细节,极大地降低了高质量3D重建与渲染的门槛。在应用场景上,它正快速渗透到数字孪生、虚拟现实、文化遗产数字化以及

weixin_29474431的博客 289

PPPoE上网配置不求人:华为路由器命令行操作指南(2023最新版)

本文提供2023年最新的华为路由器PPPoE上网配置命令行操作指南。通过详细的步骤讲解,从连接设备、创建拨号接口、绑定PPPoE客户端到配置内网与NAT,手把手教你完成配置,并附有验证排错方法,助你轻松实现稳定上网。

s4t5u6v的博客 686

UE5与Cesium for Unreal结合:打造高效离线地图解决方案

本文详细介绍了如何利用UE5与Cesium for Unreal结合打造高效离线地图解决方案,特别适用于数字孪生、军事仿真等网络不稳定场景。通过优化配置、数据处理和性能调优,实现TB级地形数据的流畅渲染,并结合实战案例展示了在油田巡检等复杂环境中的应用效果。

weixin_29007135的博客 501

海康威视国内版监控设备改英文界面难题:原因解析与解决方案

跨境安防设备部署中,国内采购的海康威视监控设备常因仅支持中文界面导致海外用户无法操作。本文剖析了该问题的核心原因:海康威视对国内版和海外版设备实行区域锁定策略,国内版固件仅内置中文且无法通过常规方式切换语言。针对此问题,文章提供了三种解决方案:1)官方合规的海外版固件更换;2)低成本的操作界面翻译与远程协助;3)长期更换海外版设备的彻底解决方案。同时给出了跨境采购的注意事项,强调应提前确认设备版本、拒绝非官方改造并预留适配时间。

海康威视技术支持 3999

C++如何实时监测另一个进程是否已经退出?(附源码)

调用WaitForSingleObject实时监测目标进程是否已经退出

dvlinker的技术专栏 8280

深度学习图神经网络 (GNN) —— 处理图结构数据(六十九)

本文系统介绍了图神经网络(GNN)的核心概念、主流模型及其应用。主要内容包括: GNN基础:阐述了图结构数据的特性(节点数不定、连接不规则),以及GNN相比CNN/RNN的优势在于处理非欧式空间的图数据。 核心机制:重点讲解了消息传递框架(MPNN),通过聚合邻居信息迭代更新节点表示,并分析了GCN的归一化邻接矩阵计算和GAT的注意力权重机制。 典型模型: GCN:基于归一化邻接矩阵的特征传播 GAT:引入注意力机制区分邻居重要性 GraphSAGE:通过采样解决大图扩展性问题 GIN:理论表达能力最强的图

hello.reader 306

数字盲水印嵌入和提取的实现基于小波变换DWT算法

数字盲水印是指在不知道原始图像的情况下,在其上嵌入水印并在后续的提取过程中能够恢复出原始水印的一种技术。本文介绍的数字盲水印嵌入和提取的实现方法基于小波变换DWT算法。具体来讲,DWT将信号或图像进行二次下采样和卷积滤波,使得高频分量的图像信息被集中在一个小区域内,方便进行嵌入和提取操作。其中 a 表示嵌入强度,而 watermark 则是用于嵌入的水印图像,这里我们嵌入的是一个全灰的图像。通过以上的代码,我们可以实现数字盲水印的嵌入和提取,并在一定程度上保护数字图片的版权安全。

HackWhisper的博客 518

【安卓逆向】python版本 sha源码

免责声明本文内容仅供学习交流使用,严禁用于商业和非法用途。抓包数据、敏感网址以及数据接口已进行脱敏处理。 注:如有引用,请标注文章地址!!!!!!!

Coodekun的博客 819

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: CSAPP: Bomb Lab(4)
下一篇: CSAPP: Architecture Lab
ethanyzf
博客等级 码龄13年 82粉丝 24原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值