TVX CTF 2026Reverse Engineering
Twist Me A Twister
“Programs can twist your tongue too.” A .NET executable decodes a 40-byte array into the flag and compares it with the input.
- Competition
TVX CTF 2026
- Category
- Reverse EngineeringEasy · estimated
- Source status
- Flag recovered locally · platform unverified
- Document
- PDF edition4 min read
Brief
The challenge
- Competition
- TVX CTF 2026
- Category
- Reverse Engineering
- Difficulty
- Easy — estimated, not an official rating
- Points
- 100
- Challenge author
- notsaad
- Verification
- Flag recovered locally; platform acceptance not documented
Difficulty: Easy (estimated). TVX CTF 2026 did not publish difficulty ratings; the challenge cards show only points and solve counts. A .NET program that builds its flag with a permutation, a rotate and an XOR, all visible after decompilation and easy to reimplement.
01
Overview
Ever heard of tongue twisters? programs can twist your tongue too!!
“Programs can twist your tongue too.” A .NET executable decodes a 40-byte array into the flag and compares it with the input.
Solution path in brief
The binary is a small .NET program. It decodes a 40-byte array into the flag at startup and compares it with what you type. Decompiling it gives the decode routine, which takes a few lines of Python to reimplement:
data[(i*7+3) % 40] → rotate right by (n % 5 + 1) → XOR with (55 + n*11) → flag[i]02
Initial investigation
The PE import table identified the binary type.
Triage
The PE header shows a 32-bit image whose only import is mscoree.dll!_CorExeMain, so this is a .NET assembly. A decompiler gives back near-source C#, and there's no need to run the program.
03
Tools used
ilspycmd(.NET decompilation)Python 3 (
solve.py)
04
Step-by-step process
Step 1: Decompile
Decompiling with ilspycmd TwistMeATwister.exe -o decompiled produces one small class:
private static readonly byte[] data = new byte[40] { 162, 216, 9, 192, ... 91, 18 };private static byte Ror(byte value, int count) => (byte)((value >> count) | (value << 8 - count));private static string Reveal(){ byte[] array = new byte[data.Length]; for (int i = 0; i < array.Length; i++) { int num = (i * 7 + 3) % array.Length; byte b = Ror(data[num], num % 5 + 1); b ^= (byte)(55 + num * 11); array[i] = b; } return Encoding.ASCII.GetString(array);}private static void Main(){ string text = Reveal(); Console.Write("flag> "); string text2 = Console.ReadLine() ?? string.Empty; Console.WriteLine((text2 == text) ? "accepted" : "rejected");}The program builds the flag itself with Reveal() and only does a plain string comparison against the input. So there is nothing to invert; we only need to run Reveal().
Step 2: The "twist"
For each output position i, Reveal() does three things:
Permutation: it reads source byte
n = (i*7 + 3) mod 40. Because 7 and 40 are coprime, this visits every byte exactly once.Rotation: it rotates that byte right by
n % 5 + 1bits, so between 1 and 5.XOR: it XORs the result with
(55 + 11n) & 0xFF.
Step 3: Reimplement
The script is in solve.py:
data = [ 162, 216, 9, 192, 74, 180, 56, 71, 143, 213, 231, 22, 230, 127, 188, 219, 2, 85, 152, 237, 76, 229, 224, 182, 136, 102, 176, 160, 67, 64, 235, 43, 70, 223, 94, 189, 250, 205, 91, 18,]def ror(v, c): return ((v >> c) | (v << (8 - c))) & 0xFFout = bytearray(len(data))for i in range(len(data)): n = (i * 7 + 3) % len(data) out[i] = ror(data[n], n % 5 + 1) ^ ((55 + n * 11) & 0xFF)print(out.decode())> python solve.pyTVX{Fl4ggy_fl4g_fl4g_tw15ty_tw15t_tw15t}05
Commands and code
Full source: solve.py
data = [ 162, 216, 9, 192, 74, 180, 56, 71, 143, 213, 231, 22, 230, 127, 188, 219, 2, 85, 152, 237, 76, 229, 224, 182, 136, 102, 176, 160, 67, 64, 235, 43, 70, 223, 94, 189, 250, 205, 91, 18,]def ror(v, c): return ((v >> c) | (v << (8 - c))) & 0xFFout = bytearray(len(data))for i in range(len(data)): n = (i * 7 + 3) % len(data) out[i] = ror(data[n], n % 5 + 1) ^ ((55 + n * 11) & 0xFF)print(out.decode())06
Technical explanation
The index (7i + 3) mod 40 visits every byte exactly once because 7 and 40 are coprime, so it is a permutation. Each byte is then rotated right by n % 5 + 1 and XORed with (55 + 11n) & 0xFF. Since the program builds the expected string itself and only compares, the solution copies the computation rather than inverting it.
Key lessons
An
mscoree.dllimport means .NET. Decompile it with ILSpy or dnSpy rather than reading x86 disassembly.When a program computes the expected value itself and only compares it, copy the computation instead of reversing it.
07
Flag
Flag
TVX{Fl4ggy_fl4g_fl4g_tw15ty_tw15t_tw15t}
Flag recovered locally · platform unverified
08
Verification status
Status: Flag recovered locally; platform acceptance not documented.
The flag is produced by reimplementing Reveal() exactly as decompiled. The source does not record running the binary to confirm it, and platform acceptance is not documented.
Source evidence in the archive: WRITEUP.md, solve.py.
09
Conclusion
A short exercise in recognising .NET binaries and copying the computation instead of reversing it.
Prepared by Adam Omar Saleh from the archived solve notes in twist_me_a_twister/. Commands, code, output and screenshots are reproduced from the source; no results were added. Difficulty is an estimate.