repositories

NixDaemon

NixOS pentest workstation as one flake — IceBreaker's successor

clonegit clone https://git.daemon-sec.xyz/NixDaemon.git
wine.nixNix71 lines3.5 KiBraw download
# modules/features/pentest/wine.nix — running Windows .NET tooling on Linux.
# Off by default. `daemon.pentest.wine.enable = true;`
#
# Off because wineWowPackages is a multi-gigabyte closure and most boxes never
# need it. The two things that do are worth knowing about:
#
#   ysoserial.net   $ysoserial/ysoserial.exe (payloads.nix stages it; paths.nix
#                   links it at ~/pentesting/web). It is a .NET *Framework*
#                   binary — mscorlib and the Windows GAC, not modern
#                   cross-platform .NET — so there is no native Linux build and
#                   no `dotnet run` path. HTB Pov is the usual first encounter.
#   SharpCollection the prebuilt Rubeus/Seatbelt/Certify family in
#                   ~/pentesting/sharpcollection, for the rare case of wanting
#                   `--help` from one without a Windows box to hand.
#
# A Wow build and not plain `wine`: ysoserial.exe really is a 32-bit PE
# (`file` says `PE32 executable ... Intel 80386`), and a 64-bit-only wine
# refuses it outright with `Bad EXE format`.
#
# `wineWow64Packages` and not `wineWowPackages`: nixpkgs deprecated the latter
# ("no longer preferred by upstream"), and on this pin it warns on every
# evaluation. The new-WoW64 build is a single 64-bit wine that runs 32-bit PEs
# without a multilib 32-bit build beside it. If a 32-bit binary misbehaves
# under it in a way that looks like a WoW64 bug rather than a missing Framework
# API, the old multilib build is still there as `wineWowPackages.stable` — it
# costs an eval warning, which is why it is not the default here.
#
# Two honest limits, so this is not mistaken for a Windows box:
#
#   1. Generators are fine, clients are not. A tool that only *emits a string*
#      (ysoserial) works, because the payload is bound to the target's keys and
#      request path, not to the host that built it. A tool that must talk to a
#      live Windows service (Rubeus asking a KDC for tickets) is unreliable
#      under wine — run those on a Windows VM or on the target itself.
#   2. Some gadget chains still fail with an mscorlib stack trace, because wine
#      does not implement the Framework internals they touch. Rotate the `-g`
#      gadget before concluding the keys are wrong.
#
# mono is here as the second string: it is closer to a real .NET runtime than
# wine for some binaries, and needs no prefix. Try `mono ysoserial.exe` when
# `wine ysoserial.exe` throws.
#
# No rebuild needed to use this once:  nix develop ~/NixDaemon#pentest-wine
{ lib, ... }:
(import ./_sets.nix { inherit lib; }) {
  name = "wine";
  description = "running Windows .NET tooling on Linux: wine, mono";
  default = false;

  packages = pkgs: with pkgs; [
    wineWow64Packages.stable # `wine`, `wine64`, `wineboot`, `wineserver`
    winetricks
    mono # `mono`, for the binaries wine chokes on
  ];

  # Only the binaries that are certainly the package's own entry points. The
  # smoke test runs `command -v`, so a wrong name here is a build failure on
  # every switch, not a warning.
  expectedBins = [ "wine" "wineserver" "winetricks" "mono" ];

  extraConfig = _: {
    # Keep the prefix out of ~/.wine, which winetricks and any gaming wine
    # would also claim. A per-toolkit prefix is disposable: `rm -rf` it and the
    # next `wineboot --init` rebuilds it.
    environment.sessionVariables = {
      WINEPREFIX = "$HOME/.wine-offsec";
      # wine's fixme: stream is a firehose that buries the tool's own output.
      WINEDEBUG = "-all";
    };
  };
}