IntroductoryFree5h of content · 1 guided labAudio:ES · EN200 XP

Python for Cybersecurity

Python from zero for people who want to work in security. Every exercise is a real analyst task: read a log, count failed logins, pull the indicators out of a JSON event, decode an obfuscated command. You write and run the code right in the browser — nothing to install. Free, no programming background assumed.

Free forever. No card, no trial, no expiry.

Preview the student experience

No login · Free interactive demo

Try demo →

1

Guided lab

Real VM with HTK Pro

5h

Of content

Videos + labs + practice + exams

5

Modules

Progressive difficulty

2–4h

Per lab session

Unlimited restarts

HackTheKnowledge logoWhat's included
  • The full course: written lessons with diagrams
  • Per-module exams to check what stuck
  • Guided walkthrough of a real phishing email
  • Submit the final assignment
  • Lifetime access, no card required
  • Isolated lab VM and graded certificate: HTK Pro
0 €

No card required

Start free →

In shortPython for Cybersecurity is a free course that teaches Python from zero through real analyst tasks: reading logs, counting events, extracting indicators with regular expressions and hashing samples. The code runs in your browser, so there is nothing to install. Available in English and Spanish with a free account and no card.

Lab tools you will use

Python 3Lab toolreLab tooljsonLab toolPython 3Lab toolreLab tooljsonLab tool
csvLab toolhashlibLab toolbase64Lab toolcsvLab toolhashlibLab toolbase64Lab tool

Before you start — quick answers

The course is free: every lesson, the in-browser exercises, the module quizzes and the flags. You need an account, but no card. Two things are paid: the HTK Python Lab — a full editor with larger datasets and graded challenges — and the instructor review of your final script. Both come with HTK Pro, a subscription you can cancel whenever you like.

No. The course starts from zero: it assumes you have never written a line of code. What it does assume is that you are interested in security, because every example comes from there.

No. The code runs inside your browser, isolated from your computer and from our servers. Any recent browser will do. If you want to install Python on your machine later, the course explains how, but you do not need it to finish.

Yes. Your code runs in an isolated area of the browser with no access to your files or your other tabs, and it cannot connect to other websites. The worst an exercise can do is get stuck, and the environment stops it after a few seconds.

Course Syllabus

5 modules · 5h of content

Each phase maps to a module in this course. Scroll to see how the curriculum builds, module by module.

1

Module 1

Introductory

First steps

  • •What Python is and why analysts use it
  • •Variables and types, explained with the data you will actually handle
  • •print, strings and the methods that clean them up
  • •Exercise: normalise a list of indicators of compromise
  • •Module quiz and flag
2

Module 2

Introductory

Deciding and repeating

  • •if, elif and else: turning a rule into code
  • •Lists and the for loop
  • •while, and how to avoid an infinite loop
  • •Exercise: walk an authentication log line by line
  • •Module quiz and flag
3

Module 3

Introductory

Dictionaries and functions

  • •Dictionaries: counting things by key
  • •Top-N: which IP address tried the most
  • •Functions you can reuse from one case to the next
  • •hashlib: computing the hash of a sample
  • •Module quiz and flag
4

Module 4

Introductory

Files and the standard library

  • •Opening and reading files
  • •csv and json: the formats security tools export
  • •Regular expressions with re to extract IPs, domains and hashes
  • •datetime: putting events in order
  • •Module quiz and flag
5

Module 5

Introductory

Automating the analyst's work

  • •base64 and decoding an obfuscated command
  • •From loose lines of code to a script you can reuse
  • •Good habits: names, comments and errors that explain themselves
  • •Pro: the HTK Python Lab, six challenges with tests on real-size data
  • •Final assignment: a triage script that summarises an incident
  • •Module quiz and flag

What you will learn

  • Write and run Python without installing anything, and read the error when it fails
  • Turn a rule like "more than five failed logins" into an if and a loop
  • Count events by key with a dictionary and find the top offenders
  • Read logs, CSV and JSON files and pull indicators out of them with regular expressions
  • Compute the hash of a sample and decode an obfuscated base64 command
  • Package what you wrote into a script you can reuse on the next case

Hands-on Lab

Every lesson has short exercises you run in the browser and a flag that only comes out if your code is right. The Pro unlock adds the HTK Python Lab: a full editor with several files, larger datasets — thousands of log lines, EDR events in JSON — and six challenges with automatic tests, plus a final triage script that an instructor reviews.

1⬡ 1 guided lab
2–4hSession window
UnlimitedRestarts
AutoFlag validation
Experience a lab preview →

Requirements

  • ·No programming background — the course assumes you have never written code
  • ·A computer with a recent browser. Nothing to install: Python runs inside the browser
  • ·A few free evenings

What's free, and what HTK Pro adds

Our subscriptions give you unlimited access and let you get the most out of every resource on the platform.

Free

Free

To start from zero

0 €

  • The free courses, with every lesson in writing
  • Some videos in each module
  • Module exams, with unlimited attempts
  • Lesson practices and most in-browser labs
  • Daily streak with rewards
Most popular3 months free with yearly

HTK Pro

To complete the track

€14.99€11.24/mo

€134.91 a year, in one payment · 3 months free

🔒 Secure payment · Cancel anytime

Everything in Free, plus…

  • Every new career-track course
  • Video lessons with visual demos: watch it done before you do it
  • Every practice and in-browser lab
  • Capstone cases in the simulator
  • The real-machine lab of the free courses
  • An instructor grades your final assignment: certificate for each course and the track
  • Guide to landing your first job
