[2024/08/01] BUUOJ刷题 Re
[ACTF新生赛2020] Oruga
抄出来爆破
#include <iostream>
unsigned char byte_201020[256] = {
0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x23, 0x23, 0x23,
0x00, 0x00, 0x00, 0x23, 0x23, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x4C, 0x00, 0x4F, 0x4F, 0x00, 0x4F, 0x4F, 0x00, 0x50, 0x50, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x4C, 0x00, 0x4F, 0x4F, 0x00, 0x4F, 0x4F, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x4C, 0x4C, 0x00, 0x4F, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x4F, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00,
0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4D, 0x4D, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x45, 0x45,
0x00, 0x00, 0x00, 0x30, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x45, 0x45,
0x54, 0x54, 0x54, 0x49, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
0x00, 0x54, 0x00, 0x49, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x00, 0x00, 0x00, 0x45, 0x00,
0x00, 0x54, 0x00, 0x49, 0x00, 0x4D, 0x00, 0x4D, 0x00, 0x4D, 0x21, 0x00, 0x00, 0x00, 0x45, 0x45
};
int __fastcall sub_78A(const char* src)
{
int v2; // [rsp+Ch] [rbp-Ch]
int v3; // [rsp+10h] [rbp-8h]
int v4; // [rsp+14h] [rbp-4h]
v2 = 0;
v3 = 5;
v4 = 0;
while (byte_201020[v2] != 0x21)
{
v2 -= v4;
if (src[v3] != 'W' || v4 == -16)
{
if (src[v3] != 'E' || v4 == 1)
{
if (src[v3] != 'M' || v4 == 0x10)
{
if (src[v3] != 'J' || v4 == -1)
return v3 + 1;
v4 = -1;
}
else
{
v4 = 16;
}
}
else
{
v4 = 1;
}
}
else
{
v4 = -16;
}
++v3;
while (!byte_201020[v2])
{
if (v4 == -1 && (v2 & 0xF) == 0)
return v3;
if (v4 == 1 && v2 % 16 == 15)
return v3;
if (v4 == 16 && (unsigned int)(v2 - 240) <= 0xF)
return v3;
if (v4 == -16 && (unsigned int)(v2 + 15) <= 0x1E)
return v3;
v2 += v4;
}
}
return v3 + 1;
}
int main()
{
int i;
char* src = (char*)malloc(40);
if (!src) return -1;
memcpy_s(src, 40, "actf{", 5);
int last = 5;
for (i = 0; i < 40; i++)
{
src[6 + i] = 0;
src[5 + i] = 'W';
if (sub_78A(src) == i + 6)
{
src[5 + i] = 'J';
if (sub_78A(src) == i + 6)
{
src[5 + i] = 'M';
if (sub_78A(src) == i + 6)
{
src[5 + i] = 'E';
if (sub_78A(src) == i + 6)
{
src[5 + i] = '}';
if (sub_78A(src) == i + 6)
{
break;
}
}
}
}
}
}
printf("%s", src);
free(src);
}
actf{MEWEMEWJMEWJM}
[WUSTCTF2020] level4
题目给了中序和后序排列
Practice my Data Structure code.....
Typing....Struct.....char....*left....*right............emmmmm...OK!
Traversal!
Traversal type 1:2f0t02T{hcsiI_SwA__r7Ee}
Traversal type 2:20f0Th{2tsIS_icArE}e7__w
Traversal type 3: //type3(&x[22]); No way!
显然缺了个前序排列,应该就是结果
我们用Python解
def ToPreOrder(Postorder,Inorder):
length = len(Postorder)
if length == 0:
return 0
root = Postorder[length-1]
for i in range(length):
if root == Inorder[i]:
break
print(root,end="")
ToPreOrder(Postorder[0:i],Inorder[0:i])
ToPreOrder(Postorder[i:length-1],Inorder[i+1:length])
ToPreOrder("20f0Th{2tsIS_icArE}e7__w","2f0t02T{hcsiI_SwA__r7Ee}")
# wctf2020{This_IS_A_7reE}
[GUET-CTF2019] number_game
树中序和后序排列,动调一下可以拿到替换表。
然后再分析一下,可以得知,相邻行/列不能相同,且输入只能是0 1 2 3 4
这五个字符。
写出z3-solver脚本即可。
from z3 import *
x = [BitVec(f"x{i}", 8) for i in range(25)]
s = Solver()
raw = """
1 4 # 2 3
3 0 # 1 #
0 # 2 3 #
# 3 # # 0
4 2 # # 1
"""
raw = "".join(raw.replace(' ', '').splitlines())
for i, v in enumerate(raw):
if v != '#':
s.add(x[i] == ord(v))
else:
s.add(x[i] >= ord('0'), x[i] <= ord('4'))
for i in range(5):
for j in range(5):
for k in range(j + 1, 5):
s.add(x[5 * i + j] != x[5 * i + k])
s.add(x[5 * j + i] != x[5 * k + i])
print(s)
print(s.check())
m = s.model()
ans = ""
for i in x:
ans += chr(m[i].as_long())
for i in range(5):
for j in range(5):
print(ans[5*i+j], end=' ')
print("")
# Tree transform
d_before = "0123456789"
d_after = "7381940526"
d_table = [d_before.index(d_after[i]) for i in range(len(d_before))]
print("table", d_table)
answers = [2, 7, 9, 11, 14, 15, 17, 18, 22, 23]
flag_ans = [i for i in range(10)]
for i in range(len(answers)):
flag_ans[d_table[i]] = ans[answers[i]]
flag = "".join(flag_ans)
print(flag)
sat
1 4 0 2 3
3 0 4 1 2
0 1 2 3 4
2 3 1 4 0
4 2 3 0 1
table [7, 3, 8, 1, 9, 4, 0, 5, 2, 6]
1134240024
flag{1134240024}
评论已关闭