how2heap(5):tcache_poisoning 2.31
tcache_poisoning 2.31
依然还是将非堆段地址作为伪造堆块挂进tcache bin中,重新申请作为正常堆块启用
源码
1 #include <stdio.h> 2 #include <stdlib.h>3 #include <stdint.h>4 #include <assert.h>5 6 int main()7 {8 // disable buffering9 setbuf(stdin, NULL);10 setbuf(stdout, NULL);11 12 printf("This file demonstrates a simple tcache poisoning attack by tricking malloc into\n"13 "returning a pointer to an arbitrary location (in this case, the stack).\n"14 "The attack is very similar to fastbin corruption attack.\n");15 printf("After the patch https://sourceware.org/git/?p=glibc.git;a=commit;h=77dc0d8643aa99c92bf671352b0a8adde705896f,\n"16 "We have to create and free one more chunk for padding before fd pointer hijacking.\n\n");17 18 size_t stack_var;19 printf("The address we want malloc() to return is %p.\n", (char *)&stack_var);20 21 printf("Allocating 2 buffers.\n");22 intptr_t *a = malloc(128);23 printf("malloc(128): %p\n", a);24 intptr_t *b = malloc(128);25 printf("malloc(128): %p\n", b);26 27 printf("Freeing the buffers...\n");28 free(a);29 free(b);30 31 printf("Now the tcache list has [ %p -> %p ].\n", b, a);32 printf("We overwrite the first %lu bytes (fd/next pointer) of the data at %p\n"33 "to point to the location to control (%p).\n", sizeof(intptr_t), b, &stack_var);34 b[0] = (intptr_t)&stack_var;35 printf("Now the tcache list has [ %p -> %p ].\n", b, &stack_var);36 37 printf("1st malloc(128): %p\n", malloc(128));38 printf("Now the tcache list has [ %p ].\n", &stack_var);39 40 intptr_t *c = malloc(128);41 printf("2nd malloc(128): %p\n", c);42 printf("We got the control\n");43 44 assert((long)&stack_var == (long)c);45 return 0;46 }
调试
22行下断点,创建变量stack_var,其地址如下:
接下来在第28行下断点,申请两个0x90(data部分为0x80)大小的堆块chunk_a和chunk_b:
34行下断点,先释放chunk_a在释放chunk_b:
37行下断点,将chunk_b的位置修改成stack_var的地址
接下来在40行下断点,重新申请一个0x90大小的堆块,将bin中的chunk_b申请出来,由于chunk_b的fd指针指向的是stack_var,所以在bin中的表现形式为chunk_b --> stack_var。因此当chunk_b被启用后,挂在tcache bin头部的堆块就变成了stack_var:
最后在44行下断点,申请一个0x90大小的堆块chunk_c,这个时候由于tcache bin的头部为stack_var,并且stack_var挂在的0x90这串链表中,所以stack_var就被作为一个堆块启用了:
总结
- 比较基础的修改堆块fd指针的操作
- 如果想要利用该技巧,需要能够对释放堆块进行写操作,那么就说明释放之后堆块的malloc指针没有被清空
how2heap(5):tcache_poisoning 2.31相关推荐
- how2heap(3):overlapping_chunks 2.31
overlapping_chunks 2.31 源码 1 /*2 3 A simple tale of overlapping chunk.4 This technique is taken from ...
- 【31】GPU(下):为什么深度学习需要使用GPU?
[计算机组成原理]学习笔记--总目录 [31]GPU(下):为什么深度学习需要使用GPU? 引言 一.Shader 的诞生和可编程图形处理器[GPU发展历史] 1.可编程管线(Programable ...
- 31 | GPU(下):为什么深度学习需要使用 GPU?
31 | GPU(下):为什么深度学习需要使用 GPU? 上一讲,我带你一起看了三维图形在计算机里的渲染过程.这个渲染过程,分成了顶点处理.图元处理. 栅格化.片段处理,以及最后的像素操作.这一连串的 ...
- 小啊呜产品读书笔记001:《邱岳的产品手记-16》第30讲产品案例分析:Primer的扑克牌交互 第31讲 产品分析的套路(下):如何出解决方案?
小啊呜产品读书笔记001:<邱岳的产品手记-16>第30讲产品案例分析:Primer的扑克牌交互 & 第31讲 产品分析的套路(下):如何出解决方案? 一.今日阅读计划 二.泛读& ...
- 好好说话之Tcache Attack(1):tcache基础与tcache poisoning
进入到了Tcache的部分,我还是觉得有必要多写一写基础的东西.以往的各种攻击手法都是假定没有tcache的,从练习二进制漏洞挖掘的角度来看其实我们一直模拟的都是很老的环境,那么这样一来其实和真正的生 ...
- 好好说话之Tcache Attack(3):tcache stashing unlink attack
tcache stashing unlink attack这种攻击利用有一个稍微绕的点,就是small bin中的空闲块挂进tcache bin这块.弯不大,仔细想想就好了 往期回顾: 好好说话之Tc ...
- 【Stage3D学习笔记续】山寨Starling(八):核心优化(批处理)的实现
批处理是使GPU进行高效绘制的一种技术手段,也是整个渲染流程中最核心的技术,到目前为止我们并没有使用到这种技术手段,下面我们看看我们现在的渲染机制. 先想一想我们最开始是怎么向GPU绘制一幅图像的,可 ...
- C# 视频监控系列(2):客户端——封装API
前言 本章主要是在C#封装的海康DVR客户端SDK 的代码上修改的,并参考<Hikvision 板卡网络开发包编程手册V4.7.pdf>补上更完整的注释,并且参照VC++源码做了小部分修改 ...
- Kubernetes部署(三):CA证书制作
相关内容: Kubernetes部署(一):架构及功能说明 Kubernetes部署(二):系统环境初始化 Kubernetes部署(三):CA证书制作 Kubernetes部署(四):ETCD集群部 ...
最新文章
- smarty---设置
- mac终端Iterm2支持rz和sz的解决方案
- 中国牡蛎碳酸钙市场需求现状调研及十四五投资风险评估报告2022-2028年版
- 无监督分类:聚类分析(K均值)
- 软工专硕考研_分析|华北电力(北京)大学20计算机考研报录分析!电子信息复试狂刷114人,软工专硕复试录取高达1:4.7!...
- matplotlib figure转为numpy array或者PIL图像进行显示
- 936焊台(恒温电烙铁)温度不可调的维修 (Z)
- .net的retrofit--WebApiClient库深入篇
- mysql 优化之 is null ,is not null 索引使用测试
- 数据库每日一题(易错)
- smale学习之数学表达式(day1)
- C++ 中 Windows 编程概述
- python 写字机器人_机器人股票:用 Python 自动化办公能做到哪些有趣或有用的事情?作者:陈廷聿...
- win10多合一原版系统_win10多合一原版系统
- php composer 无法下载,composer给laravel下载扩展包 无法下载的问题
- 如何制作一份高大上的学术PPT?
- 疫情期间,在家办公,这几款高效远程办公协作工具解决燃眉之急
- 手把手教你如何在AWS EC2 启用 IPv6
- 最近五年中秋节后第一天涨幅前十个股在此 沪深三七开 更多规律你来找
- 基于Rocky Linux搭建Windows域控制器