Skip to main contentSkip to main content
The Red Raffle banner icon.

The Jr Pentester Path just got rebuilt. Complete rooms, earn tickets, and win a free PT1 cert.

Room Banner
Back to all walkthroughs
Room Icon

Python: Building Scripts

Premium room

Acquire the necessary skills to build Python scripts.

easy

60 min

4

User profile photo.
User profile photo.
User profile photo.

To access material, start machines and answer questions login.

In the Python: Core Concepts room, we learned how to work with data types, strings, lists, dictionaries, operators, and loops. We can now store data, inspect it, iterate over it, and make decisions based on conditions. These are the building blocks. In this room, we will learn how to assemble those building blocks into real programs.

Consider the difference between knowing individual musical notes and being able to play a song. In Core Concepts, you learned the notes. In this room, you will play the song.

Specifically, we will cover four capabilities that separate a code snippet from a real script: functions for organizing and reusing logic, error handling for building resilience, file I/O for reading input and writing output, and libraries for leveraging code that others have already written. By the end, we will combine every concept from both rooms into a single, working Password Strength Checker: a tool that evaluates passwords against length requirements, character variety rules, and a common-passwords wordlist.

Learning Objectives

After completing this room, you will:

  • Define and call functions with parameters, return values, and defaults
  • Understand variable scope
  • Handle runtime errors with try/except
  • Read from and write to files using context managers (with)
  • Import modules from the Python standard library
  • Install third-party packages with pip
  • Combine all concepts into a complete, security-relevant program

Prerequisites

It is best if you tackle this room after finishing:

Machine Access

You can follow along by starting the attached virtual machine (VM). Visual Studio Code (VS Code) should open automatically with a modern Python installation ready for you. All example scripts discussed in this room are saved in the /home/ubuntu/Building-Scripts/ directory. We strongly encourage you to run, modify, and experiment with every code snippet on the as you progress through the tasks.

Set up your virtual environment

To successfully complete this room, you'll need to set up your virtual environment. This involves starting the Target Machine, ensuring you're equipped with the necessary tools and access to tackle the challenges ahead.
Target machine
Status:Off
Answer the questions below

Let's build real scripts!