Darling Hold My Hand

· · 科技·工程

Nothing beats a Jet 2 holiday! And right now, you can save fifty pounds per person! That's two hundred pounds off for a family of four! 把简介区空间占满把简介区空间占满把简介区空间占满把简介区空间占满把简介区空间占满

SigningIn

预期的解题路径是发现送外卖的界面会有一次时间校准,断网后仍旧能产出外卖字符串。这说明断网之后用的是本地时间,可以断网调时间调到未来,提前生成未来的外卖字符串,然后卡个点交就行。

用 selenium 之类的自动化也许也能做到。

我的合成

熟练可以直接进 40s。

没有账号注册机制的服务器不太可能做到追踪谁在用哪个种子,也就是说,服务器只是负责下发种子,具体用哪个种子完成游戏服务器是不管的。

故可以用重放攻击,先正常打一把,把当时下发的那个种子网络包记录下来;后面再打一把,用记录的这个包去覆盖真实服务器响应包,就能原题复现了。

另外这两道题如果有精力去逆向 JS 直接拿到 token 生成算法的话也可以过。

misc FFTer boy

算作经典 trick 叠加题。binwalk 一下能发现下发的文件后面跟了张图片。把图片提取出来发现是张一乘一的超小图,但是文件大小对不上。

对不上之后可以爆破一下长宽,发现有两百万个像素,能拼成一张两千乘以一千的图片。这个图很经典,是 Mel 频谱图:

把频谱图用转回声音就能听到 flag 了。

Online

平时打 OI 可能没怎么注意到的点:mt19937 原理很简单也很弱。只要有六百二十四个连续的数字(必须是原始满 32 位输出,不能取模,不然要 z3)就能够预测它接下来的生成序列。

解法就是直接在输入权值的时候预测接下来的生成序列,然后在线变离线做,非常简单。

这个题自己测试的时候喂给 AI,AI 立刻就发现做法了。算比较典的科普题吧。

Locks

纯粹乱搞题,输入没做任何限制,20 把锁可以写个程序枚举看哪个字符串能通过。这个题虽然一次交不太可能交过,多次探测即可。

找 AI 做也是很快就做出来了。

旷野小计算懒人版

AI 能做,代码附后(代码由 AI 生成)。

HashKiller (-1)

观察哈希算法可以发现有假的循环移位,而且有两个块用了一次就没参与过后续哈希算法。直接针对这里攻击构造即可。攻击构造算法:

cout?!

resolve_index 这个函数里存在经典的负数漏洞:如果传入的是 0x80000000 也就是 INT_MIN,它取相反数之后仍然是负数。这样就能造成越界访问。越界可以修改指令计数器,让它偏移一个单位;再构造 gadget 一路 NOP 过去就行。

赛时出现的非预期解是由于没对 JMP 做边界检查,直接 JMP 到指令内部的 ROP 解法。这个也算有道理,所以就保留成绩并把原题权重提高了。

PreImage

编译器里面有几个漏洞:编译 LOAD 指令的时候用的是带符号的 int,可以溢出变成负数;但是 STORE 指令用的是不带符号的,又转回去变正数了,这里其实读写不对称。

预期解法是发现 for 语句没弹出结果,相当于会在栈上留一些垃圾数据。而且有 LOAD 就可以读出 canary 和 pckey(需要自己计算指令地址然后异或算出来)。两个结合一下,伪造一个假的异常栈帧,然后让这个栈帧的处理器地址指向那个评测结果函数调用处(没做 ASLR,指令在哪里都是固定的,也是要自己计算),最后抛个异常,让虚拟机跟着伪造的栈帧跑到那里自己调用评测结果函数处完成攻击。

但是看赛时的做法好像没人按照这个写。后来发现是声明变量和参数的地方忘了做检查导致能触发任意地址写。原本打算就这么算了的,后来还是多加了一题加强版。

另外,这几个题都是 AI 写的虚拟机和编译器代码,然后由人工注入缺陷的。

奇变偶不变