All inclusive3 months free with yearly

HTK Ultimate

To go beyond the track

€34.99€26.24/mo

€314.91 a year, in one payment · 3 months free

🔒 Secure payment · Cancel anytime

Everything in Pro, plus…

  • Full professional courses, Beginner and Intermediate: Windows Malware and Phishing with OSINT
  • Guided labs on a real, isolated machine, with unlimited resets
  • Capstone cases on a real machine
  • Module exams and HTK certificates for each level
  • An instructor personally reviews your reports and practicals
  • Private Discord community and direct instructor support

Everything you unlock with HTK Pro

No marketing screenshots: each piece, as it actually looks inside. Click a tab or let them play.

Every lesson, as a video tooIncluded in HTK Pro

With HTK Pro, one click turns the lesson into a video explained step by step: the log scrolls, the counter climbs and you get at first sight what takes three reads in text. What you see, you remember.

Module 2 · Logs and authentication

What auth.log records

VideoText

You're reading this lesson. The concepts are the same as in the video.

Every SSH login attempt leaves a line in /var/log/auth.log. When one IP fails hundreds of times in a few minutes it's almost never a typo: it's a brute-force attack.

Nov  7 03:12:41 vpn sshd[2214]: Failed password for invalid user rrhh01 from 203.0.113.45
Nov  7 03:12:42 vpn sshd[2214]: Failed password for invalid user rrhh02 from 203.0.113.45

In this task you'll count failures per IP and decide which one to block.

Chapter 2 · Reading auth.log

Nov 7 03:12:40 vpn sshd[2214]: Failed password for invalid user rrhh01 from 203.0.113.45

Nov 7 03:12:41 vpn sshd[2214]: Failed password for invalid user rrhh02 from 203.0.113.45

Nov 7 03:12:42 vpn sshd[2214]: Failed password for invalid user rrhh03 from 198.51.100.23

Nov 7 03:12:43 vpn sshd[2214]: Failed password for invalid user rrhh04 from 203.0.113.45

Nov 7 03:12:44 vpn sshd[2214]: Failed password for invalid user rrhh05 from 203.0.113.45

Nov 7 03:12:45 vpn sshd[2214]: Failed password for invalid user rrhh06 from 203.0.113.45

Nov 7 03:12:46 vpn sshd[2214]: Failed password for invalid user rrhh07 from 192.0.2.14

Nov 7 03:12:47 vpn sshd[2214]: Failed password for invalid user rrhh08 from 203.0.113.45

Nov 7 03:12:48 vpn sshd[2214]: Failed password for invalid user rrhh09 from 203.0.113.45

Nov 7 03:12:49 vpn sshd[2214]: Failed password for invalid user rrhh01 from 203.0.113.45

Nov 7 03:12:50 vpn sshd[2214]: Failed password for invalid user rrhh02 from 198.51.100.23

Nov 7 03:12:51 vpn sshd[2214]: Failed password for invalid user rrhh03 from 203.0.113.45

Nov 7 03:12:52 vpn sshd[2214]: Failed password for invalid user rrhh04 from 203.0.113.45

Nov 7 03:12:53 vpn sshd[2214]: Failed password for invalid user rrhh05 from 203.0.113.45

Nov 7 03:12:54 vpn sshd[2214]: Failed password for invalid user rrhh06 from 192.0.2.14

Nov 7 03:12:55 vpn sshd[2214]: Failed password for invalid user rrhh07 from 203.0.113.45

203.0.113.45

0

failed attempts

Each line is one SSH login attempt.

1:12 / 6:40CC
  • An instructor grades your final assignment
  • Verifiable certificate for LinkedIn
  • Every free course in full

Work like a real SOC

An alert queue with teammates, statuses and SLAs: you assign the alert, follow the playbook, read the evidence, give the verdict and write the report. This is what it looks like inside.

This is the simulator from the courses, driven by a script: you can pause it and step through it. With a free account you solve it yourself.

Frequently Asked Questions

Complete answers about this course, labs, certificates, and refunds

The course is free: every lesson, the in-browser exercises, the module quizzes and the flags. You need an account, but no card. Two things are paid: the HTK Python Lab — a full editor with larger datasets and graded challenges — and the instructor review of your final script. Both come with HTK Pro, a subscription you can cancel whenever you like.

No. The course starts from zero: it assumes you have never written a line of code. What it does assume is that you are interested in security, because every example comes from there.

No. The code runs inside your browser, isolated from your computer and from our servers. Any recent browser will do. If you want to install Python on your machine later, the course explains how, but you do not need it to finish.

Yes. Your code runs in an isolated area of the browser with no access to your files or your other tabs, and it cannot connect to other websites. The worst an exercise can do is get stuck, and the environment stops it after a few seconds.

Only with HTK Pro. The certificate depends on an instructor reviewing and passing your final triage script, and that review is the paid part. Writing and submitting the script is free.

After this course

Then pick the specialism that fits you

This course exists to help you choose with some basis instead of guessing. Once you know which side of the field appeals to you, each learning path takes you from beginner to intermediate with the labs to match.

Explore learning paths →
Ready to level up?

Start learning cybersecurity today

About 5 h, no prior knowledge, and a real phishing email to take apart. Create an account and begin.

FreeNo card required
No card requiredLifetime accessStart in under a minute