GDOUCTF2023-Reverse WP

[GDOUCTF 2023]Check_Your_Luck

image-20231128094404871

根据 if 使用z3约束求解器。

EXP:

from z3 import *
# 创建整数变量
v, w, x, y, z = Ints('v w x y z')
# 创建Z3求解器
solver = Solver()
solver.add(v * 23 + w * -32 + x * 98 + y * 55 + z * 90 == 333322)
solver.add(v * 123 + w * -322 + x * 68 + y * 67 + z * 32 == 707724)
solver.add(v * 266 + w * -34 + x * 43 + y * 8 + z * 32 == 1272529)
solver.add(v * 343 + w * -352 + x * 58 + y * 65 + z * 5 == 1672457)
solver.add(v * 231 + w * -321 + x * 938 + y * 555 + z * 970 == 3372367)

# 检查是否存在解
if solver.check() == sat:
    model = solver.model()
    output_str = f"flag{{{model[v]}_{model[w]}_{model[x]}_{model[y]}_{model[z]}}}"
    print(output_str)
else:
    print("方程组无解")
# flag{4544_123_677_1754_777}

[GDOUCTF 2023]Tea

image-20231128094815207

64bit的文件。IDA64打开

image-20231128095030838

根据字符串定位

image-20231128095118816

image-20231128103247829

这里的v7是错误的,后面进行了修改。

之后对v8和v7进行操作。

image-20231128103321373

一个XTEA的加密,找到密文,提取出来

image-20231128103406832

加密的逻辑大概就是,明文的第一位和第二位进行XTEA加密,之后加密后的第二位继续和第三位XTEA,依次下去,逆向一下就好。

写个EXP解密:

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
 
void decrypt (uint32_t* v,uint32_t* k,int wheel) {
    uint32_t v0=v[0], v1=v[1], i;
    uint32_t delta=0xF462900;
    uint32_t sum = delta*(33+wheel);
    for (i=0; i<33; i++) {
        sum -= delta;
        v1 -= (((v0 * 16) ^ (v0 >> 5)) + v0) ^ (sum + k[(sum >> 11 ) & 3]);
        v0 -= (((v1 * 16) ^ (v1 >> 5)) + v1) ^ (sum + k[(sum & 3)])^sum;
    }
    v[0]=v0; v[1]=v1;
}
 
int main()
{
    
    uint32_t enflag[] = {444599258, 4154859931, 1226314200, 4060164904, 359413339, 1013885656, 2228535080, 4045045479, 856928850, 3718242937};
    uint32_t key[4] = {2233,4455,6677,8899};
    for(int i=8;i>=0;i-=1)
    {
        uint32_t temp[2];        
        temp[0] = enflag[i];
        temp[1] = enflag[i+1];
        int wheel = i;
        decrypt(temp,key,wheel);
        enflag[i] = temp[0];
        enflag[i+1] = temp[1];
    }
     for (int i = 0; i < 10; i++)
    {
        for (int j = 3; j>=0; j--)
        {
            printf("%c", (enflag[i] >> (j * 8)) & 0xFF);
        }
    }
    
    return 0;
}
//HZCTF{hzCtf_94_re666fingcry5641q  q}
//HZCTF{hzCtf_94_re666fingcry5641qq}

[GDOUCTF 2023]easy_pyc

pyc文件,用uncompyle6反编译

image-20231128103658740

image-20231128103839706

一个简单的rsa加密。

EXP:

d = inverse(e,(p-1)*(q-1))
n = p*q
m = pow(c,d,n)
print(long_to_bytes(m))
# flag{IfYouWantItThenYouHaveToTakeIt}

[GDOUCTF 2023]doublegame

image-20231128104028527

通过查找字符串定位到关键函数。

image-20231128104120885

函数点进去看一看,最后发现都没有什么用。回去查看一下字符串,发现一个GAME OVER。

image-20231128104800098

找到了。第一个game。如果分数大于13371337就进行第二个游戏,即score。

if下面的函数。

image-20231128104905640

一个迷宫题,用dfs解:

maze = ['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', '0', '0', ' ', '0', ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0', ' ', '0', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', '0', '0', ' ', '0', '0', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', '0', ' ', '0', ' ', ' ', ' ', '0', ' ', '0', ' ', '0', '0', ' ', '0', ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0', '0', '0', ' ', '0', '0', '0', ' ', '0', '0', ' ', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', '0', ' ', '0', ' ', ' ', ' ', ' ', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', '0', '0', '0', '0', '0', ' ', '0', '0', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', '0', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', ' ', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', ' ', '0', '0', '0', '0', '0', '0', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0', '0', '0', '0', '0', ' ', ' ', ' ', ' ', '0', ' ', ' ', ' ', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', ' ', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', ' ', '0', ' ', '0', ' ', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', '0', '0', '0', ' ', '0', ' ', '0', '0', '0', '0', '0', ' ', '0', ' ', '0', '0', '0', ' ', '0', '0', '0', '0', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '0', ' ', '0', ' ', ' ', ' ', '0', ' ', ' ', ' ', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0']


maze[21*7+20] = '2'
# maze[x * 21 + y]
def check_point_valid(map, x, y):
    if (x >= 0) and (x <= 20) and (y >= 0) and (y <= 20):
        return (map[x * 21 + y] != '0') and ((map[x * 21 + y] == ' ') or (map[x * 21 + y] == '2'))
    else:
        return False


