Courses3 levels
Level 1 · Foundations11 courses
Level 2 · Core5 courses
Level 3 · Advanced5 courses
Labs8 topics
Library Practice exams AI Range Pricing Start free

KaliRange / Foundations

Python for security work

Write the small tools that security work needs. From your first script to a log analyser.

12 lessons · about 9 hours · every command tested

How to use the lab files

The zip keeps the files of each lesson apart, and the lessons work in one flat folder. After you unzip it, sh kr-lab.sh LESSON FOLDER builds that folder as it stands after a lesson, for example sh kr-lab.sh 00-set-up-your-lab ~/krlab/python.

You will build

Build a log analyser that flags a brute-force attack

You need

A computer with Linux, macOS, or Windows with WSL. No GPU, no cloud account and no paid tool.

Next course

Networking hands-on

  1. 00Set up your Python labCreate the lab folder and a virtual environment for the courseSet-up15 min
  2. 01Run a Python script and know which Python runs itCheck the Python version and use the interactive prompt30 min
  3. 02Count failed logins with strings, lists and dictionariesCut a log line into fields with string methods40 min
  4. 03Write a rule that sorts log lines into classesChoose between paths with if, elif and else40 min
  5. 04Read logs and write JSON and CSV reportsRead a log file one line at a time, without loading all of it40 min
  6. 05Build a command-line tool that fails in a clear wayCatch and raise exceptions without hiding a failureBuild45 min
  7. 06Call a web API safely with the standard libraryRun a small JSON API on your own machine and call it from Python45 min
  8. 07Install packages and check them before you trust themInstall packages with pip inside a virtual environment and pin their versions45 min
  9. 08Find a burst of failed logins in a time window and pin it with a testParse a log time and compare times in UTC with datetime and timedelta55 min
  10. 09Run another program and fingerprint your evidenceStart another program with subprocess.run and read its output and exit code30 min
  11. 10Build a log analyser that flags a brute-force attackBuild a command-line tool that reads an auth log and counts failed loginsBuild60 min
  12. 11Scenario test - find what matters in a web server logBuild a tool that reads a web server log and a CSV list of bad addressesTest90 min

More practice

Labs and workbooks on the same skills, from the practice library. Do the lessons first.

Work roles

Work roles this course supports

The course helps you to prepare for these roles of the NICE Workforce Framework for Cybersecurity (NIST SP 800-181 Rev. 1). No single course covers a whole role, and KaliRange is not a certification body.

Role names and codes are NIST's (Components 2.2.0, 2026-04-28); the choice of roles is our own reading of the role descriptions. The NICE Framework at NIST has the full description of each role.