Challenge Description

Category: Reverse Engineering / Industrial Protocols

Difficulty: 🔴 Hard

Northgate Water Treatment Plant is running an unpatched SCADA system in its DMZ. The process is in safe shutdown, its IEC 60870-5-104 interface is exposed on TCP/2404, and a web HMI on TCP/8080 gives us a view of the plant. The interlock order is undocumented. Send the controls in the wrong order and the PLC trips.

We get three files:

main              Linux build
main.exe          Windows build
ioa_map_ctf.png   command and telemetry IOA map

The map is useful. It tells us that the commands are single-point controls in the 2001 to 2008 range. It does not tell us the only order that the emulated PLC accepts.

At first this looks like a protocol puzzle: connect to port 2404, throw commands at it, watch the HMI, repeat until something works. That approach lasts exactly until the first wrong command trips the process and wipes the progress.

The order is not meant to be guessed. It is sitting in the binary.


TL;DR

  • Both executables are Go 1.22.2 builds of the same PLC emulator.
  • The native symbol tables are stripped, but Go’s pclntab still contains the function names.
  • The binary embeds the HMI, an HTTP status endpoint, the IEC-104 server, the ladder simulation, and the sequence checker.
  • main.NewPLCState constructs this seven-element slice:
2006 → 2005 → 2001 → 2003 → 2002 → 2004 → 2007
  • In command names, that is:
SYS_ENABLE
ALM_RESET
VALVE_A_OPEN
PUMP1_START
VALVE_B_OPEN
PUMP2_START
HEATER_ON
  • BYPASS_MODE at IOA 2008 is a very convincing decoy.
  • Commands are sent as IEC-104 C_SC_NA_1 (TypeID=45) activation requests to common address 1.
  • A wrong ON command sets the sequence-trip and motor-fault bits, clears process outputs, and resets the sequence index.
  • After the ladder marks the process unlocked, /api/status calls main.generateFlag.
  • The suffix is the first eight SHA-256 bytes of SCADA_CTF_2026_INTERLOCK_SEQUENCE_COMPLETE, formatted as uppercase hex.
  • Final flag:
FLAG{PLC_L4DD3R_L0G1C_4C036B21E901E1FB}

Initial Triage

I started with the boring checks because the boring checks tell me which toolchain lies ahead.

Get-Item .\main, .\main.exe | Select-Object Name, Length
Get-FileHash -Algorithm SHA256 .\main, .\main.exe
Format-Hex .\main -Count 32
Format-Hex .\main.exe -Count 160

The two files are different target builds of the same program:

File Format Size SHA-256
main ELF64, x86-64, Linux 7,615,449 13A43EABDCF0F76BC7F5FE2F42C943EC9C2928C595A9F23321071B93CFCE0A28
main.exe PE32, x86, Windows 7,498,752 82E16120A3483367CB01E91996A4922CB148F4473CB16C3D27D82532A6E0E728

The Windows PE really is 32-bit: its COFF machine is 0x014c, and the optional-header magic is 0x10b. The Linux build is a normal x86-64 executable. That split is convenient: I can execute the PE directly on the analysis host and use the ELF for cleaner static disassembly.

The Go build metadata is still present:

strings.exe -n 8 .\main     | rg "go1\.|GOARCH|GOOS"
strings.exe -n 8 .\main.exe | rg "go1\.|GOARCH|GOOS"
main:
go1.22.2
build   GOARCH=amd64
build   GOOS=linux

main.exe:
go1.22.2
build   GOARCH=386
build   GOOS=windows
IDA Free after importing the Go metadata, with main.main and recovered Go functions visible

A broad strings pass already gives us a surprising amount of context:

strings.exe -n 5 .\main |
  rg -i "IEC104|api/status|static/index.html|Sequence step|ALARM_RESET|FLAG\{|main\."

Interesting hits include:

static/index.html
/api/status
[IEC104] Listening on %s
[IEC104] C_SC IOA=%d State=%v
Sequence step accepted
SEQUENCE FAULT: wrong order (IOA %d)
Alarm reset accepted - sequence fault cleared, restart from step 1
FLAG{PLC_L4DD3R_L0G1C_%X}
main.NewPLCState
main.(*PLCState).ExecuteLadderLogic
main.(*IEC104Session).handleSingleCommand
main.generateFlag

