repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
helpers.nixNix67 lines2.8 KiBraw download
# modules/features/pentest/helpers.nix — the small daily-use commands, taken
# from IceBreaker (~/Downloads/IceBreaker-main.zip, scripts/ and home/zsh.nix)
# and rewired to this toolkit's state instead of IceBreaker's ~/targets tree.
#
#   revshell [type] [port]   reverse shell one-liners; LHOST from htbip
#   htbscan [full|udp|ports] nmap passes into $BOXDIR/recon, then htbbox ports
#   hcmode [word|number]     hashcat -m lookup, read from the installed hashcat
#   dmnfuzz <mode>           vhost/dns/dir/auto fuzzing; also `dnsfuzz`
#
# What was NOT taken, and why: newbox/flag/cred/settarget (htbbox already
# does this, with box.json behind it), setproxy (it seds
# proxychains.conf, which is generated by programs.proxychains in pivot.nix),
# ligolo-fetch.sh (payloads.nix builds ligolo from source per arch),
# install-pipx-tools.sh (python.nix pins the same tools declaratively),
# tmux-htb.sh (~/.dotfiles/scripts/htb-layout.sh) and icebreaker-bench (the
# dissertation's benchmark harness, not a tool).
#
# The scripts live in _helpers/ as plain bash so shellcheck (which
# writeShellApplication runs at build time) sees them unescaped. htbip,
# htbbox and sudo are deliberately NOT runtimeInputs: they come from the
# system (vpn.nix, boxes.nix, the setuid wrapper), and a store copy of htbbox
# would read a different $STATE than the one on PATH.
{ lib, ... }:
{
  flake.nixosModules.pentest-helpers =
    { config, pkgs, lib, ... }:
    let
      on = config.daemon.pentest.enable;

      mk = name: runtimeInputs:
        pkgs.writeShellApplication {
          inherit name runtimeInputs;
          text = builtins.readFile ./_helpers/${name}.sh;
        };

      # Same as mk, but lets a script choose its own bash options. dmnfuzz runs
      # WITHOUT errexit: its control flow leans on non-zero returns (ffuf
      # finding nothing, run_vhost failing inside auto mode) that `set -e`
      # would turn into a hard abort mid-scan.
      mkOpts = name: runtimeInputs: bashOptions:
        pkgs.writeShellApplication {
          inherit name runtimeInputs bashOptions;
          text = builtins.readFile ./_helpers/${name}.sh;
        };

      dmnfuzz = mkOpts "dmnfuzz"
        (with pkgs; [ coreutils gnugrep gnused gawk ffuf jq curl dnsx dnsutils ])
        [ "nounset" "pipefail" ];

      helpers = [
        (mk "revshell" (with pkgs; [ coreutils jq gum wl-clipboard glibc.bin ]))
        (mk "htbscan" (with pkgs; [ coreutils gnugrep rustscan nmap ]))
        (mk "hcmode" (with pkgs; [ gnugrep gawk hashcat ]))
        dmnfuzz
        # The name it keeps getting called by.
        (pkgs.runCommand "dnsfuzz" { } ''
          mkdir -p $out/bin
          ln -s ${dmnfuzz}/bin/dmnfuzz $out/bin/dnsfuzz
        '')
      ];
    in
    {
      config = lib.mkIf on {
        environment.systemPackages = helpers;
      };
    };
}