经典的声学侧信道攻击,注意到每个字母按下去的键盘音是不一样的,而且每一句话后面多一个键盘音。最后也多了很多的键盘音(这里其实是为了引起选手注意才加了那一句话),提取出来多的键盘音,按照对应关系翻译出 flag 交上去就行了。

另外 flag 是有意义的单词,所以提取出几个字母大概就能猜到剩下的部分。这也算是降难度。

PY991

耍帅用的 PyJail。Python 3 开始,可以用全角字母代替半角字母,能正常编译的。其他字符,比如下划线,虽然不能用全角代替,但是可以用 chr 拼出来。

另外没了 eval 还可以用 exec 啊。阉割了很多函数。

赛时能看到一堆人知道用全角但是都不知道 exec。大概是 AI 的功劳。

OPENSSL \$5\$

时间侧信道攻击,openssl 的这个哈希算法其实是比较少见的、输入长度会影响运行时间的哈希算法。它是每奇数轮就要复制一次原始字符串。

首先得知道盐。样例这次有用了,可以写一个脚本爆破出用的盐(因为样例里的是真的明文)。然后再写一个脚本爆破出所有明文,一共三十二个。

然后:

#include <iostream>
#include <string>
using namespace std;
const string words[32] = {
    // 那三十二个明文
};
int main() {
    int x; cin >> x; cout << words[x - 1] << endl; // 20 个测试点一次只能测 20 个,不过调整下标就行了
    for (int i = 0; i < 4096000; i++) putchar('a');
    putchar(10);
}

看评测记录,UKE 就是因为运行太久超时被洛谷评测系统杀进程了。

这里是旷野小计算后三个比较难的点的代码。用 AI 生成的。

#include <iostream>
#include <string>

using namespace std;

void gen_op(string op, string a, string b) { cout << op << " " << a << " " << b << "\n"; }
void xor_r(string a, string b) { gen_op("^", a, b); }
void mul_r(string a, string b) { gen_op("*", a, b); }
void shl_r(string a, int c)    { if(c > 0) gen_op("<", a, to_string(c)); }
void shr_r(string a, int c)    { if(c > 0) gen_op(">", a, to_string(c)); }
void submit(string a)          { cout << "! " << a << "\n"; }

void mov_r(string dst, string src) {
    if (dst == src) return;
    xor_r(dst, dst); xor_r(dst, src);
}

// 提取常数 (绝对安全,不污染输入 X)
void gen_const(uint32_t val, string dest, string s1, string s2) {
    xor_r(s2, s2);
    for(int j = 0; j < 32; ++j) {
        mov_r(s1, "x"); shr_r(s1, j); shl_r(s1, 31); shr_r(s1, 31);
        mov_r(dest, s2); mul_r(dest, s1); xor_r(s2, s1); xor_r(s2, dest);
    }
    xor_r(dest, dest);
    for(int i = 0; i < 32; ++i) {
        if ((val >> i) & 1) {
            mov_r(s1, s2); shl_r(s1, i); xor_r(dest, s1);
        }
    }
}

void gen_minus_1(string dest, string s1, string s2) {
    gen_const(1, dest, s1, s2);
    mov_r(s1, dest); shl_r(s1, 1); xor_r(dest, s1);
    mov_r(s1, dest); shl_r(s1, 2); xor_r(dest, s1);
    mov_r(s1, dest); shl_r(s1, 4); xor_r(dest, s1);
    mov_r(s1, dest); shl_r(s1, 8); xor_r(dest, s1);
    mov_r(s1, dest); shl_r(s1, 16); xor_r(dest, s1);
}

