repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
render-readme.pyPython177 lines10.1 KiBraw download
#!/usr/bin/env python3
"""Render local README SVG artwork from the repository's Gruvpine palette.

Run from any directory: python3 scripts/render-readme.py
Requires Python's standard library and Nix; does not build or activate anything.
"""
from html import escape
import json
from pathlib import Path
import subprocess

ROOT = Path(__file__).resolve().parents[1]
OUT = ROOT / 'docs/images'
P = json.loads(subprocess.check_output([
    'nix-instantiate', '--eval', '--strict', '--json', '--expr',
    '(import ./modules/_palette.nix).gruvpine',
], cwd=ROOT, text=True))
FONT = "'DejaVu Sans Mono','Liberation Mono',monospace"


def text(x, y, label, size=16, color='text', **attrs):
    options = ' '.join(f'{k.replace("_", "-")}="{escape(str(v), quote=True)}"' for k, v in attrs.items())
    return f'<text x="{x}" y="{y}" font-size="{size}" fill="{P[color]}" {options}>{escape(label)}</text>'


def rect(x, y, w, h, fill='surface', stroke='hlMed', radius=8):
    return f'<rect x="{x}" y="{y}" width="{w}" height="{h}" rx="{radius}" fill="{P[fill]}" stroke="{P[stroke]}"/>'


def line(x1, y1, x2, y2, color='hlMed', width=1):
    return f'<path d="M{x1} {y1}H{x2}" stroke="{P[color]}" stroke-width="{width}"/>' if y1 == y2 else f'<path d="M{x1} {y1}L{x2} {y2}" fill="none" stroke="{P[color]}" stroke-width="{width}"/>'


def snowflake(x, y, scale=1):
    parts = [f'<g transform="translate({x} {y}) scale({scale})" fill="none" stroke-linecap="square">']
    for i, color in enumerate(['gold', 'pine', 'foam', 'iris', 'rose', 'love']):
        parts.append(f'<path transform="rotate({i * 60})" d="M0 -16V-82M0 -49L-26 -64M0 -49L26 -64" stroke="{P[color]}" stroke-width="9"/>')
    parts.append(f'<path d="M0 -16L14 -8V8L0 16L-14 8V-8Z" stroke="{P["text"]}" stroke-width="3"/></g>')
    return ''.join(parts)


def svg(name, width, height, title, desc, body):
    drawing = '\n'.join(body)
    data = f'''<svg xmlns="http://www.w3.org/2000/svg" width="{width}" height="{height}" viewBox="0 0 {width} {height}" role="img" aria-labelledby="title desc" font-family="{FONT}">
<title id="title">{escape(title)}</title>
<desc id="desc">{escape(desc)}</desc>
<!-- Generated by scripts/render-readme.py; palette: modules/_palette.nix (gruvpine). -->
<rect width="{width}" height="{height}" rx="12" fill="{P['base']}"/>
{drawing}
</svg>
'''
    path = OUT / name
    path.parent.mkdir(parents=True, exist_ok=True)
    path.write_text(data)


def hero():
    body = [rect(1, 1, 1198, 358, 'base', 'hlMed', 12), line(35, 1, 1165, 1, 'gold', 3)]
    for x in range(825, 1170, 24):
        for y in range(48, 286, 24):
            body.append(f'<circle cx="{x}" cy="{y}" r="1" fill="{P["hlMed"]}"/>')
    body += [text(44, 52, 'DECLARATIVE / OFFENSIVE SECURITY', 14, 'gold', letter_spacing=2),
             text(40, 143, 'NIXDAEMON', 78, 'text', font_weight=700, letter_spacing=-3),
             text(45, 186, 'A workstation you can read, rebuild, and make your own.', 17, 'subtle'),
             text(45, 216, 'NixOS · Niri + Noctalia · nvf · the HTB workflow', 17, 'foam'),
             line(45, 250, 760, 250), snowflake(1006, 156, 1.15),
             text(1006, 282, 'GRUVPINE', 13, 'gold', text_anchor='middle', letter_spacing=4)]
    for x, label, value, color in [(45, '01 FLAKE', 'shared toolkit', 'gold'), (298, '23 CATEGORIES', 'choose your loadout', 'pine'), (570, '02 HOSTS', 'explicit boundaries', 'iris')]:
        body += [text(x, 292, label, 15, color, font_weight=700), text(x, 320, value, 13, 'subtle')]
    svg('nixdaemon-hero.svg', 1200, 360, 'NixDaemon — a declarative security workstation',
        'Gruvpine charcoal and cream, with gold, sage, rose and lilac accents. One flake, 23 toolkit categories, two separate host configurations.', body)