So the challenge is self-contained. The UI, PLC model, IEC-104 stack, and flag generator all live in the same executable.

One string is conspicuously incomplete:

SCADA_CTH

That turns out to matter later. For now I parked it.


Running It Once

Before opening the disassembler I wanted to see the program’s normal behavior. The Windows build accepts separate listen addresses, which means I can bind it to loopback and not expose an emulated control system to the rest of the network.

.\main.exe `
  -verbose `
  -iec104 127.0.0.1:2404 `
  -web 127.0.0.1:8080
==============================================
  PLC CTF Emulator - IEC 60870-5-104
  Target: Industrial Process Control System
==============================================
  IEC104 addr : 127.0.0.1:2404
  Web addr    : 127.0.0.1:8080
  HMI         : embedded in binary
  Verbose     : true
==============================================
[IEC104] Listening on 127.0.0.1:2404
[WEB] Listening on 127.0.0.1:8080  (HMI embedded in binary)

The embedded web server exposes:

GET /             HMI
GET /api/status   live PLC state as JSON

The initial status is exactly what the challenge description promises:

{
  "sensor_estop": true,
  "sensor_door_closed": true,
  "sensor_motor_fault": false,
  "cmd_system_enable": false,
  "cmd_valve_a_open": false,
  "cmd_pump1_start": false,
  "cmd_valve_b_open": false,
  "cmd_pump2_start": false,
  "cmd_heater_on": false,
  "flag_unlocked": false,
  "sequence_tripped": false,
  "correct_commands": 0
}

The HMI is unusually useful for a reversing challenge. It provides the IOA map, process feedback, eight ladder rungs, command coils, diagnostic messages, and a flag panel. What it refuses to show is the secret order.

Embedded HMI before any IEC-104 commands

The command table visible in the image and HMI is:

Command IOA HMI output
VALVE_A_OPEN 2001 Q2.0
VALVE_B_OPEN 2002 Q2.1
PUMP1_START 2003 Q2.2
PUMP2_START 2004 Q2.3
ALM_RESET 2005 Q2.4
SYS_ENABLE 2006 Q2.5
HEATER_ON 2007 Q2.6
BYPASS_MODE 2008 Q2.7

The ladder makes a believable story out of these controls:

  • E-stop, door, and motor-fault contacts establish SYS_READY.
  • SYS_ENABLE and a normally closed temperature-alarm contact establish the first interlock.
  • ALM_RESET and a LEVEL_LOW OR BYPASS branch establish the second interlock.
  • Valve A permits pump 1.
  • Pump 1 and flow feedback permit valve B.
  • Valve B feedback permits pump 2 and the heater.

If I were operating a real plant, I would reason from those permissives. In a CTF, the ladder is also a piece of misdirection. It tells me what should be physically sensible, not what the flag checker compares.


“Stripped” Go Is Not Nameless

The ELF’s native symbol table does not help much:

objdump.exe -t .\main

There is effectively nothing useful there. The easy mistake is to throw the binary into IDA, accept several thousand anonymous functions, and begin renaming them by hand.

Go gives us a better option. The runtime needs program-counter metadata for stack growth, panic traces, garbage collection, and reflection. The linker stores that data in pclntab, and function names usually survive even when the platform symbol table does not.

For this Go 1.22 binary, the pclntab header begins with:

f1 ff ff ff 00 00 01 08

I located it at file offset 0x35BA40:

data = open("main", "rb").read()
base = data.find(bytes.fromhex("f1ffffff00000108"))
print(hex(base))
# 0x35ba40

The 64-bit header fields decode to:

nfunc          = 0x15E0  (5600 functions)
nfiles         = 0x0238
textStart      = 0x401000
funcnameOffset = 0x60
cuOffset       = 0x38620
filetabOffset  = 0x3ACC0
pctabOffset    = 0x411C0
pclnOffset     = 0xEBA20

This small parser is enough to recover every Go function name and address I need:

import struct

data = open("main", "rb").read()
base = data.find(bytes.fromhex("f1ffffff00000108"))
assert base >= 0

magic, pad1, pad2, min_lc, ptr_size = struct.unpack_from(
    "<IBBBB", data, base
)

(
    nfunc,
    nfiles,
    text_start,
    funcname_off,
    cu_off,
    filetab_off,
    pctab_off,
    pcln_off,
) = struct.unpack_from("<QQQQQQQQ", data, base + 8)

funcnametab = base + funcname_off
pclntab = base + pcln_off

for index in range(nfunc):
    entry_off, func_off = struct.unpack_from(
        "<II", data, pclntab + index * 8
    )

    func_record = pclntab + func_off
    _, name_off = struct.unpack_from("<Ii", data, func_record)

    name_start = funcnametab + name_off
    name_end = data.index(b"\x00", name_start)
    name = data[name_start:name_end].decode("utf-8", errors="replace")

    if name.startswith("main."):
        print(f"0x{text_start + entry_off:08x}  {name}")

Selected output:

0x006490e0  main.NewPLCState
0x00649280  main.(*PLCState).AddDiag
0x006495c0  main.(*PLCState).ExecuteLadderLogic
0x00649c60  main.(*IEC104Server).Start
0x0064a280  main.(*IEC104Session).handle
0x0064abe0  main.(*IEC104Session).processAPDU
0x0064afa0  main.(*IEC104Session).processIFrame
0x0064b400  main.(*IEC104Session).handleSingleCommand
0x0064c700  main.(*IEC104Session).buildIFrame
0x0064d180  main.generateFlag
0x0064d2c0  main.(*WebServer).handleStatus
0x0064da80  main.(*WebServer).handleIndex
0x0064e380  main.main

That is almost a source-level roadmap. I no longer need to ask which of 5,600 functions contains the sequence. NewPLCState is the obvious first stop.

⚠️ If a Go binary looks stripped, check pclntab before doing anything heroic. I have manually renamed enough runtime wrappers for one lifetime.


Finding the Hidden Sequence

main.NewPLCState starts at 0x6490E0. The first half initializes timestamps, sensor bits, setpoints, and the initial process state. Near the end, the function allocates another object and starts writing seven 64-bit immediates into it.

objdump.exe -d -M intel `
  --start-address=0x6490e0 `
  --stop-address=0x649280 `
  .\main

