Skip to content
hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets
  • Understanding the ss Command: A Modern Alternative to netstat

    2025-11-01

    The ss command (short for socket statistics) is a fast, feature-rich replacement for the older netstat utility. It allows administrators to inspect and manage network sockets on a system — whether they’re TCP, UDP, RAW, or UNIX domain sockets. Compared to netstat, ss runs faster and provides more filtering options, making it invaluable for network diagnostics and system monitoring.

    Show All TCP, UDP, RAW, and UNIX Sockets

    ss -a -t -u -w -x
    

    Motivation: Network administrators often need a complete snapshot of all active sockets — to check which services are listening, what connections are established, or to detect unusual activity.

  • Understanding HTTP from Scratch with Python Sockets

    2025-11-01

    Most Python developers reach for requests when working with HTTP — and for good reason. It’s convenient, safe, and hides all the messy details of networking. But hiding those details also hides how the web actually works.

    Under the surface, every HTTP transaction is just plain text sent over a TCP socket. Understanding what happens at that level gives you insight into how browsers, APIs, and servers communicate. It also helps you debug connection issues, craft custom clients, or even build HTTP servers yourself.

  • When Environment Variables Mysteriously Reset...

    2025-07-08

    Ran into a frustrating issue recently where a custom environment variable kept resetting itself every time a system rebooted. I wasn’t sure what was causing this I was notified that the team had changed all necassary items to correct this but it kept occurring. After some digging it turns out it was being overwritten by a GPO startup script.

    How did I find it? PowerShell, of course:

    Get-ChildItem -Path "\\domain.name\SYSVOL\domain.name\Scripts" -Recurse -File | Select-String -Pattern "MY_ENV_VAR"
    

    I searched the SYSVOL scripts directory on the domain controller, and sure enough, one of the logon scripts was setting the variable back to a default value.

  • How to Generate a 32-byte Key for AES Encryption

    2025-01-21

    Generating a 32-byte key for AES encryption from a password using only built-in Python modules. To do this we’ll use the hashlib library. For this approach we’ll use the PBKDF2 (Password-Based Key Derivation Function 2) via hashlib.pbkdf2_hmac. This ensures that the key is securely derived from the password.

    Here’s some example code:

    import os
    import hashlib
    
    def generate_aes_key(password: str, salt: bytes = None, iterations: int = 100_000) -> bytes:
        """
        Generate a 32-byte AES key from a password using PBKDF2-HMAC-SHA256.
    
        :param password: The password to derive the key from.
        :param salt: A unique salt (16 bytes recommended). If None, a random salt will be generated.
        :param iterations: The number of iterations for the key derivation function.
        :return: A tuple containing the derived key and the salt used.
        """
        if salt is None:
            salt = os.urandom(16)  # Generate a random 16-byte salt if not provided
    
        # Use PBKDF2 with HMAC-SHA256 to derive the key
        key = hashlib.pbkdf2_hmac('sha256', password.encode(), salt, iterations, dklen=32)
        return key, salt
    
    # Example usage
    password = "securepassword"
    key, salt = generate_aes_key(password)
    
    print("Derived Key (hex):", key.hex())
    print("Salt (hex):", salt.hex())
    

    I preferred to use this approach to avoid any external dependencies.

  • Streamlining Deployment: Installing Docker, Gitea, Gitea Act Runner, and Nginx on Ubuntu

    2024-06-11

    Learn how to setup a robust source control system with CI/CD to deploy your applications on Ubuntu. This post will guide you through the process of installing Docker, Gitea, Gitea Act Runner, and Nginx on Ubuntu, empowering you to streamline your deployment workflow and enhance your server capabilities.

    Installing Docker on Ubuntu

    Docker provides a powerful platform for containerizing applications and simplifying deployment across different environments. To install Docker on Ubuntu, follow these steps:

  • How to Filter HTML Table By Multiple Columns

    2024-06-07

    TL;DR: The full code is available at the bottom of this post.

    Let’s walk through building the whole page starting with the HTML.

    HTML Structure:

    First we’ll create a text input field that will be used to accept input to search on. We’ll also give it an id attribute set to "myInput", which is used to identify it in JavaScript later on.

    <input type="text" id="myInput">
    

    Next let’s add a table and add an id attribute set to "myTable", which will also be used to identify it in JavaScript later.

  • Using a Kubernetes Configmap in a Pod

    2024-02-12

    A ConfigMap is provided as a way to inject configuration data into a pod/pods. It can be included as files or be used as environment variables. Below are a couple of examples of mounting a configmap using both methods.

    Use as File

    In this first example I’ll show how to create a configmap and mount it using the key(s) as filenames and the data as the file content. It will then be used in an Nginx container as the index page.

  • CentOS 9 Automated KVM Install Using Kickstart

    2023-12-15

    A quick demo using virt-install and Kickstart to provision a new CentOS 9 virtual machine. This uses KVM (Kernel Virtual Machine) and libvirt to manage the VM. And uses Kickstart to setup and install the new system within the virtual machine.

    Creating kickstart file

    I’m going to post my Kickstart file on GitHub as a reference. It installs a headless server with some system admin tools, sets up networking, SELinux, and uses autopart to partition the disk with LVM support. This also assumes that you have setup a Bridge Network that is shared to KVM so the local network can be used instead of the libvirt network.

  • Ansible - Please add this host's fingerprint to your known_hosts file to manage this host

    2023-12-15

    If you’ve ever tried to run an ansible playbook and recieved Please add this host's fingerprint to your known_hosts file to manage this host you’re not alone. Here’s a couple of ways to fix it.

    Turn off host key checking

    This would not be the preferred method but turning off host key checking will enable ansible to continue on with the playbook.

    Either modify the /etc/ansible/ansible.cfg or create an ansible.cfg file in the project directory and add the following lines to it:

  • Install and Configure Embedded Python on Windows

    2023-12-09

    I wanted to document these steps after downloading embedded Python recently. I extracted it, set the environment path and started the interpreter. Everything seemed to be going smoothly until I tried to exit exit() and it reported back ’exit not found’ or something like that. What!? How can this be? I ended up import sys and using sys.exit() but this sent me on an adventure to determine how to use embedded Python as a regular install.

  • ««
  • «
  • 1
  • 2
  • 3
  • 4
  • »
  • »»
Recent posts
  • Understanding the ss Command: A Modern Alternative to netstat
  • Understanding HTTP from Scratch with Python Sockets
  • When Environment Variables Mysteriously Reset...
  • How to Generate a 32-byte Key for AES Encryption
  • Streamlining Deployment: Installing Docker, Gitea, Gitea Act Runner, and Nginx on Ubuntu
© 2025 hakk
  • Home
  • Blog
  • Docs
  • DSA
  • Snippets