Labs / Security Basics / Threats and weaknesses

Lab 5 of 5 · Threats and weaknesses

Kill chain: the stages of an attack, and where each one breaks

Read what one closed break-in left behind, sort it into six stages, and name the control that would have ended it at each.

Start this lab 7 steps

The idea

Nell looks after production and the computers at Thistledown Press, a small publisher. On one night in October somebody copied its big autumn book, two weeks before it went on sale. The incident is closed, and the publisher asks where exactly they got hacked. Lay out what that night left behind in the order it happened, and find every point where it could have been stopped.

Found backwards, read forwards
Found backwards, read forwards
A reader who tried the doors
A reader who tried the doors
Break one stage and the later ones never happen
Break one stage and the later ones never happen
A new password no longer helps
A new password no longer helps
The comment is not the rule
The comment is not the rule
The log names the machine in between
The log names the machine in between
Six stages, six chances
Six stages, six chances

Steps

  1. One night, found backwards

    Corin, the publisher, asks where Thistledown got hacked. His question expects one place and one moment.

    A break-in is rarely one moment. It is a run of stages, each a separate job the intruder has to get done, from looking the target over to taking what they came for. Defenders call that run a kill chain. The chain is the intruder's, and breaking it is the defender's job.

    The lab has put the night's evidence back where it was found. Start with Nell's notes on editorPc, her desk.

    editorPc:~# cat /home/nell/review/what-we-found.txt
  2. Stage 1, reconnaissance: a reader who tried the doors

    The oldest trace is not from the night at all. On Sunday 18 October, three days earlier, the outside address 203.0.113.58 visited the press's website.

    Before an intruder touches anything, they look the target over: what it runs, who works there, what is worth taking. This first stage is reconnaissance. On a public website it leaves the same trace as any reader does. The web server writes one line per page asked for, with the visitor's address, the time, the page and a status number: 200 for a page served, 404 for a page that does not exist.

    Pull that address's lines from the log on website. Then fetch /team, the page it read twice.

    website:~# grep '203.0.113.58' /var/log/nginx/access.log
    editorPc:~# curl -s http://10.0.9.10/team
  3. Stage 2, initial access: fourteen wrong, one right

    Looking is free. The second stage is the first that needs something to give way: initial access, the moment the intruder is first inside a machine.

    website lets the freelancer who looks after its pages sign in from home over SSH, with the account webdesk. Every try is written to /var/log/auth.log: Failed password for a wrong password, Accepted password for the right one.

    Pull the same address from that log.

    website:~# grep '203.0.113.58' /var/log/auth.log
  4. Stage 3, foothold: a job nobody scheduled

    A guessed password is a fragile way in. Nell changes it, and the intruder is outside again. So the third stage makes the way back in last. The plain name for it is a foothold, and reports also say persistence.

    A machine keeps a list of scheduled jobs: programs it starts by itself at set times. On website each account's jobs are in a file named after the account, in the folder /etc/crontabs.

    List that folder with full dates. Then read the job, and the file the job starts. Nothing here can run: the investigators kept the real file, and the lab left a note in its place.

    website:~# ls -l --full-time /etc/crontabs
    website:~# cat /etc/crontabs/webdesk
    website:~# cat /var/tmp/.site-refresh
  5. Stage 4, privilege escalation: the rule that allowed everything

    So far the intruder is webdesk, an account for changing web pages. An ordinary account can't read other accounts' files or change the machine itself. The administrator account, root, can do all of it. Getting from the first to the second is the fourth stage, privilege escalation.

    On this machine a program named sudo lets an account run one command as the administrator, if a rule allows it. sudo writes each use to the sign-in log, and its rules are files in /etc/sudoers.d.

    Pull the sudo lines from the log. Then read the rule for webdesk.

    website:~# grep 'sudo' /var/log/auth.log
    website:~# cat /etc/sudoers.d/webdesk
  6. Stage 5, lateral movement: one password, two machines

    The book was never on website. The manuscripts are on bookServer, which can't be reached from the internet at all. So the intruder had to go from a machine it held to the machine it wanted. That sideways step is the fifth stage, lateral movement.

    bookServer keeps the same kind of sign-in log. Staff sign in from their desks: Nell from 10.0.9.30, Corin from 10.0.9.31 and Tamar from 10.0.9.32.

    Pull every sign-in that worked, and read where each one came from.

    bookServer:~# grep 'Accepted' /var/log/auth.log
  7. Stage 6, objective: 412 MB at three in the morning

    Five stages in, nothing has been taken. The last stage is the reason for the others, the objective: here, a copy of a book that is not out yet.

    Two machines saw it. bookServer has its file log switched on: it wrote down every folder the session listed (opendir), every file it opened (open), and at each close how many bytes were read. officeRouter keeps a line for each call from the office to the outside: who called whom, and how much was sent.

    Read the 02:00 hour of that night on bookServer. Then read the router's list.

    bookServer:~# grep 'Oct 21 02' /var/log/auth.log
    officeRouter:~# cat /var/log/connections.log

Run these steps on real machines

Keep reading

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab