Find the Gate
Task 4 of 5 · Stage 1 · Read files · Next: Task 5 · Signal Check
The painted word is refused. Find the decision in Ghidra, read its length and byte rules, then derive an input and test it against a near miss.
- ~35 min
- 4 checked steps
- Ghidra · Detect It Easy
- You will use this when
- you must explain why a program accepts one input and refuses another — a licence or login check, or the condition that makes a sample start its real work. Most of a program does not matter; the few lines that decide do.
- Later in this path
- task 5 reads the same kind of check with one more step, a locked byte; module 5, Just Enough Assembly (planned), explains the instructions behind the decompiler’s text.
- After this task you can
- go from a function’s name to its address, read a rule and its constant, and say which position a comparison really uses.

Keeper: You made the door speak. This gate will not. Someone has painted a word across it in plain sight, and every traveller who trusted the paint is still standing outside. The gate does not read paint. Somewhere inside it is one test — a few lines that decide open or shut. Find those lines, and read them the way the gate does.
You will learn
- go from a program's name for its check to the check itself
- read a rule and its constant exactly, in hex and decimal
- read which position a comparison uses, not only which value
- You need
- Task 3 — Hear the Words · Task 2: position is not value · Ghidra and Detect It Easy from the lab setup · PowerShell
- Time
- ~35 minutes; the bonus note adds ~10
- Tools
- Ghidra, Detect It Easy, a notes file
Where this is used
Finding the few instructions where a program decides — accept or refuse — is how analysts review a licence or login check, how security researchers look for authentication that can be walked around, and how malware analysts find the condition that makes a sample start its real work. A secret inside a program stops being secret once someone reads the check.
Get the page, run it once
Archive page 4
gate-check.exe
A tiny console program written for this task. Its import table lists the same four Windows functions as task 3's; it also offers one named function, check_gate.
SHA-256: 963f050c2bd967cd96f1f17f5c69e2b9aa354c4b9757c6e049b18f1a3ade13e7
VirusTotal: 0 / 70 engines reported a detection (scanned 26 November 2026). See the report.
Read Downloads and safety first. Then repeat task 3's check: drag the file into Detect It Easy and read its import list. The same four functions give you the same lead. The import list alone is not a safety check; follow the fingerprint check in Downloads and safety before running the sample. Now run it once and type back the word painted on the gate.
.\gate-check.exe
$LASTEXITCODE
Write it under Observed: the program shows a word, and refuses that same word. What it says and what it checks are different things. From here on, you read the check.
Before step 1 · ~5 min · nothing to check
A map of Ghidra
Until now you read bytes one by one. Ghidra reads the whole program for you and shows it in several linked windows. You need three of them in this task; leave the rest closed for now.
- Symbol Tree
- the program's names, sorted into folders. Exports holds the names the program offers to others; Functions holds every function Ghidra found, most with names it made up, such as
FUN_140001000. - Listing
- the program as it is: one machine instruction per line, its address on the left. This is the evidence.
- Decompiler
- Ghidra's rebuild of the selected function as C-like text. Easier to read, but it is a guess: names and some types are invented.
The windows follow each other. Click a line in the Decompiler and the Listing moves to the matching instructions; select a name in the Symbol Tree and both move to it.
- Double-click a name or address to follow it; Alt+← goes back.
- G opens Go To: type an address or a name.
- L renames the selected function, label or variable. A good name is a note to yourself, not a fact about the program.
Quick self-test: which window is evidence, and which is a guess?
The Listing shows the instructions that are in the file. The Decompiler shows Ghidra's reading of them. When the two seem to disagree, trust the Listing and look again.
Step 1 · ~8 min
Find the gate
A program decides in very few instructions: a comparison, then a jump to "accept" or to "refuse". Finding them in a large program is most of the work; here you are given a head start. Some programs export functions — they offer them by name to other programs. This one's export table names exactly one function, as task 5's program will; Ghidra lists the program's start, entry, in the same folder. A name helps you navigate; it proves nothing. The lines inside are the evidence.
- In Ghidra, open your project and choose File → Import File. Accept the detected format (Portable Executable, x86-64), open the program and let it analyse.
- In Symbol Tree → Exports, select
check_gate. The Listing jumps to it and the Decompiler shows it as C-like text. - Write the function's address — the number at the left of its first line in the Listing — in your notes.
Show the Ghidra navigation reference — includes the rules from steps 2–3
Before you check: A Windows program's header names a preferred base address, and Ghidra shows addresses from that base. (When the program runs, Windows usually moves it elsewhere — ASLR — so a debugger shows different numbers; the distances from that base (RVAs) stay the same. They are not the same as file offsets in HxD.) How many hex digits do you expect the address to have — four, or about nine?
From now on, every claim in your notes gets an address beside it.
H1 · Direction
If you cannot see the Symbol Tree, open it from the Window menu. Exports is one of its folders.
H2 · Method
Click check_gate once. The Listing's cursor lands on the function's first instruction; the address is the long hex number at the start of that line.
H3 · Check
It starts with 14 — the usual base of a 64-bit Windows program. Other tools, Detect It Easy among them, may show the same function relative to the base instead of the full address: give the answer as Ghidra shows it.
Step 2 · ~7 min
The length rule
The decompiler rebuilds C-like text from machine code. Its names (param_1, local_10, uVar1) are its own guesses, not the author's. Look for its shape. A loop that walks the input until it meets a zero byte is counting the length. A line of the form if (… != …) return 1; is a rule: when it holds, the gate refuses. Ghidra usually prints constants in hex.
- In the Decompiler, find the counting loop and the variable it leaves the length in.
- Find the first
return 1after it. Copy the whole condition into your notes, with the address of its line. - Convert the constant to decimal and write the multiplication.
Before you check: count the characters of the painted word. Does it pass this first rule? (If it does, the paint was made to look right.)
The painted word has the right length. It passes the first rule — so the second rule is where it fails.
H1 · Direction
The rule sits near the top of the function, just after the loop that counts.
H2 · Method
The constant is one hex digit after 0x. Hex digits run a = 10 to f = 15.
H3 · Check
Between 10 and 15, and the same number as the characters of the painted word.
Step 3 · ~8 min
The byte rule
After the length, a loop checks one character per pass. Read three things in it: how far i runs, which input byte is compared, and which stored byte it is compared with. The two positions need not be the same: the expression inside the square brackets decides. Ghidra may show the stored bytes as a DAT_… label or an inline string literal, depending on its analysis. Follow the data reference to inspect the bytes in the Listing; the screenshot below shows the inline form.
- Find the loop. Write its bound — it should match step 2.
- Write the comparison exactly as shown, then twice more with numbers: once for
i = 0, once fori = 1. - Follow the data reference from the label or string literal to the Listing. Copy the stored bytes in order, with their indexes from 0; compare with Figure 4.5 if your view differs.
Before you check: if the brackets held plain i, what would the accepted word be? Write it — then say why the gate would refuse it.
The first character you type is checked against the last stored byte. Work out what that means for the second one before you build the word.
H1 · Direction
Look at the stored-byte index inside the square brackets, whether Ghidra shows a DAT_… label or an inline string literal.
H2 · Method
Put i = 0 into the expression and compute it. Ghidra shows the constant in hex.
H3 · Check
It is the last valid index of the stored bytes — one less than the length from step 2.
Step 4 · ~7 min · flag
What does the gate accept?