HEADERS = [
    ('00-what-is-this', '//', 'WHAT IS NIXDAEMON?', 'OVERVIEW', 'foam'),
    ('01-payload-manifest', '00', 'THE WORKSTATION', 'PAYLOAD MANIFEST', 'gold'),
    ('02-system-requirements', '01', 'CHOOSE YOUR MACHINE', 'SYSTEM REQUIREMENTS', 'pine'),
    ('03-installation', '02', 'INSTALLATION', 'START WITH YOUR HOST', 'gold'),
    ('04-daily-ops', '03', 'DAILY OPERATIONS', 'BUILD / WORK / RECORD', 'foam'),
    ('05-arsenal', '04', 'THE ARSENAL', '23 CATEGORIES / ONE SWITCH EACH', 'love'),
    ('06-adding-removing', '05', 'MAKE IT YOURS', 'PACKAGES & MODULES', 'iris'),
    ('07-architecture', '06', 'HOW IT FITS TOGETHER', 'DENDRITIC ARCHITECTURE', 'pine'),
    ('08-when-things-break', '07', 'WHEN THINGS BREAK', 'DIAGNOSE / RECOVER', 'rose'),
    ('09-documentation', '08', 'KEEP THE MAP CLOSE', 'DOCUMENTATION', 'foam'),
    ('10-lineage', '09', 'FROM ICEBREAKER', 'LINEAGE', 'iris'),
    ('11-theme', '10', 'GRUVPINE, THROUGHOUT', 'THEME & ARTWORK', 'gold'),
]


def headers():
    for name, number, title, eyebrow, color in HEADERS:
        body = [rect(1, 1, 1198, 88, 'surface', 'hlMed'),
                line(1, 89, 1199, 89, color, 2),
                text(28, 58, number, 27, color), line(91, 18, 91, 71),
                text(118, 29, eyebrow, 11, 'subtle', letter_spacing=2),
                text(117, 62, title, 25, 'text', font_weight=700),
                snowflake(1144, 44, .32)]
        svg(f'headers/{name}.svg', 1200, 90, title, f'{eyebrow}. Section {number}.', body)
    for name, color in [('phosphor', 'pine'), ('rose', 'rose')]:
        body = [line(0, 16, 548, 16), line(652, 16, 1200, 16)]
        for x, c in [(574, color), (600, 'gold'), (626, color)]:
            body.append(f'<path d="M{x} 11L{x+5} 16L{x} 21L{x-5} 16Z" fill="{P[c]}"/>')
        svg(f'dividers/{name}.svg', 1200, 32, 'Gruvpine section divider', 'Decorative rule with three small diamonds.', body)


def flow():
    body = [rect(1, 1, 1198, 305, 'base', 'hlMed'),
            text(30, 36, 'A NEW MACHINE, FROM CONFIGURATION TO FIRST BOOT', 16, 'gold', font_weight=700),
            text(30, 65, 'Generic installations only. Existing machines keep their verified host and accounts.', 13, 'subtle')]
    steps = [
        ('01 / CHECK OUT', 'NixDaemon', ['Read the install guide', 'Choose bare metal or VM'], 'foam'),
        ('02 / CONFIGURE', '_settings.nix', ['User, hardware, desktop', '+ generated hardware file'], 'iris'),
        ('03 / BUILD', 'nixos-install', ['Use the generic host', '.#nixdaemon'], 'gold'),
        ('04 / START', 'Your workstation', ['Boot, set your password', 'Choose a lab or project'], 'pine'),
    ]
    for i, (label, title, notes, color) in enumerate(steps):
        x = 30 + i * 295
        body += [rect(x, 91, 255, 150), text(x+18, 120, label, 12, color),
                 text(x+18, 156, title, 20, 'text', font_weight=700),
                 text(x+18, 190, notes[0], 12, 'subtle'), text(x+18, 215, notes[1], 12, 'subtle')]
        if i < 3:
            body += [line(x+263, 166, x+283, 166, 'gold', 2), f'<path d="M{x+278} 161L{x+283} 166L{x+278} 171" fill="none" stroke="{P["gold"]}" stroke-width="2"/>']
    body += [text(30, 281, 'Personal laptop: nixos / daemonsec. Generic template: nixdaemon / operator (customise before installing).', 12, 'rose')]
    svg('jack-in-flow.svg', 1200, 306, 'Generic installation flow',
        'Check out the flake, configure your user and hardware, install the generic host, then boot. The personal laptop is a separate host.', body)


