# modules/features/pentest/python.nix — one interpreter with every offensive # library importable, plus impacket's 70 example scripts reachable by name. { lib, ... }: (import ./_sets.nix { inherit lib; }) { name = "python"; description = "offensive python: impacket, certipy, pypykatz and friends"; packages = pkgs: let inherit (import ./_impacket.nix { inherit lib pkgs; }) impacket aliases; # Libraries, for importing. Applications are NOT installed from this env: # python3.withPackages links every package's console scripts into the # env's bin/, so an app that is ALSO installed standalone (certipy in # ad.nix, bloodhound-py, pypykatz…) gives two store paths owning one # name, which is a profile collision that stops the system building. # checks.pentest-collisions found exactly that, twice. env = pkgs.python3.withPackages (ps: with ps; [ impacket certipy dploot masky ldapdomaindump pypykatz bloodyad lsassy minikerberos aiowinreg dnspython scapy pwntools pycryptodomex requests rich aiosmtpd # Snoopy: pentest-python -m aiosmtpd paramiko # Snoopy's Python SSH honeypot pycryptodome # Crypto namespace, distinct from Cryptodome above pyasn1 ldap3 ]); # Spec C2's discovery command: `impacket` alone lists the 70 scripts # (through fzf when there is a terminal), `impacket ` runs one. # Tab-completing `impacket-` does most of this already, but this is the # entry point when you cannot remember whether it is GetUserSPNs or # getuserspns. impacket-cmd = pkgs.writeShellScriptBin "impacket" '' set -uo pipefail names() { ${pkgs.coreutils}/bin/ls -1 ${aliases}/bin \ | ${pkgs.gnugrep}/bin/grep '^impacket-' \ | ${pkgs.gnused}/bin/sed 's/^impacket-//' \ | ${pkgs.coreutils}/bin/sort } case "''${1:-}" in -l|--list) names; exit 0 ;; -h|--help) echo "usage: impacket [