// 5 寄存器减法:引入了恢复标志位 (restore_op2),保证连等式运算的安全性
void macro_sub_5(string out, string op1, string op2, string carry, string scratch, bool restore_op2 = false) {
    gen_minus_1(scratch, carry, out); 
    xor_r(op2, scratch); // op2 = ~op2
    gen_const(1, carry, scratch, out); // carry = 1
    xor_r(out, out);
    for(int j = 0; j < 32; ++j) {
        mov_r(scratch, op1); xor_r(scratch, op2); shl_r(scratch, 31); shr_r(scratch, 31);
        xor_r(scratch, carry); 
        shr_r(out, 1); shl_r(scratch, 31); xor_r(out, scratch); 

        mov_r(scratch, op1); xor_r(scratch, op2); shl_r(scratch, 31); shr_r(scratch, 31);
        mul_r(scratch, carry); 

        mov_r(carry, op1); mul_r(carry, op2); shl_r(carry, 31); shr_r(carry, 31);
        xor_r(carry, scratch); 

        mov_r(scratch, op1); shl_r(scratch, 31); shr_r(op1, 1); xor_r(op1, scratch);
        mov_r(scratch, op2); shl_r(scratch, 31); shr_r(op2, 1); xor_r(op2, scratch);
    }
    if (restore_op2) {
        // 利用不会再被使用的 op1 充当草稿纸生成 -1 翻转恢复 op2
        gen_minus_1(scratch, carry, op1);
        xor_r(op2, scratch);
    }
}

// 极高精度乘法:仅偏移 1 位(完全避免溢出并保留高达 99.99% 的精度)
void approx_mul_var(string out, string op1, string op2, string scratch) {
    mov_r(out, op1); shr_r(out, 1);
    mov_r(scratch, op2); shr_r(scratch, 1);
    mul_r(out, scratch);
    shr_r(out, 14); // 1 + 1 + 14 = 16 (拨正回 Q16.16)
}

// FPU 级终极展开
void compile_task_sin() {
    cout << "; ====== FPU Ultimate Precision: 65536 * sin(X) ======\n";

    // 1. 保护与提取: 分离符号位与绝对值 |x|
    mov_r("a", "x"); shr_r("a", 31); 
    mov_r("b", "x"); shl_r("b", 1); shr_r("b", 1);
    mov_r("x", "b"); shl_r("a", 31); xor_r("x", "a"); // X = |x| 寄生 sign

    // 2. T1 = 1 - x^2/20
    mov_r("b", "x"); shl_r("b", 1); shr_r("b", 1); 
    approx_mul_var("c", "b", "b", "d"); // C = x^2
    gen_const(3277, "d", "a", "y"); // D = 1/20
    mul_r("c", "d"); shr_r("c", 16); // 全精度直接乘! C = x^2 / 20
    gen_const(65536, "d", "a", "y"); // D = 1.0
    macro_sub_5("a", "d", "c", "b", "y", false); // A = T1

    // 3. T2 = x^2 * T1
    mov_r("b", "x"); shl_r("b", 1); shr_r("b", 1);
    approx_mul_var("c", "b", "b", "d"); // 重新算出精确的 x^2
    approx_mul_var("a", "a", "c", "d"); // A = x^2 * T1 = T2

    // 4. T3 = 1 - T2/6
    gen_const(10923, "d", "b", "c"); // D = 1/6
    mul_r("a", "d"); shr_r("a", 16); // 全精度乘法! A = T2 / 6
    mov_r("c", "a"); // C = T2 / 6
    gen_const(65536, "d", "a", "b"); // D = 1.0
    macro_sub_5("a", "d", "c", "b", "y", false); // A = 1 - T2/6 = T3

    // 5. sin(|x|) = |x| * T3
    mov_r("b", "x"); shl_r("b", 1); shr_r("b", 1);
    approx_mul_var("c", "a", "b", "d"); // C = sin(|x|) 算完了!

    // 6. 神级符号恢复 (数学掩码选择网络)
    xor_r("d", "d"); 
    macro_sub_5("y", "d", "c", "a", "b", true); // Y = -sin(|x|). 关键:必须开启 true 以便保住 C 原值!

    gen_const(1, "d", "a", "b"); // D = 1
    mov_r("a", "x"); shr_r("a", 31); // A = sign (1 or 0)
    mov_r("b", "a"); xor_r("b", "d"); // B = !sign (0 or 1)

    mul_r("y", "a"); // 选出负半轴结果
    mul_r("c", "b"); // 选出正半轴结果

    xor_r("a", "a"); xor_r("a", "y"); xor_r("a", "c"); // A = 最终输出!
    submit("a");
}