CATEGORIES = [
    ('RECON', 'nmap · rustscan · dnsx', 'Host and service discovery', 'foam'),
    ('ACTIVE DIRECTORY', 'netexec · certipy · bloodyAD', 'Kerberos, LDAP, SMB, ADCS', 'love'),
    ('WEB', 'ffuf · feroxbuster · sqlmap', 'Fuzzing, proxies, injection', 'pine'),
    ('PIVOT', 'ligolo-ng · chisel · sshuttle', 'Tunnels and port forwarding', 'iris'),
    ('CRACK', 'hashcat · john · hydra', 'Hashes and password testing', 'gold'),
    ('SHELLS', 'metasploit · pwncat · rlwrap', 'Listeners and file transfer', 'rose'),
    ('CORE', 'ncat · socat · smbclient', 'The protocol primitives', 'foam'),
    ('PYTHON', 'impacket · pypykatz', 'One pinned Python environment', 'pine'),
    ('BLOODHOUND', 'BloodHound CE', 'Graph analysis · x86_64', 'love'),
    ('GUI', 'Burp · ZAP · Wireshark', 'Desktop assessment tools', 'iris'),
    ('PAYLOADS', 'PEASS · mimikatz · agents', 'Pinned, organised, cross-built', 'gold'),
    ('WORDLISTS', 'SecLists · rockyou · exploitdb', 'Searchable local references', 'rose'),
]


def arsenal():
    body = [rect(1, 1, 1198, 757, 'base', 'hlMed'),
            text(30, 39, 'THE DEFAULT LOADOUT', 21, 'text', font_weight=700),
            text(30, 70, '12 categories enabled by default on x86_64 · each can be configured independently', 14, 'subtle')]
    for i, (title, tools, desc, color) in enumerate(CATEGORIES):
        x, y = 30 + (i % 3) * 390, 98 + (i // 3) * 126
        body += [rect(x, y, 360, 106), line(x+1, y+13, x+1, y+93, color, 3),
                 text(x+19, y+29, title, 16, color, font_weight=700),
                 text(x+19, y+58, tools, 14, 'text'), text(x+19, y+85, desc, 12, 'subtle')]
    body += [line(30, 618, 1170, 618), text(30, 648, '11 MORE, WHEN YOU NEED THEM', 16, 'gold', font_weight=700),
             text(30, 680, 'DFIR / REVERSING / WIRELESS / RADIO / HARDWARE / C2', 15, 'text'),
             text(30, 709, 'DATABASE / CLOUD / OSINT / SOCIAL / MOBILE', 15, 'text'),
             text(30, 737, 'Enable in _settings.nix · BloodHound is disabled on ARM; mobile is x86_64-only.', 12, 'subtle')]
    svg('arsenal-map.svg', 1200, 758, 'NixDaemon toolkit categories',
        'Twelve default categories and eleven optional categories. Full category names and module switches are listed in the README.', body)


def palette():
    body = [text(30, 34, 'GRUVPINE / THE SHARED PALETTE', 15, 'text', font_weight=700)]
    colors = [('base', 'CHARCOAL'), ('text', 'CREAM'), ('gold', 'GOLD'), ('pine', 'SAGE'), ('love', 'LOVE'), ('rose', 'ROSE'), ('foam', 'FOAM'), ('iris', 'IRIS')]
    for i, (key, name) in enumerate(colors):
        x = 30 + i * 146
        body += [rect(x, 55, 118, 50, key, 'hlHigh', 5), text(x, 132, name, 12, 'text'), text(x, 154, P[key].upper(), 11, 'subtle')]
    svg('gruvpine-palette.svg', 1200, 179, 'Gruvpine colour palette',
        ', '.join(f'{name.lower()} {P[key]}' for key, name in colors), body)


if __name__ == '__main__':
    hero()
    headers()
    flow()
    arsenal()
    palette()
    print('Rendered 18 Gruvpine SVGs in docs/images.')