All projects

Scripting · log analysis

Python for security: a learning log

Learning Python with security examples, one small tool at a time: log parsing, IP classification and reports, file hashing and integrity checks, HTTP security checks, a VirusTotal client, a link extractor and an asyncio port scanner. Still in progress.

Period
Since October 2026
Status
In progress · public learning repository
Type
Personal project
  • Python 3
  • re
  • ipaddress
  • hashlib · pathlib
  • subprocess
  • requests · ssl
  • BeautifulSoup
  • asyncio

The project

Almost every SOC job post asks for some scripting, so I learn Python with security examples instead of « hello world ». I push everything to a public repository, mistakes included, so the progression stays visible, and I keep adding to it.

What I did, and what went wrong

  • Week 1: fundamentals on ports, IPs and fake login logs, ending with a small brute-force check that counts failed logins per IP.
  • Week 2: command-line tools: ip_report.py extracts IPs from a log, classifies them (private, public, loopback, invalid) and writes TXT, JSON and CSV reports; a TCP scanner limited to localhost.
  • Week 3: file_hasher.py (SHA-256, read in blocks), log_finder.py (every .log file with size and hash), cmd_runner.py (subprocess with error handling), log_parser.py (syslog, kernel, SSH and UFW lines into structured fields, with named regex groups) and url_checker.py (status, six security headers, cookies, redirects, TLS certificate).
  • Week 4: integrity_checker.py (compares files with a reference list of SHA-256 hashes), vt_lookup.py (VirusTotal API for hashes and URLs, key read from an environment variable, pause between calls), web_scraper.py (links of a page with BeautifulSoup) and async_scanner.py (several TCP ports tested in parallel with asyncio).

How I checked it

What I wanted to prove, the test I ran, and what I actually saw.

What I wanted to proveThe testWhat I saw
file_hasher.py computes the right SHA-256Compared with the output of sha256sumSame hash

Limits and next steps

  • Learning exercises, run on synthetic logs and on localhost; the scanners only target 127.0.0.1.

What I would do next

  • Security libraries next: scapy, paramiko, impacket.

Code and documents

  • Repository github.com/AGRO-Rachidi/cybersecurity-python-journey