int main() {
    compile_task_sin();
    return 0;
}
#include <iostream>
#include <string>

using namespace std;

void op(string o, string a, string b) { cout << o << " " << a << " " << b << "\n"; }
void xor_r(string a, string b) { op("^", a, b); }
void mul_r(string a, string b) { op("*", a, b); }
void shl_r(string a, int c)    { if(c > 0) op("<", a, to_string(c)); }
void shr_r(string a, int c)    { if(c > 0) op(">", a, to_string(c)); }
void mov_r(string d, string s) { if (d != s) { xor_r(d, d); xor_r(d, s); } }
void submit(string a)          { cout << "! " << a << "\n"; }

// 展开为 -1 (0xFFFFFFFF)
void expand_minus_1(string target, string scratch) {
    mov_r(scratch, target); shl_r(scratch, 1); xor_r(target, scratch);
    mov_r(scratch, target); shl_r(scratch, 2); xor_r(target, scratch);
    mov_r(scratch, target); shl_r(scratch, 4); xor_r(target, scratch);
    mov_r(scratch, target); shl_r(scratch, 8); xor_r(target, scratch);
    mov_r(scratch, target); shl_r(scratch, 16); xor_r(target, scratch);
}

// 绝对安全的“三体扫描”常数生成器(扫描 Y, X, B)
void gen_1_YXB(string dest, string scratch) {
    xor_r(dest, dest);
    for(int j = 0; j < 32; ++j) {
        mov_r(scratch, "y"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31);
        mul_r(scratch, dest); xor_r(dest, scratch);
        mov_r(scratch, "y"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31); xor_r(dest, scratch);

        mov_r(scratch, "x"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31);
        mul_r(scratch, dest); xor_r(dest, scratch);
        mov_r(scratch, "x"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31); xor_r(dest, scratch);

        mov_r(scratch, "b"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31);
        mul_r(scratch, dest); xor_r(dest, scratch);
        mov_r(scratch, "b"); shr_r(scratch, j); shl_r(scratch, 31); shr_r(scratch, 31); xor_r(dest, scratch);
    }
}

// 终极无懈可击的除法编译器
void compile_task_div() {
    cout << "; ====== FLAWLESS Division: A / B (Ultimate Carry-Out + Anti-Collapse) ======\n";
    xor_r("a", "a");
    for(int i = 0; i < 32; ++i) {
        // 1. 左移 A 和 X
        mov_r("d", "x"); shr_r("d", 31); shl_r("x", 1); shl_r("a", 1); xor_r("a", "d");

        // 2. 仅扫描原始 Y 造 -1 取反 (此时 Y 绝对非零)
        xor_r("b", "b");
        for(int j=0; j<32; ++j) {
            mov_r("c", "y"); shr_r("c", j); shl_r("c", 31); shr_r("c", 31);
            mul_r("c", "b"); xor_r("b", "c");
            mov_r("c", "y"); shr_r("c", j); shl_r("c", 31); shr_r("c", 31); xor_r("b", "c");
        }
        expand_minus_1("b", "c");
        xor_r("y", "b"); // Y 变成了 ~Y

        // 3. 初始 Carry 设为 1 (极其巧妙,直接复用刚才的 -1)
        mov_r("c", "b"); shl_r("c", 31); shr_r("c", 31); 
        xor_r("b", "b"); // B 作为 Sum 初始化为 0

        // 4. 位串行加法器 (A + ~Y + 1)
        for(int j = 0; j < 32; ++j) {
            mov_r("d", "a"); xor_r("d", "y"); shl_r("d", 31); shr_r("d", 31); xor_r("d", "c");
            shr_r("b", 1); shl_r("d", 31); xor_r("b", "d"); // Sum 入 B

            mov_r("d", "a"); xor_r("d", "y"); shl_r("d", 31); shr_r("d", 31); mul_r("d", "c");
            mov_r("c", "a"); mul_r("c", "y"); shl_r("c", 31); shr_r("c", 31); xor_r("c", "d"); // Carry 更新

            mov_r("d", "a"); shl_r("d", 31); shr_r("a", 1); xor_r("a", "d");
            mov_r("d", "y"); shl_r("d", 31); shr_r("y", 1); xor_r("y", "d");
        }

        // 5. 核心:C 此时就是精确无误的 Carry Out (商位)!直接写入 X
        xor_r("x", "c");

        // 6. 恢复 Y (调用三体扫描,彻底杜绝全零热寂)
        gen_1_YXB("c", "d"); 
        expand_minus_1("c", "d");
        xor_r("y", "c");

        // 7. 有条件恢复 A (无需分支,纯数学选择)
        mov_r("c", "x"); shl_r("c", 31); shr_r("c", 31); // 提取商位 0 或 1
        mov_r("d", "a"); xor_r("d", "b"); // D = A ^ B
        mul_r("d", "c"); // 若商位是1, D = A^B; 若商位是0, D = 0
        xor_r("a", "d"); // 若商位是1, A = B; 若商位是0, A 不变
    }
    submit("x");
}

