Tcache Dup

黎 浩然/ 9 6 月, 2022/ PWN, 安全/SECURITY, 计算机/COMPUTER/ 0 comments

glibc-2.27

2.27对tcache几乎没有任何检查,用于检查double free的key在普遍的2.27中是不存在的。但是我不知道为什么我的18.04.5的ubuntu的2.27确实有tcache的double free检查,而且key成员也是存在的。

如果CTF题目阐明libc是2.27的话,那么下面的攻击就可以使用:

#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

int main()
{
	printf("This file demonstrates a simple double-free attack with tcache.\\n");

	printf("Allocating buffer.\\n");
	int *a = malloc(8);

	printf("malloc(8): %p\\n", a);
	printf("Freeing twice...\\n");
	free(a);
	free(a);

	printf("Now the free list has [ %p, %p ].\\n", a, a);
	void *b = malloc(8);
	void *c = malloc(8);
	printf("Next allocated buffers will be same: [ %p, %p ].\\n", b, c);

	assert((long)b == (long)c);
	return 0;
}
Share this Post

Leave a Comment

您的邮箱地址不会被公开。 必填项已用 * 标注

*
*