Cyber Security 101 (SEC1) has landed

Build real-world cyber skills with a hands-on certification designed by industry experts.

CertificationCertification
Feature
BLOG • 4 min read

Python for Cybersecurity: A Hands-On Introduction

Python is one of the most powerful skills you can add to your cyber security toolkit, not because it turns you into a software engineer, but because it gives you leverage.

It lets you take messy, real-world security problems and make them manageable.

If you’ve ever looked at a log export and thought “there’s no way I’m reading this manually”, or copied indicators out of an alert and felt like you were doing admin work rather than analysis, you’ve already discovered why Python matters.

This is a hands-on introduction to Python for cyber security, without code. Instead of scripts, we’ll focus on the workflows Python unlocks, the kinds of inputs and outputs you should expect, and the exact ways you can practise this skill so it transfers into SOC, incident response, and security engineering work.


What “hands-on Python” actually means in cyber security

When people say “learn Python”, they often mean learning syntax: variables, loops, functions.

That’s not wrong, but it’s not the point.

Hands-on Python in cyber security means being able to do things like:

  • Take a messy log file and turn it into a clean timeline
  • Extract indicators (IPs, domains, hashes) from raw text quickly
  • Enrich alerts so you can make faster decisions
  • Automate repetitive investigation steps
  • Create small, reusable utilities for your own workflow

You don’t need to build big applications. You need to build little pieces of automation that remove friction.


The 5 workflows Python is most useful for (and how to practise each)

To keep this practical, think in terms of outputs.

If you can produce the output described in each section, you are doing “real Python for cyber security”, even if you don’t feel advanced yet.


1) Log triage: turning noise into a timeline

This is the number one use case for Python in defensive security.

In real SOC work, logs arrive in formats like:

  • Exports from tooling (CSV, JSON)
  • Raw text files
  • Mixed fields
  • Inconsistent timestamps

The job is to find the thread: what happened first, what happened next, and what matters. Python helps you go from a huge text dump to a clean timeline of events filtered by user, IP, action, or time window.

How to practise this (no code required to start):
Take any log export from a lab or training scenario and define what “good triage” would look like:

  • “show me only failed logins”
  • “sort events by timestamp”
  • “group activity by source IP”
  • “flag anything outside business hours”

When you can regularly produce those outputs, you are operating like a SOC analyst, not just learning theory.

If you want a structured place to practise the SOC-style thinking behind this, TryHackMe’s SOC pathway is the best fit.


2) Indicator handling: extracting IOCs fast and accurately

A huge portion of cyber security work is indicator handling.

Someone sends an alert in a ticket. A colleague pastes suspicious domains into Slack. An incident report includes URLs, IPs, file names, and hashes.

You need to extract them cleanly.

Python helps you turn unstructured text into:

  • A clean list of IP addresses
  • A clean list of domains
  • A clean list of URLs
  • Deduplicated and ready for analysis

And this skill matters more than people expect, because speed isn’t just convenience. Speed reduces mistakes and reduces time-to-decision.

How to practise:
Use any scenario content (phishing emails, incident write-ups, sandbox notes) and practise producing a clean output list as if you’re going to hand it to another analyst.

A useful reference for what “good indicators” look like operationally is CISA’s guidance around sharing and handling threat indicators.


3) IOC matching: answering “have we seen this before?”

This is an investigation moment SOC teams hit constantly.

You have a list of IOCs and want to know:

  • Do we see this domain in our logs?
  • Did any endpoints talk to this IP?
  • Does this hash appear in any investigation notes?

Python helps you compare and match:
IOC lists vs logs vs notes

The outcome is a “hit list” you can act on.

And the reason this is so valuable is that it turns uncertain alerts into clearer prioritisation. It’s one thing to receive an IOC. It’s another thing to confirm whether it actually appears inside your environment’s activity.

How to practise:
You can practise this with any lab incident scenario. The aim is simple: take a list of 10 indicators and search across multiple data sources to confirm what is present.


4) Enrichment: making alerts actionable

Enrichment is where analysts become fast.

An alert without context is expensive. It forces decision-making with incomplete information.

Python helps create enrichment workflows such as:

  • Identifying whether an IP is internal or external
  • Normalising hostnames/usernames
  • Attaching timestamps and event counts
  • Tagging likely false positives
  • Grouping multiple alerts into a single storyline

The key is that enrichment reduces alert fatigue because it brings decision-relevant context forward.

You don’t need to be a detection engineer to do this. You can do enrichment in your personal workflow with training scenarios and become noticeably more effective.


5) Automation: reducing repetition without losing judgement

Python automation in cyber security should not replace thinking. It should replace repetition.

If you find yourself doing the same steps repeatedly during investigations, those steps belong in automation.

A strong mindset here is:

  • Automate the boring parts so you can spend time on the interesting ones.
  • That’s the difference between learners who stay stuck and learners who scale their ability.

How to learn Python for cyber security without getting overwhelmed

If you’re a beginner, don’t try to learn “Python” as a full subject first.

Instead, learn Python through security workflows.

Here’s the most practical sequence:

  • First, learn input/output: how to read text and files, how to output a clean result.
  • Then learn parsing: how to extract fields, timestamps, indicators.
  • Then learn logic: how to compare, filter, classify, group.
  • Then learn packaging: how to make your work repeatable.

You don’t need to master everything. You just need to build competence through repetition.


What to avoid (beginner traps)

There are three traps that waste time for new learners:

The first is trying to build “big projects” too early. Real Python value in cyber security is in small utilities.

The second is learning Python in isolation from cyber practice. Python skill without security context doesn’t transfer cleanly.

The third is obsessing over perfection. In SOC work, 80% clarity today beats 100% perfection next week.


Where to practise hands-on Python the right way

The best place to practise Python for cyber security is in labs where:

  • Logs and alerts exist
  • Decisions matter
  • Investigations lead somewhere
  • Outputs can be validated

If your goal is practical security work, especially SOC workflows, start here:

authorNick O'Grady
Jan 29, 2026

Join over 640 organisations upskilling their
workforce with TryHackMe

We use cookies to ensure you get the best user experience. For more information see our cookie policy.