The interesting block begins at 0x6491E9:

6491e9  lea    rax,[rip+0x25d70]
6491f0  call   runtime.newobject

6491f5  mov    qword ptr [rax],      0x7d6   ; 2006
6491fc  mov    qword ptr [rax+0x08], 0x7d5   ; 2005
649204  mov    qword ptr [rax+0x10], 0x7d1   ; 2001
64920c  mov    qword ptr [rax+0x18], 0x7d3   ; 2003
649214  mov    qword ptr [rax+0x20], 0x7d2   ; 2002
64921c  mov    qword ptr [rax+0x28], 0x7d4   ; 2004
649224  mov    qword ptr [rax+0x30], 0x7d7   ; 2007

649231  mov    qword ptr [rcx+0x60], 0x7     ; slice length
649239  mov    qword ptr [rcx+0x68], 0x7     ; slice capacity
64925a  mov    qword ptr [rcx+0x58], rax     ; slice data pointer
FlagSequence allocation and immediate IOA stores

That is a Go slice header in the PLC state:

plc.FlagSequence.data = array;
plc.FlagSequence.len  = 7;
plc.FlagSequence.cap  = 7;

And the array is:

0x7D6  2006  SYS_ENABLE
0x7D5  2005  ALM_RESET
0x7D1  2001  VALVE_A_OPEN
0x7D3  2003  PUMP1_START
0x7D2  2002  VALVE_B_OPEN
0x7D4  2004  PUMP2_START
0x7D7  2007  HEATER_ON

So the exact order is:

SYS_ENABLE
ALM_RESET
VALVE_A_OPEN
PUMP1_START
VALVE_B_OPEN
PUMP2_START
HEATER_ON

Two things here are designed to punish reasonable assumptions.

First, BYPASS_MODE is not in the array. The HMI gives it equal visual weight, and the ladder shows it as a valid parallel path around LEVEL_LOW. It may affect simulated process logic, but it does not advance the flag sequence.

Second, ALM_RESET is step two. On a healthy process, an alarm-reset command feels unnecessary. In this challenge it has two roles: it is the second clean-path command and the special recovery command after a trip.

If I had guessed from the ladder, I would have sent SYS_ENABLE, then VALVE_A_OPEN. That guess gets the first step right and immediately trips on the second. Close enough to look promising; wrong enough to erase the evidence that it was close.


Reading handleSingleCommand

The sequence array tells us the answer, but I still wanted to understand the failure behavior before touching the live service. That logic is in main.(*IEC104Session).handleSingleCommand at 0x64B400.

The function begins by decoding the command object:

IOA = ASDU[6] | ASDU[7]<<8 | ASDU[8]<<16
SCO = ASDU[9]
ON  = SCO & 1

It normalizes the command range with ioa - 2001:

64b529  lea  r15,[r13-0x7d1]    ; IOA - 2001
...
64b70a  cmp  rcx,0x7            ; valid indices 0..7
64b726  jmp  qword ptr [rax+rcx*8]

The jump table maps the eight IOAs to eight adjacent command booleans in the PLC state. Unknown IOAs take the logging path instead.

The sequence checker only runs when both conditions hold:

recognized command == true
command state       == ON

That is visible at:

64b880  test cl,cl              ; recognized?
64b882  je   skip_sequence
64b888  test r8b,0x1            ; ON?
64b88c  je   skip_sequence

Trip recovery

The first branch checks whether the PLC is already tripped:

64b892  cmp  byte ptr [rax+0x70],0   ; SequenceTripped?
64b896  je   check_expected_step

64b8a1  cmp  rdx,0x7d5               ; IOA == 2005?
64b8a8  jne  reject_while_tripped

64b8aa  mov  byte ptr [rax+0x70],0   ; clear SequenceTripped
64b8ae  mov  byte ptr [rax+0x23],0   ; clear MotorFault
64b8b2  mov  qword ptr [rax+0x50],0  ; step = 0

That produces:

Alarm reset accepted - sequence fault cleared, restart from step 1

Any other ON command while tripped is rejected.

Correct command

On a healthy state, the function loads the current sequence index, bounds-checks it, and reads the expected IOA from the recovered slice:

64b938  mov  rdx,[rax+0x50]          ; current step
64b93c  mov  rcx,[rax+0x60]          ; sequence length
64b949  jbe  panicIndex
64b94f  mov  rcx,[rax+0x58]          ; sequence data
64b953  mov  rcx,[rcx+rdx*8]         ; expected IOA
64b957  mov  rbx,[rsp+0x30]           ; received IOA
64b960  cmp  rcx,rbx
64b963  jne  sequence_fault

A match advances the index and increments the accepted-command counter:

64b965  lea  rcx,[rdx+1]
64b969  mov  [rax+0x50],rcx          ; step++
64b96d  inc  qword ptr [rax+0x80]   ; CorrectCommands++

Wrong command

The mismatch path is deliberately destructive:

64b991  mov  byte ptr [rax+0x70],1   ; SequenceTripped = true
64b995  mov  byte ptr [rax+0x23],1   ; MotorFault = true
64b999  mov  byte ptr [rax+0x29],0   ; clear command outputs...
64b99d  mov  byte ptr [rax+0x24],0
64b9a1  mov  byte ptr [rax+0x25],0
64b9a5  mov  byte ptr [rax+0x26],0
64b9a9  mov  byte ptr [rax+0x27],0
64b9ad  mov  byte ptr [rax+0x2a],0
64b9b1  mov  qword ptr [rax+0x50],0  ; step = 0

The decompiled logic is roughly:

if (recognized && on) {
    if (plc.SequenceTripped) {
        if (ioa == 2005) {
            plc.SequenceTripped = false;
            plc.SensorMotorFault = false;
            plc.FlagSequenceStep = 0;
        } else {
            reject("send ALARM_RESET first");
        }
    } else if (ioa == plc.FlagSequence[plc.FlagSequenceStep]) {
        plc.FlagSequenceStep++;
        plc.CorrectCommands++;
    } else {
        plc.SequenceTripped = true;
        plc.SensorMotorFault = true;
        plc.FlagSequenceStep = 0;
        clear_process_commands();
    }
}

There is a subtle split here: the command handler advances the secret sequence, while the periodic ExecuteLadderLogic goroutine evaluates the process state. Near 0x649BA2, the ladder task checks its final conditions and writes the FlagUnlocked byte at PLC-state offset 0x4C.

Finally, main.(*WebServer).handleStatus checks that byte. Only when it is set does the HTTP handler call main.generateFlag and include the flag in the JSON response.

In other words, the protocol handler does not simply return a flag after command seven. The sequence checker and process simulation cooperate, and the HMI observes the result.


IEC 60870-5-104, Just Enough to Drive It

With the order recovered, the reversing half is done. Now I need to speak enough IEC-104 to send seven single commands.

IEC-104 rides directly over TCP. Every APDU starts with 0x68, followed by a one-byte length. The four-byte APCI control field follows, then an ASDU for I-frames.

The connection starts with a U-frame handshake:

68 04 07 00 00 00    STARTDT_ACT
68 04 0B 00 00 00    STARTDT_CON

After STARTDT_ACT, this server immediately sends its current process image as a series of M_SP_NA_1 I-frames. In verbose mode I saw the server send 13 telemetry objects before it accepted my first control command. For a quick challenge solver I can drain them. A production IEC-104 implementation must track and acknowledge them properly.

The command ASDU is C_SC_NA_1, a single command without timestamp:

Field Value Meaning
Type ID 45 / 0x2D C_SC_NA_1
VSQ 1 one information object
COT 6 activation
Common address 1 PLC station address
IOA 2001–2007 target command
SCO 0x01 command state ON

The complete command APDU is 16 bytes:

68 0E SS SS RR RR 2D 01 06 00 01 00 II II II 01

Breaking that apart:

68             start byte
0E             14 bytes follow
SS SS          N(S) << 1, little-endian
RR RR          N(R) << 1, little-endian
2D             TypeID 45, C_SC_NA_1
01             VSQ, one object
06 00          cause of transmission 6, activation
01 00          common address 1
II II II       three-byte little-endian IOA
01             SCO: ON, select bit clear

For the first command, SYS_ENABLE at IOA 2006 (0x07D6), I used:

68 0E 00 00 00 00 2D 01 06 00 01 00 D6 07 00 01

The IOA encodings for the whole sequence are:

Step Command Decimal IOA Three-byte IOA
1 SYS_ENABLE 2006 D6 07 00
2 ALM_RESET 2005 D5 07 00
3 VALVE_A_OPEN 2001 D1 07 00
4 PUMP1_START 2003 D3 07 00
5 VALVE_B_OPEN 2002 D2 07 00
6 PUMP2_START 2004 D4 07 00
7 HEATER_ON 2007 D7 07 00

For consecutive client I-frames, N(S) increments and is shifted left by one in the control field:

step 1: N(S)=0 -> 00 00
step 2: N(S)=1 -> 02 00
step 3: N(S)=2 -> 04 00
step 4: N(S)=3 -> 06 00
step 5: N(S)=4 -> 08 00
step 6: N(S)=5 -> 0A 00
step 7: N(S)=6 -> 0C 00

For each activation, the server returns:

COT 7    activation confirmation
COT 10   activation termination
S-frame  receive acknowledgement

That behavior is useful during testing. A TCP write succeeding only proves that the bytes reached the socket. The confirmation and diagnostic log prove that the emulator parsed and accepted the command.


A Minimal Solver

This is the exact approach I used against the local emulator. It starts data transfer, drains the initial process-image messages, sends the recovered sequence, and finally checks the HMI API.

