Skip to content

Latest commit

 

History

History
142 lines (100 loc) · 7.88 KB

File metadata and controls

142 lines (100 loc) · 7.88 KB

Mini Projects

Sixteen self-contained, runnable Python security tools that turn the course's language and library skills into working scanners, crackers, monitors, and recon utilities.

Part of the [[Readme|Python for Security Professionals]] course.

Overview

This module is the hands-on capstone of the course: each note is a complete mini-project with a fully commented, runnable script (argparse CLI where appropriate), an architecture sketch, a source layout, and improvement ideas. The projects progress from raw sockets to web tooling, cryptography, host monitoring, and OSINT — the same building blocks real security tools are made of. Everything defaults to localhost or authorized targets.

[!warning] Authorized use only Every tool here is for learning and for systems you own or are explicitly authorized to test. Unauthorized scanning, brute-forcing, or access is illegal. Keep all experiments in your own lab.

Learning Objectives

  • Build networking tools directly on socket (TCP/UDP clients, servers, scanners).
  • Automate web reconnaissance with requests and BeautifulSoup.
  • Apply hashlib/secrets to password generation, hashing, and integrity monitoring.
  • Parse and analyze logs with re and collections.Counter to detect brute-force activity.
  • Perform DNS, WHOIS, and subdomain OSINT with dnspython and friends.
  • Structure a small tool: CLI parsing, concurrency, error handling, and clean output.

Prerequisites

  • Modules 1–14 and the [[Practical-Labs/Readme|Practical Labs]] — projects assume the labs are done.
  • A Python 3.9+ interpreter in a virtual environment.
  • A lab environment you control for anything that touches the network.

[!warning] Authorized use only Only run these projects against systems you own or are explicitly authorized to test.

Topics Covered

Networking

  • [[Port-Scanner|Port Scanner]] — threaded TCP connect scanner with an argparse CLI.
  • [[Banner-Grabber|Banner Grabber]] — fingerprint services by their connection banners.
  • [[TCP-Client|TCP Client]] — interactive client for sending data and reading replies.
  • [[TCP-Server|TCP Server]] — threaded echo server used as a safe local target.
  • [[UDP-Scanner|UDP Scanner]] — connectionless scanning and open/filtered inference.

Web

  • [[Web-Crawler|Web Crawler]] — same-domain crawler with requests + BeautifulSoup.
  • [[Directory-Bruteforcer|Directory Bruteforcer]] — wordlist-driven HTTP content discovery.
  • [[API-Client|API Client]] — reusable requests session with auth, retries, and pagination.

Crypto & Passwords

  • [[Password-Generator|Password Generator]] — secrets-based, policy-driven generator.
  • [[Hash-Cracker|Hash Cracker]] — educational dictionary attack with hashlib.
  • [[File-Integrity-Monitor|File Integrity Monitor]] — hash baseline and change detection.

Recon & OSINT

  • [[Whois-Lookup|Whois Lookup]] — domain/IP registration data with a raw-socket fallback.
  • [[DNS-Enumeration|DNS Enumeration]] — A/MX/NS/TXT/SOA record lookups via dnspython.
  • [[Subdomain-Enumerator|Subdomain Enumerator]] — wordlist subdomain discovery over DNS.

Monitoring

  • [[Log-Analyzer|Log Analyzer]] — parse auth/access logs and flag brute-force sources with Counter.
  • [[Network-Inventory-Tool|Network Inventory Tool]] — subnet host discovery plus local inventory with psutil.

Practical Exercises

  • Run [[TCP-Server]] on 127.0.0.1:9000, then reach it with [[TCP-Client]], [[Port-Scanner]], and [[Banner-Grabber]].
  • Generate a hash of your own password and recover it with [[Hash-Cracker]]; then baseline a directory with [[File-Integrity-Monitor]] and detect a change.
  • Serve a local site (python -m http.server), crawl it with [[Web-Crawler]], and discover hidden paths with [[Directory-Bruteforcer]].
  • Enumerate a domain you own end-to-end: [[Whois-Lookup]] → [[DNS-Enumeration]] → [[Subdomain-Enumerator]].

Security Applications

The sixteen projects group into five domains, each mapping to a phase of real assessment work:

Domain Projects Used for
Networking [[Port-Scanner|Port Scanner]] · [[Banner-Grabber|Banner Grabber]] · [[TCP-Client|TCP Client]] · [[TCP-Server|TCP Server]] · [[UDP-Scanner|UDP Scanner]] Service discovery and enumeration
Web [[Web-Crawler|Web Crawler]] · [[Directory-Bruteforcer|Directory Enumerator]] · [[API-Client|API Client]] Attack-surface mapping
Crypto & passwords [[Password-Generator|Password Generator]] · [[Hash-Cracker|Hash Utility/Cracker]] Credential generation and authorized auditing
Recon & OSINT [[Whois-Lookup|WHOIS Lookup]] · [[DNS-Enumeration|DNS Enumeration]] · [[Subdomain-Enumerator|Subdomain Enumerator]] Passive and active reconnaissance
Monitoring [[File-Integrity-Monitor|File Integrity Monitor]] · [[Log-Analyzer|Log Analyzer]] · [[Network-Inventory-Tool|Network Inventory Tool]] Defensive baselining and detection

Each project is a complete tool rather than a snippet: it has a CLI, structured output, error handling, and a test approach — the difference between a script and something a teammate can use.

Common Mistakes

  • Building the whole tool before running anything — follow the implementation plan and get a minimal version working first.
  • Mixing engine and presentation, producing a tool that cannot be reused or given a JSON mode.
  • Skipping error handling — network code fails constantly, and a project without it dies on the first unreachable host.
  • No timeouts, so one unresponsive target hangs the run.
  • Hardcoding targets or credentials in the source instead of taking them from arguments or the environment.
  • Ignoring the Testing section — untested tools produce findings nobody should trust.
  • Scaling up concurrency without adding rate limiting.

Best Practices

  • Follow each project's implementation plan in order; it is sequenced to keep you running code.
  • Separate the engine from the CLI from the first commit.
  • Support both human-readable and JSON output.
  • Set a timeout on every network call and handle failures per target.
  • Enforce an authorization/scope check inside the engine.
  • Write at least one test per project with the network mocked.
  • Attempt one extension idea per project — that is where the design thinking happens.

Review Questions

  1. Which projects require raw-socket or root privileges, and why?
  2. What is the difference between the port scanner project and the corresponding practical lab?
  3. What security issue can occur if a directory enumerator is pointed at a host without authorization?
  4. How would you add JSON output to a project that currently only prints text?
  5. Which project would you extend into a scheduled monitoring service, and what would need to change?

Commands

# Set up an isolated environment for the project dependencies
python -m venv .venv && source .venv/bin/activate
pip install requests beautifulsoup4 dnspython python-whois psutil

# Run a couple of the tools against your own machine / lab
python port_scanner.py 127.0.0.1 -p 1-1024
python fim.py baseline ./myapp --db baseline.json

References

Related Notes

  • [[Socket-Programming-for-Networking]] — the networking foundation for the socket-based tools
  • [[Hashlib-Module]] · [[Argparse-Module]] — library notes these projects build on
  • [[Readme|Python for Security Professionals]]

Navigation

  • Previous: [[Practical-Labs/Readme|Practical Labs]]
  • Home: [[Readme|Course Home]]