BruceFan's Blog

Stay hungry, stay foolish

0%

这道题是湖湘杯2019的一道QEMU pwn,题目下载(提取码: 4wag)。QEMU pwn题目一般是基于QEMU源码进行修改或者添加,在QEMU模拟的PCI设备中引入漏洞,选手需要利用漏洞读取宿主机上的flag文件。
解压文件,查看内容:

阅读全文 »

环境:
Mac: VMware Fusion
VMware: Ubuntu 18.10 x64 4G 开启Intel VT-x/EPT支持 qemu-2.3.0
qemu: Ubuntu 18.04 x64 2G

漏洞分析

阅读全文 »

这是一道Redpwn CTF 2019很简单的溢出题,主要考察ROP exp的编写。
[srnr](https://pan.baidu.com/s/174jiewXQISoHb08Aqisy7Q 提取码: yt2r)
对二进制文件进行逆向分析,可以看到程序先读入了一个数字作为文件描述符,再从文件描述符中读取100000个字符,而buf是rbp-9,只要读超过17个字符就会覆盖到ret:

阅读全文 »

Tcache介绍

tcache是libc2.26之后引入的一种新机制,与fastbin类似,是一个LIFO的单链表,每条链上最多有7个chunk,free的时候先放入tcache,tcache满了再放入fastbin,unsorted bin,libc2.29之前不会检查double free。malloc的时候先去tcache找,其相关结构体如下:

1
2
3
4
5
6
7
8
9
10
typedef struct tcache_entry
{
struct tcache_entry *next;
} tcache_entry;

typedef struct tcache_perthread_struct
{
char counts[TCACHE_MAX_BINS];
tcache_entry *entries[TCACHE_MAX_BINS];
} tcache_perthread_struct;
阅读全文 »

编译Android10.0.0_r2

1.选择aosp_x86_64-eng版本,因为编译成aosp_arm64-eng的启动不了。
2.emulator启动

1
2
3
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure KVM is properly installed and usable.
CPU acceleration status: This user doesn't have permissions to use KVM (/dev/kvm)
阅读全文 »

基于前一篇Syzkaller Fuzz Linux AMD64的文章,这里用一个自己写的驱动(有一个堆溢出)做演示。

在Syzkaller中添加规则

在syzkaller/sys/linux目录编辑proc_operation.txt。
proc_operation.txt

阅读全文 »

替换同名函数

使用gcc选项no-builtin,默认不使用系统的优化函数,而使用自定义的函数。
case for study

1
2
3
4
5
6
7
8
9
// printf.c
#include <unistd.h>
#include <string.h>

int printf(const char* format, ...) {
write(STDOUT_FILENO, "my printf\n", 10);
write(STDOUT_FILENO, format, strlen(format));
return 0;
}
阅读全文 »

说是移植AFL,其实是移植android-afl,因为AFL的插桩代码都是汇编写的,原版都是ATT汇编,要直接写ARM汇编有点难度,android-afl里有这部分内容,所以改起来容易一些。但是Android和普通Linux还是有一些区别的,我用的是树莓派3B,Raspberry系统。

阅读全文 »