chunk_overlapping
chunk_overlapping是堆中常见的漏洞
低版本下其打法主要有两种 2.27之后会新增pre_size和size一致性的校验
针对size位置的打法(此种打法是向后合并
直接修改一个正在使用的堆块的size位
然后free掉
实现overlap
1 2 3 4 5 6 7 8 9 10 11 12
| 1 2 #include<stdio.h> 3 int main(void) 4 { 5 void *hollk, *hollkr1; 6 hollk = malloc(0x10); 7 malloc(0x10); 8 *(long long *)((long long)hollk - 0x8) = 0x41; 9 free(hollk); 10 hollk1 = malloc(0x30); 11 return 0; 12 }
|
1 2 3 4 5 6 7 8 9 10 11 12
| 1 2 #include<stdio.h> 3 int main() 4 { 5 void *hollk, *hollk1; 6 hollk = malloc(0x80); 7 malloc(0x10); 8 malloc(0x10); 9 *(long *)((long)hollk-0x8) = 0xb1; 10 free(hollk); 11 hollk1 = malloc(0xa0); 12}
|
或者对一个已经free掉的堆块修改size位,也能实现overlap
先free
修改size位
申请出来即可
1 2 3 4 5 6 7 8 9 10 11
| 1 2 #include<stdio.h> 3 int main() 4 { 5 void *hollk, *hollk1; 6 hollk = malloc(0x80); 7 malloc(0x10); 8 free(hollk); 9 *(long *)((long)hollk - 0x8) = 0xb1; 10 hollk1 = malloc(0xa0); 11}
|
同时对pre_size和pre_inuse的利用(此种打法是向前合并
利用的是smallbin的unlink机制
记得得free两个堆块
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #include<stdio.h> int main(void) { void *hollk1, *hollk2, *hollk3, *hollk4; hollk1 = malloc(128); hollk2 = malloc(0x10); hollk3 = malloc(0x10); hollk4 = malloc(128); malloc(0x10); free(hollk1); *(int *)((long long)hollk4 - 0x8) = 0x90; *(int *)((long long)hollk4 - 0x10) = 0xd0; free(hollk4); malloc(0x150); }
|
参考文章:
好好说话之Chunk Extend/Overlapping_好好说话 堆_hollk的博客-CSDN博客