import json
import socket
import time
import urllib.request

HOST = "127.0.0.1"
IEC_PORT = 2404
HMI_STATUS = "http://127.0.0.1:8080/api/status"

SEQUENCE = [2006, 2005, 2001, 2003, 2002, 2004, 2007]


def c_sc_na_1(tx_sequence, ioa):
    # APCI control field. The challenge server tolerates N(R)=0.
    control = (tx_sequence << 1).to_bytes(2, "little") + b"\x00\x00"

    # TypeID, VSQ, COT, common address, IOA, SCO.
    asdu = (
        bytes([0x2D, 0x01, 0x06, 0x00, 0x01, 0x00])
        + ioa.to_bytes(3, "little")
        + b"\x01"
    )

    return b"\x68\x0E" + control + asdu


def drain_until_quiet(sock):
    try:
        while sock.recv(65535):
            pass
    except socket.timeout:
        return


sock = socket.create_connection((HOST, IEC_PORT))
sock.settimeout(0.08)

# U-frame: STARTDT_ACT
sock.sendall(bytes.fromhex("68 04 07 00 00 00"))
time.sleep(0.15)

# STARTDT_CON plus the server's initial telemetry burst.
drain_until_quiet(sock)

for tx_sequence, ioa in enumerate(SEQUENCE):
    frame = c_sc_na_1(tx_sequence, ioa)
    print(f"TX IOA={ioa}: {frame.hex(' ')}")

    sock.sendall(frame)
    time.sleep(0.18)
    drain_until_quiet(sock)

sock.close()

status = json.load(urllib.request.urlopen(HMI_STATUS))
print(json.dumps(status, indent=2))

This is intentionally a challenge client, not a reusable IEC-104 stack. It leaves N(R) at zero because the emulator tolerates it. A correct general client should parse every incoming I-frame, advance its receive counter, and place N(R) << 1 in bytes four and five of later APDUs.

Running it with verbose logging gives one accepted step per command:

[IEC104] C_SC IOA=2006 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2005 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2001 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2003 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2002 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2004 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted

[IEC104] C_SC IOA=2007 State=true (SCO=0x01)
[SUCCESS] Sequence step accepted
Verbose IEC-104 log showing all seven accepted commands

The final API response contains the proof I care about:

{
  "sensor_motor_fault": false,
  "cmd_valve_a_open": true,
  "cmd_valve_b_open": true,
  "cmd_pump1_start": true,
  "cmd_pump2_start": true,
  "cmd_alarm_reset": true,
  "cmd_system_enable": true,
  "cmd_heater_on": true,
  "cmd_bypass_mode": false,
  "flag_unlocked": true,
  "sequence_tripped": false,
  "total_commands": 7,
  "correct_commands": 7,
  "flag": "FLAG{PLC_L4DD3R_L0G1C_4C036B21E901E1FB}"
}

BYPASS_MODE is still false. All seven required commands were accepted. No sequence trip occurred.

HMI after the process sequence unlocks the flag

At this point the challenge is solved. There is still one part of the binary worth reversing: where the last 16 hex characters come from.


Reversing generateFlag

The flag format is visible to strings:

FLAG{PLC_L4DD3R_L0G1C_%X}

The %X means the suffix is computed. main.generateFlag at 0x64D180 shows exactly how.

