
~/roadmaps/foundations
Python for Security
Scripting for recon, automation, and tooling.
Loading graph…
Python for Security Roadmap: step-by-step
18 steps in order. Open any step in the map above to track progress and take notes.
Orientation
1.Start here
Start· Beginner· ~0.5h
Python is the most useful language for security work: automating tasks, parsing logs, talking to APIs and building small tools. This roadmap assumes basic programming but no Python experience.
- Install Python 3
- Choose an editor such as VS Code
- Plan your study time
Core skills
2.Python syntax refresh
Concept· Beginner· ~2h
Learn Python's essentials: variables, data types, lists, dictionaries, loops, functions and error handling.
- Use core data types and control flow
- Write functions
- Handle exceptions
Tools & tech: Programming
3.Virtual environments
Concept· Beginner· ~3h
Virtual environments isolate each project's dependencies so tools don't break each other.
- Create and activate a venv
- Install packages with pip
- Record dependencies in requirements.txt
Tools & tech: Programming
4.HTTP with requests
Concept· Beginner· ~4h
The requests library makes calling web APIs and websites simple — essential for automation.
- Send GET and POST requests
- Handle headers, JSON and errors
- Use timeouts and TLS verification
Tools & tech: Programming
5.Parsing JSON and YAML
Tool· Beginner· ~2h
Security tools often output JSON or YAML. Parsing them lets you filter, transform and report data.
- Load and write JSON
- Navigate nested structures
- Validate input before using it
Tools & tech: Programming
6.Regex for logs
Lab· Beginner· ~3h
Regular expressions extract structured data from unstructured log lines.
- Write and test regular expressions
- Use capture groups
- Avoid overly greedy patterns
Tools & tech: Programming
7.CLI tools with argparse
Concept· Beginner· ~4h
argparse turns scripts into proper command-line tools with options and help text.
- Define arguments and options
- Provide help and defaults
- Validate input
Tools & tech: Programming
8.Working with files and paths
Concept· Beginner· ~2h
pathlib makes file handling safe and portable across operating systems.
- Read and write files safely
- Walk directories
- Handle encodings
Tools & tech: Programming
9.Subprocess and system calls
Tool· Beginner· ~3h
subprocess runs other programs from Python. Passing arguments as a list avoids shell injection.
- Run commands with subprocess.run
- Capture output and errors
- Avoid shell=True with untrusted input
Tools & tech: Programming
Advanced practice
10.Socket basics
Concept· Beginner· ~4h
Sockets are the foundation of network programming — every client and server uses them.
- Create TCP client and server sockets
- Send and receive data
- Handle timeouts
Tools & tech: Programming
11.Building a simple TCP port checker
Lab· Beginner· ~2h
Checking which ports are open on your own systems is a classic networking exercise that teaches sockets, timeouts and concurrency. Only scan systems you own or are authorized to test.
- Check TCP connectivity with timeouts
- Add concurrency safely
- Report results clearly
Tools & tech: Programming
12.Parsing PCAP metadata
Concept· Beginner· ~3h
Scapy and similar libraries read packet captures so you can extract hosts, protocols and statistics programmatically.
- Read PCAP files with Scapy
- Extract hosts, ports and protocols
- Summarize traffic
Tools & tech: Programming
13.Writing clients for security tool APIs
Tool· Beginner· ~4h
Most security tools (SIEMs, scanners, ticketing) have REST APIs. Small Python clients automate lookups and reporting.
- Authenticate to APIs securely
- Handle pagination and rate limits
- Keep API keys out of code
Tools & tech: Programming
14.Packaging a small utility
Concept· Beginner· ~2h
Packaging turns a script into an installable tool you can share and version.
- Structure a project
- Write pyproject.toml
- Build and install a package
Tools & tech: Programming
15.Testing scripts
Concept· Beginner· ~3h
Tests catch mistakes before your tool gives wrong results during an investigation.
- Write unit tests with pytest
- Test edge cases
- Run tests automatically
Tools & tech: Programming
16.Secure coding habits
Lab· Beginner· ~4h
Security tools must be secure too: validate input, avoid injection, handle secrets carefully and scan your code.
- Validate and sanitize input
- Avoid unsafe functions (eval, shell=True, pickle on untrusted data)
- Scan code with Bandit
Tools & tech: Programming
Assessment
17.Skills checkpoint
Checkpoint· Beginner· ~2h
Check that you can build, test and package a small, secure security tool in Python.
- Parse data and call APIs
- Build a CLI tool
- Test and scan your code
Capstone
18.Python for Security — ready
Finish· Beginner· ~1h
You can now automate security tasks with Python. Continue with Detection Engineering, Log Analysis or Git & Collaboration.
- Keep your tools in Git
- Choose your next roadmap
- Share a tool you built
Continue learning
Related roadmaps
Linux Administrator Roadmap
Shells to systemd, hardening, and troubleshooting.
Network Administrator Roadmap
TCP/IP, routing, switching, and network troubleshooting.
Database Administrator Roadmap
PostgreSQL and MySQL ops, replication, and backup.
Git and Collaboration Roadmap
Version control hygiene for security teams.
All roadmaps
Browse every CyberA4U learning path