1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 python312,
6 writableTmpDirAsHomeHook,
7}:
8let
9 python = python312.override {
10 self = python;
11 packageOverrides = self: super: {
12 impacket = super.impacket.overridePythonAttrs {
13 version = "0.12.0-unstable-2025-03-14";
14 src = fetchFromGitHub {
15 owner = "fortra";
16 repo = "impacket";
17 rev = "8b4566b12fc79acb520d045dbae8f13446a9d4d7";
18 hash = "sha256-jyn5qSSAipGYhHm2EROwDHa227mnmW+d+0H0/++i1OY=";
19 };
20 # Fix version to be compliant with Python packaging rules
21 postPatch = ''
22 substituteInPlace setup.py \
23 --replace 'version="{}.{}.{}.{}{}"' 'version="{}.{}.{}"'
24 '';
25 };
26 };
27 };
28in
29python.pkgs.buildPythonApplication rec {
30 pname = "netexec";
31 version = "1.4.0";
32 pyproject = true;
33
34 src = fetchFromGitHub {
35 owner = "Pennyw0rth";
36 repo = "NetExec";
37 tag = "v${version}";
38 hash = "sha256-1yNnnPntJ5aceX3Z8yYAMLv5bSFfCFVp0pgxAySlVfE=";
39 };
40
41 pythonRelaxDeps = true;
42
43 pythonRemoveDeps = [
44 # Fail to detect dev version requirement
45 "neo4j"
46 ];
47
48 postPatch = ''
49 substituteInPlace pyproject.toml \
50 --replace-fail " @ git+https://github.com/fortra/impacket.git" "" \
51 --replace-fail " @ git+https://github.com/wbond/oscrypto" "" \
52 --replace-fail " @ git+https://github.com/Pennyw0rth/NfsClient" ""
53 '';
54
55 build-system = with python.pkgs; [
56 poetry-core
57 poetry-dynamic-versioning
58 ];
59
60 dependencies = with python.pkgs; [
61 jwt
62 aardwolf
63 aioconsole
64 aiosqlite
65 argcomplete
66 asyauth
67 beautifulsoup4
68 bloodhound-py
69 dploot
70 dsinternals
71 impacket
72 lsassy
73 masky
74 minikerberos
75 msgpack
76 msldap
77 neo4j
78 paramiko
79 pyasn1-modules
80 pylnk3
81 pynfsclient
82 pypsrp
83 pypykatz
84 python-dateutil
85 python-libnmap
86 pywerview
87 requests
88 rich
89 sqlalchemy
90 termcolor
91 terminaltables
92 xmltodict
93 ];
94
95 nativeCheckInputs = with python.pkgs; [ pytestCheckHook ] ++ [ writableTmpDirAsHomeHook ];
96
97 # Tests no longer works out-of-box with 1.3.0
98 doCheck = false;
99
100 meta = {
101 description = "Network service exploitation tool (maintained fork of CrackMapExec)";
102 homepage = "https://github.com/Pennyw0rth/NetExec";
103 changelog = "https://github.com/Pennyw0rth/NetExec/releases/tag/v${version}";
104 license = lib.licenses.bsd2;
105 maintainers = with lib.maintainers; [ vncsb ];
106 mainProgram = "nxc";
107 # FIXME: failing fixupPhase:
108 # $ Rewriting #!/nix/store/<hash>-python3-3.11.7/bin/python3.11 to #!/nix/store/<hash>-python3-3.11.7
109 # $ /nix/store/<hash>-wrap-python-hook/nix-support/setup-hook: line 65: 47758 Killed: 9 sed -i "$f" -e "1 s^#!/nix/store/<hash>-python3-3.11.7^#!/nix/store/<hash>-python3-3.11.7^"
110 broken = stdenv.hostPlatform.isDarwin;
111 };
112}