objdump.exe -d -M intel `
  --start-address=0x64d180 `
  --stop-address=0x64d2c0 `
  .\main

The compiler first writes a 42-byte constant onto the stack. It does this with several overlapping movabs stores rather than referencing one clean string in .rodata:

64d1c7  movabs rcx,0x54435f4144414353
64d1d1  mov    [rsp+0x2e],rcx
64d1d6  movabs rcx,0x495f363230325f46
64d1e0  mov    [rsp+0x36],rcx
64d1e5  movabs rcx,0x544e495f36323032
64d1ef  mov    [rsp+0x38],rcx
...
64d212  movabs rcx,0x4554454c504d4f43
64d21c  mov    [rsp+0x50],rcx

Replaying the overlapping writes yields:

SCADA_CTF_2026_INTERLOCK_SEQUENCE_COMPLETE

This explains the weird SCADA_CTH artifact from the first strings pass. strings sees bytes in file order. The final runtime string exists only after those stores overlap in memory.

The rest of the function is straightforward:

64d22b  mov  ecx,0x2a                  ; input length = 42
64d233  call crypto/sha256.(*digest).Write
64d244  call crypto/sha256.(*digest).Sum
64d249  cmp  rcx,0x8                   ; require at least 8 digest bytes
64d258  mov  ebx,0x8                   ; slice digest[:8]
64d27c  lea  rax,[format_string]
64d298  call fmt.Sprintf

The format string is at .rodata:0x6CA14A:

objdump.exe -s `
  --start-address=0x6ca140 `
  --stop-address=0x6ca170 `
  .\main
6ca140  62797465 733a2025 2058464c 41477b50  bytes: % XFLAG{P
6ca150  4c435f4c 34444433 525f4c30 4731435f  LC_L4DD3R_L0G1C_
6ca160  25587d                               %X}

The source-level equivalent is:

func generateFlag() string {
    digest := sha256.Sum256(
        []byte("SCADA_CTF_2026_INTERLOCK_SEQUENCE_COMPLETE"),
    )

    return fmt.Sprintf(
        "FLAG{PLC_L4DD3R_L0G1C_%X}",
        digest[:8],
    )
}

Independent reproduction:

import hashlib

seed = b"SCADA_CTF_2026_INTERLOCK_SEQUENCE_COMPLETE"
digest = hashlib.sha256(seed).digest()

print(hashlib.sha256(seed).hexdigest())
print(digest[:8].hex().upper())
4c036b21e901e1fbe9086471f6619cb8b11d1a35eba88918c302697b61bc26a4
4C036B21E901E1FB

One final implementation detail: generateFlag is not called by the command handler. handleStatus checks FlagUnlocked and only then calls the generator while building the JSON response. That is why the flag can be deterministically reproduced without ever operating the emulator, but the intended live path still requires the ladder sequence.


Flag

FLAG{PLC_L4DD3R_L0G1C_4C036B21E901E1FB}

Reflection

This challenge works because every layer tells part of the truth.

The HMI is truthful about the available controls. It is not truthful about which controls matter to the flag checker. The ladder is truthful about process permissives. It is not the source of the seven-element comparison array. The IEC-104 service is real enough to require correct framing. It is forgiving enough that a tiny Python client can drive it. The binary is stripped in the normal ELF sense. It is still full of Go metadata.

There are four traps I would call out.

Trap one: treating Go like a stripped C binary

The native symbol table is empty, but pclntab restores names for NewPLCState, handleSingleCommand, ExecuteLadderLogic, and generateFlag. Finding that table turns thousands of anonymous functions into a short reading list.

Trap two: trusting the visual prominence of BYPASS_MODE

BYPASS_MODE is a valid command, appears on the HMI, and sits in a visible ladder branch. It never appears in FlagSequence. Sending it ON during the seven-step path trips the sequence.

Trap three: treating ALM_RESET as recovery-only

It is recovery-only after a trip. On the clean path it is also the mandatory second command. That dual role is the best piece of misdirection in the challenge.

Trap four: stopping at the visible flag

The HMI gives the answer after the correct sequence, but generateFlag contains another compact reversing puzzle. The seed is assembled through overlapping stores, so a basic string search sees only a broken fragment. Reconstructing it explains the suffix instead of merely copying it.

The solve path I liked was:

Go metadata
    ↓
NewPLCState and FlagSequence
    ↓
handleSingleCommand trip behavior
    ↓
raw IEC-104 APDUs
    ↓
live HMI verification
    ↓
static reconstruction of generateFlag

It is one executable viewed from three angles: a Go program, a PLC state machine, and an industrial protocol endpoint. None of those views is quite enough by itself. Together they make the sequence obvious and the final flag reproducible.

And, importantly, the PLC never trips. Not even once. I definitely did not first try SYS_ENABLE → VALVE_A_OPEN before reading the slice.