void compile_task_sqrt() {
    cout << "; ====== FLAWLESS Square Root: Sqrt(A) ======\n";
    xor_r("a", "a");
    for(int i = 15; i >= 0; --i) {
        // sqrt 对 X 是只读的,X 作为被开方数必定非零,扫描 X 和 Y 绝对安全
        xor_r("b", "b");
        for(int j = 0; j < 32; ++j) {
            mov_r("c", "x"); shr_r("c", j); shl_r("c", 31); shr_r("c", 31);
            mul_r("c", "b"); xor_r("b", "c");
            mov_r("c", "x"); shr_r("c", j); shl_r("c", 31); shr_r("c", 31); xor_r("b", "c");
        }
        mov_r("y", "b"); shl_r("y", i); // 游标 T

        mov_r("d", "a"); xor_r("d", "y"); 
        mov_r("b", "d"); mul_r("b", "d"); // B = T^2

        expand_minus_1("b", "c"); // 将 B 取反 (~T^2)

        xor_r("c", "c");
        for(int j = 0; j < 32; ++j) {
            mov_r("d", "x"); shr_r("d", j); shl_r("d", 31); shr_r("d", 31);
            mul_r("d", "c"); xor_r("c", "d");
            mov_r("d", "x"); shr_r("d", j); shl_r("d", 31); shr_r("d", 31); xor_r("c", "d");
        }
        // C = Initial Carry = 1

        for(int j = 0; j < 32; ++j) {
            mov_r("d", "x"); xor_r("d", "b"); shl_r("d", 31); shr_r("d", 31); mul_r("d", "c");
            mov_r("c", "x"); mul_r("c", "b"); shl_r("c", 31); shr_r("c", 31); xor_r("c", "d"); // Next Carry

            mov_r("d", "x"); shl_r("d", 31); shr_r("x", 1); xor_r("x", "d");
            mov_r("d", "b"); shl_r("d", 31); shr_r("b", 1); xor_r("b", "d");
        }

        // C 此时就是最终判断位 (1 表示够减)
        xor_r("b", "b");
        for(int j = 0; j < 32; ++j) {
            mov_r("d", "x"); shr_r("d", j); shl_r("d", 31); shr_r("d", 31);
            mul_r("d", "b"); xor_r("b", "d");
            mov_r("d", "x"); shr_r("d", j); shl_r("d", 31); shr_r("d", 31); xor_r("b", "d");
        }
        mov_r("y", "b"); shl_r("y", i); 

        mov_r("d", "y"); mul_r("d", "c");
        xor_r("a", "d");
    }
    submit("a");
}

int main() {
    compile_task_div();
    compile_task_sqrt();
    return 0;
}

有点好奇为什么难一点的题全被过光了留几个经典 Misc 没人过