Lion Cipher Lab

Command execution on Microsoft SQL Server via xp_cmdshell — prove it, then harden it

Why it matters

Databases are where the crown jewels live, and Microsoft SQL Server is one of the most common databases in enterprise environments. The single most damaging way it gets owned is boring: the `sa` account -- the built-in system administrator login -- is left with a weak, guessable, or reused password, and the server is reachable on the network. That is not a data-theft problem, it is a whole-host problem, because a SQL Server sysadmin can reconfigure the server, and one of the things they can turn on is xp_cmdshell, a built-in feature that runs operating-system commands. The reason this lab…

What you'll learn

Steps in this lab

  1. First, the shape of the problem — an account, not a magic bug
  2. Set up: run a real SQL Server locally, for free
  3. Install impacket and connect as sa
  4. BEFORE — prove xp_cmdshell is OFF by default
  5. AFTER — a sysadmin can turn it back on
  6. Why this worked — and why the naive fix misses the point
  7. HARDEN — set xp_cmdshell back off
  8. HARDEN — fix the real hole: the account and the exposure
  9. Honest limits, and how a pro thinks about it

Open the full interactive lab →