TexSAW CTF 2026 Excellent Neurons

Find the flag by reverse engineering this neural network. Oh, and its in Excel.

Flag format: texsaw{flag} (e.g., texsaw{orthogonal})

前置知识

本题涉及神经网络逆向工程,且模型实现在 Excel 电子表格中。以下概念有助于理解:

概念 说明
前馈神经网络 输入层→隐藏层→输出层,数据逐层前向传递
ReLU \(f(x)=\max(0,x)\),负输入→零输出(关键逻辑门控!)
Sigmoid \(\sigma(x)=\frac{1}{1+e^{-x}}\),输出映射到 \((0,1)\),\(>0.5\) 表示正输入
权重与偏置 网络参数,本例中 W1 是极端稀疏的 +1/-1 矩阵
Excel 逆向 .xlsx 本质是 ZIP,内部 XML 含公式与数据
前向传播公式 归一化字符与权重相乘,再加偏置;公式见表后。

前向传播约束:

\[ \frac{\mathrm{ASCII}}{127} \times \mathrm{weight} + \mathrm{bias} = 0 \]

当 \(\mathrm{weight} \neq 0\) 时,还原字符值:

\[ \mathrm{ASCII} = \operatorname{round}\!\left(\frac{-\mathrm{bias} \times 127}{\mathrm{weight}}\right) \]

参考:Excel NN 教程、hxp EXCELlent

Solution

1. Understanding the Success Condition

Examining the spreadsheet, specifically Row 112, we find the conditions for a valid flag: - \(F > 0.5\), \(L < 0.5\), \(A > 0.5\), \(G < 0.5\)

Since the output layer uses a Sigmoid activation function: - To get output \(> 0.5\), the input to the sigmoid (z3) must be positive (\(> 0\)). - To get output \(< 0.5\), the input to the sigmoid (z3) must be negative (\(< 0\)).

Analyzing the final weights (W3) and biases (b3), we find that all weights in W3 are large (300 or -300) and the biases are small (between 0.49 and 0.59). For these specific constraints to be met, the output of Layer 2 (a2) must be an extremely small positive number, very close to zero.

2. Reverse-Engineering Layer 2

Layer 2 uses the ReLU activation function: \(a_2 = \operatorname{ReLU}(z_2)\), where \(z_2 = \operatorname{sum}(a_1 \cdot W_2) + b_2\).

Key observations: - All weights in W2 are negative (e.g., -0.954667). - The bias b2 is a very small positive number (approx. \(\frac{1}{254}\)). - a1 is the output of Layer 1's ReLU, so \(a_1 \ge 0\).

Negative W2 weights reduce z2 whenever an a1 component is positive. Setting every a1 component to zero is a sufficient way to preserve the positive bias contribution. Proving that this is necessary requires the exact weights, biases, and discrete input step; the retained values alone do not establish that bound.

3. Analyzing Layer 1

To force \(a_1 = 0\), we must ensure that \(z_1 = x \cdot W_1 + b_1 \le 0\) for all neurons in the first layer.

Looking closely at the biases (b1), they appear to be "random" decimals: - h1[0] = -0.795276 - h1[3] = -0.90551 - h1[12] = -0.968504 - h1[23] = 0.91339

If we multiply these values by 127 (the maximum standard ASCII value), they resolve into integers. This reveals that W1 and b1 are essentially implementing boundary checks for each character of the input string.

Converting these non-zero biases back to ASCII: - -0.795276 * 127 \(\approx\) -101 \(\rightarrow\) e - -0.90551 * 127 \(\approx\) -115 \(\rightarrow\) s - -0.968504 * 127 \(\approx\) -123 \(\rightarrow\) { - 0.91339 * 127 \(\approx\) 116 \(\rightarrow\) t

4. Reconstructing the Flag

Extracting all valid b1 values and converting them yields a multiset of 22 characters: t, e, x, s, a, w, {, }, s, v, r, r, r, 3, 3, 3, 3, _, n, l, 4, u

We know the flag format is texsaw{flag}. Removing the wrapper characters (t, e, x, s, a, w, {, }), we are left with: s, v, r, r, r, 3, 3, 3, 3, _, n, l, 4, u

The character multiset suggests a Leetspeak phrase, but does not determine character order. A reproducible reconstruction must associate each nonzero W1 entry with its input column and intersect that column’s bounds, then evaluate the candidate through the complete network and the Row 112 predicate. The spreadsheet, extraction script, and forward-check output are not retained here; this is a method note rather than a complete solver. The flag below is retained from the existing record, without a new acceptance or model verification claim.

Flag

texsaw{n3ur4l_r3v3rs3}