def gen_nex(map, x, y):
    all_dir = []
    # if check_point_valid(map, x - 1, y, z):
    # all_dir.append((x - 1, y, z, 'q'))
    # if check_point_valid(map, x + 1, y, z):
    # all_dir.append((x + 1, y, z, 'u'))
    if check_point_valid(map, x + 1, y):
        all_dir.append((x + 1, y, 's'))
    if check_point_valid(map, x - 1, y):
        all_dir.append((x - 1, y, 'w'))
    if check_point_valid(map, x, y - 1):
        all_dir.append((x, y - 1, 'a'))
    if check_point_valid(map, x, y + 1):
        all_dir.append((x, y + 1, 'd'))
    return all_dir


def check_success(map, x, y):
    if map[x * 21 + y] == '2':
        return True
    else:
        return False


def dfs(mapb, x, y, path):
    map = mapb.copy()
    if map[x * 21 + y] != '2':
        map[x * 21 + y] = '0'
    if check_success(map, x, y):
        print(path)
        return True

    next_point = gen_nex(map, x, y)
    for n in next_point:
        pathn = path + n[2]
        dfs(map, n[0], n[1], pathn)


outpus = ""
dfs(maze, 15, 0, outpus)

可以解出俩条路径,用最短的,dddssssddwwwwddssddwwwwwwddddssaassddddwwwwddwwwwddd

再加上一个MD5加密,

image-20231128113204670

最后加上分数得到flag。

HZCTF{811173b05afff098b4e0757962127eac13371337}


[GDOUCTF 2023]L!s!

image-20231128113400183

俩个文件。

用Bindiff 检查文件差异性

image-20231128113520312

IDA分析后会留下一个i64或idb文件。

image-20231128113603145

Ctrl+6 快捷键打开,(有些可能没插件)

image-20231128113640972

image-20231128113705095

绿色的是匹配度最高的。这里可以发现只有一个有差异。应该就是经过修改的地方。

image-20231128113752938

发现是 extract_dirs_from_files这个函数。

用IDA打开另一个文件,找到这个函数,比对俩个函数,

image-20231128113944452

发现这里多出了一部分内容。

可以看到就只是做了一个异或而已。

EXP:

enc = [ 0x04, 0x16, 0x0F, 0x18, 0x0A, 0x37, 0x2E, 0x7D,
        0x22, 0x28, 0x25, 0x2A, 0x2A, 0x13, 0x7D, 0x3F,
        0x13, 0x2D, 0x13, 0x39, 0x3F, 0x7F, 0x2A, 0x39,
        0x20, 0x13, 0x38, 0x7C, 0x7C, 0x20, 0x31, 0x00]
for j in range(100):
    flag = []
    for i in range(len(enc)):
        flag.append(chr(enc[i]^j))
    print(''.join(flag))
# HZCTF{b1ndiff_1s_a_us3ful_t00l}L

[GDOUCTF 2023]润!

image-20231128114747225

UPX壳,看到EP Section UPX标志被修改了。

image-20231128114835213

用WInhex修改回来。

image-20231128114909407

image-20231128114939139

image-20231128115004700

一个迷宫题,不过是三维迷宫。

image-20231128115225050

一开始init处创建了一次迷宫(一层)后面moving里面每u一次都会layer++。这里layer就是楼的意思。

用动态调试,输入uuuuuuuuuuuuuuuuuuu连续创建迷宫,把迷宫copy出来;

EXP:

maze = [0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1,
        1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 1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, 1, 1, 1, 1, 1,
        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2]


# maze[x * 64 + y * 8 + z]
def check_point_valid(map, x, y, z):
    if (x >= 0) and (x <= 7) and (y >= 0) and (y <= 7) and (z >= 0) and (z <= 7):
        return (map[x * 64 + y * 8 + z] != 1) and ((map[x * 64 + y * 8 + z] == 0) or (map[x * 64 + y * 8 + z] == 2))
    else:
        return False


def gen_nex(map, x, y, z):
    all_dir = []
    if check_point_valid(map, x - 1, y, z):
        all_dir.append((x - 1, y, z, 'n'))
    if check_point_valid(map, x + 1, y, z):
        all_dir.append((x + 1, y, z, 'u'))
    if check_point_valid(map, x, y - 1, z):
        all_dir.append((x, y - 1, z, 'w'))
    if check_point_valid(map, x, y + 1, z):
        all_dir.append((x, y + 1, z, 's'))
    if check_point_valid(map, x, y, z - 1):
        all_dir.append((x, y, z - 1, 'a'))
    if check_point_valid(map, x, y, z + 1):
        all_dir.append((x, y, z + 1, 'd'))
    return all_dir


def check_success(map, x, y, z):
    if map[x * 64 + y * 8 + z] == 2:
        return True
    else:
        return False


def dfs(mapb, x, y, z, path):
    map = mapb.copy()
    if map[x * 64 + y * 8 + z] != 2:
        map[x * 64 + y * 8 + z] = 1
    if check_success(map, x, y, z):
        print(path)
        return True

    next_point = gen_nex(map, x, y, z)
    for n in next_point:
        pathn = path + n[3]
        dfs(map, n[0], n[1], n[2], pathn)


outpus = ""
dfs(maze, 0, 0, 0,  outpus)

解出来ssddssuuwwddndduuussdussasauudd

CTF-Reverse 迷宫地图类题目分析‘‘DFS和BFS算法‘‘

  • 26
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Sciurdae.

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值