repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
hardware.nixNix62 lines2.0 KiBraw download
# modules/features/pentest/hardware.nix — the physical layer: flashing chips,
# talking to a UART, driving JTAG/SWD, sniffing a logic bus, CAN.
# Off by default. `daemon.pentest.hardware.enable = true;`
#
# This is the "you have the device open on the bench" category. Firmware
# extraction (binwalk) lives in dfir.nix and the disassembly of what you pull
# off the chip lives in reversing.nix — this is only the part that moves bytes
# on and off hardware.
{ lib, ... }:
(import ./_sets.nix { inherit lib; }) {
  name = "hardware";
  description = "firmware flashing, UART/JTAG, logic analysers and CAN";
  default = false;

  packages = pkgs: with pkgs; [
    # Flashing and dumping
    flashrom # SPI flash, in-circuit or on a programmer
    esptool # ESP8266/ESP32: esptool, espefuse, espsecure
    avrdude
    dfu-util # anything speaking USB DFU
    stlink # st-flash, st-info — ST-Link probes

    # Debug ports
    openocd # JTAG/SWD, the generic answer

    # Serial
    minicom
    picocom

    # Logic analysis
    sigrok-cli
    pulseview # the GUI for the same capture

    # Vehicle and industrial buses
    can-utils # candump, cansend, cangen, isotpdump, …
  ];

  expectedBins = [
    "flashrom" "esptool" "espefuse" "avrdude" "dfu-util" "st-flash" "st-info"
    "openocd"
    "minicom" "picocom"
    "sigrok-cli" "pulseview"
    "candump" "cansend" "cangen"
  ];

  extraConfig = { pkgs, lib, user, ... }: {
    # Probes and programmers are USB devices; without their rules you are
    # running every one of the above as root.
    services.udev.packages = with pkgs; [
      openocd
      stlink
      sigrok-cli
    ];

    # A USB serial adapter appears as /dev/ttyUSB* owned by group `dialout`,
    # so without this `picocom /dev/ttyUSB0` needs sudo. The host's user is in
    # networkmanager and wheel only, so the membership is granted HERE and goes
    # away with the category. `dialout` already exists in NixOS, so only the
    # membership is added.
    users.users.${user}.extraGroups = [ "dialout" ];
  };
}