跳至主要內容

Scratch Passcode 2

Haynes原创...大约 2 分钟CTFMiscHKCert22

佢哋啱啱升級咗安全系統 - 今次用唔到密碼鍵盤去打正確嘅密碼啦!
Scratch: https://scratch.mit.edu/projects/755732653/open in new window

0x01 分析

查看源码,找到计算密码的函数,发现是通过memoryinput计算后匹配character中的内容来计算 flag
function-clicked

同时在 userinput 中可以看到密码的位数是小于等于 4 的,根据以上信息进行爆破
function-userinput

通过 scratch 可以导出memorycharacter的内容

memory
6
126
330
225
6
77
297
230
28
49
440
80
2
329
528
245
100
133
209
15
72
28
55
195
102
7
22
5
28
364
583
20
72
98
55
20
108
280
121
25
50
112
330
20
110
392

爆破时发现,0000-9999 都无法匹配,猜测一位密码可能并不是个位数,于是扩大爆破范围得到 flag

0x02 Exploit

#include <bits/stdc++.h>

using namespace std;

int mem[50] = {/*填入数据*/};

char cc[41] = {/*填入数据*/};

int input[5] = {-1, 0, 0, 0, 0};

int main() {
    for (int a = 1; a <= 12; a++) {
        for (int b = 1; b <= 12; b++) {
            for (int c = 1; c <= 12; c++) {
                for (int d = 1; d <= 12; d++) {
                    int j = 46;
                    input[4] = d;
                    input[3] = c;
                    input[2] = b;
                    input[1] = a;
                    cout << input[1] << " " << input[2] << " " << input[3] << " " << input[4] << endl;
                    string de = "ans=";
                    for (int i = 1; i <= 46; i++) {
                        j = ((j + 2) % 4) + 1;
                        if (input[j] == 0) continue;
                        int ch = mem[i] / input[j];
                        if (ch > 40) {
                            continue;
                        }
                        de = de + cc[ch];
                    }
                    // 包含pass的字符串就是答案,输出即可
                    if (de.find("pass") != string::npos) {
                        cout << de << endl;
                        cin.get();
                    }
                }
            }
        }
    }
    return 0;
}

0x03 Flag

hkcert22{cr4ck1ng_passc0de-aband0ned_keyp4d}
上次编辑于:
贡献者: HaynesChen
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v3.1.3