Skip to content
Lab 6 of 6

Write the Detection: Catch the Attack, Not the Customers

Turn the night into three detections — a rule for SQL injection in web requests, a brute-force alarm over auth.log, a YARA rule for the backdoor — and prove each catches other attackers too without firing on Kestrel's own customers and scripts.
  • Advanced
  • 38 min
  • Blue Team
  • Detection
  • YARA
  • Regex
  • Kestrel

Overview

The morning of 4 November. Customers have been getting SMS messages that use their names and phone numbers. Harpreet Kaur calls it in at 07:15; Simran Gill rolls back the release that went out at 22:47 the night before and, before anything rotates, copies the server's logs to /srv/evidence/var/log (start with cat /srv/evidence/README.md). This machine is that server, kestrel-api-1, exactly as the attacker left it.

The investigation is done; now make sure the next one starts at the first probe, not at 07:15. A detection is only as good as two numbers: what it catches (true positives) and what it wrongly flags (false positives). A rule that fires on every customer who searches for Haldiram's gets switched off in a week; a rule that only matches last night's exact strings catches nobody else.

So each rule you write is tested three ways: against last night's attack, against the night's normal traffic, and against other attackers' traffic the rule has never seen — other addresses, tools, capitalisation and spacing. Rules live in ~/rules/.

What you will learn

  • Write a case-insensitive regular-expression rule for SQL injection over decoded requests
  • Avoid false positives on real customer searches
  • Turn a counting pipeline into a reusable brute-force alarm
  • Write a YARA rule that catches a reverse shell but not a health probe

Before you start

  • Comfortable in a Linux shell: grep, pipes and redirecting with >
  • sudo for files another account owns — you have it here
  • Basic regular expressions (|, *, +, character classes)
  • Labs 1 and 2 of this track, or the same skills

Tasks

  1. 01A rule for SQL injection
  2. 02A brute-force alarm
  3. 03A YARA rule for the backdoor