Keeper: Two rules, and you have read both. Build the word the way the gate reads it, one mark at a time — then try it, and try it wrong.
- Make a table:
i· stored index · stored byte · character. Fill it for everyithe loop runs. - Read the character column from top to bottom: that is the word. Check it against both rules.
- Run the program with it: expect
0. Run it again with one character changed: expect1. Type the word below. A right answer gives you the flag.
Flag captured
Keeper: Open. You did not guess at it — you read the test, and the test does not lie. My last page in this region is a program that locks its word with a key, the copper rule of my archive. You already know every part of it.
Task 5 · Signal Check → Explain your findingH1 · Direction
No arithmetic on the bytes: every stored byte is already a character. Only the order changes.
H2 · Method
Row i = 0 uses the stored index from step 3; each next row uses one less. The character in each row is what you must type at position i.
H3 · Check
Your word has the length from step 2 and is made of readable pieces joined by hyphens. Typing the stored bytes as they appear is refused; so is the painted word. If yours is refused, check row 0 against the last stored byte.
Walkthrough
Stuck after the hints? Show the walkthrough — it shows every answer
- 1. Symbol Tree → Exports →
check_gate: its address is 0x140001220. - 2. Length rule: the constant is
0xe= 14. - 3. Byte rule:
input[i]is compared with the stored byte at0xd - i= 13 − i, soinput[0]meets index 13 and the stored bytes are the word written backwards. - 4. Read the stored bytes from index 13 down to index 0 and type the result.
Bonus
Explain the gate in five lines
The same five lines task 5 asks for: Location (function and address of the decision) · Conditions (both rules, with their constants) · Derivation (how one position of the word follows from the stored bytes) · Validation (the accepted run and a refused near miss, with exit codes) · Boundary (what your tests show, and what you have not looked at).
I have written my note — show the model note
- Location
- The exported function
check_gate, at the address found in step 1. The entry code calls it with the line typed at the prompt and prints "opens" or "stays shut" from its result. - Conditions
- (1) The input must be
0xe= 14 characters, or the function returns 1. (2) For eachifrom 0 to 13,input[i]must equal the stored byte at0xd - i; the first difference returns 1. - Derivation
- At
i = 0the gate reads stored index 13, ati = 1index 12, and so on: the stored bytes are the word backwards. Reading them from index 13 to 0 gives the word. - Validation
- The word: "The gate opens.", exit 0. The word with its last character changed: "The gate stays shut.", exit 1. The painted word, which has the right length: exit 1 — it fails the second rule.
- Boundary
- I read the decompiler's view of one function and tested three inputs. I typed the derived word exactly. I did not test whether the program ignores case or surrounding spaces, and I did not inspect the entry code's input handling instruction by instruction.
Check yours: does each line point at an address, a constant or a run? Did you test a refusal as well as the acceptance? Any “no” tells you what to add.
This is guided practice. After task 5, use the Stage 1 checkpoint, The Forged Ledger, to test your work without hints. A separate no-hints version of this task is planned.
Your progress in this browser
Read further
- Ghidra on GitHub — the official project; its installed
docsfolder holds a beginner class with exercises on the CodeBrowser you used here. - Microsoft — x64 calling convention — why the typed line reaches
check_gatein the registerRCX, and where its result comes back. - CWE-656 — Reliance on Security Through Obscurity — why a check that only works while nobody reads it is a weakness.
Outside sites, not ByteToFlag. Links checked on 26 November 2026.
Take your method to the next task
Before you move on
- Can you navigate from an exported name to the function and explain why its name alone proves nothing?
- Can you read the length constant in hex and decimal?
- Can you derive the stored index for each input position and test an accepted input against a refused near miss?
If one is unclear, revisit that step or compare your five-line explanation with the model note. The final answer check records guided practice when browser progress is on.
Task 5 · Signal Check: the same shape of check, with one more step. Each stored byte is locked with XOR, as in Task 2's copper marks. Keep Ghidra ready and bring your position-by-position method.
Task 5 · Signal Check → Review XOR in Task 2 Back to Module 4