From ebf06389432aad9fffbb76143666428699ce4129 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 9 Jan 2024 18:12:39 +0000 Subject: [PATCH 1/8] netexec: remove unnecessary package override --- pkgs/tools/security/netexec/default.nix | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index d5925365a87a..999d769e2b59 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -16,11 +16,6 @@ let hash = "sha256-Jozn4lKAnLQ2I53+bx0mFY++OH5P4KyqVmrS5XJUY3E="; }; }; - bloodhound-py = super.bloodhound-py.overridePythonAttrs (old: { - propagatedBuildInputs = - lib.lists.remove super.impacket old.propagatedBuildInputs - ++ [ self.impacket ]; - }); }; }; From cf50dc9229080ae17bfefe5334dd21e3ebdb0548 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 9 Jan 2024 18:45:26 +0000 Subject: [PATCH 2/8] python3Packages.dploot: init at 2.2.4 --- .../python-modules/dploot/default.nix | 48 +++++++++++++++++++ pkgs/tools/security/netexec/default.nix | 19 -------- pkgs/top-level/python-packages.nix | 2 + 3 files changed, 50 insertions(+), 19 deletions(-) create mode 100644 pkgs/development/python-modules/dploot/default.nix diff --git a/pkgs/development/python-modules/dploot/default.nix b/pkgs/development/python-modules/dploot/default.nix new file mode 100644 index 000000000000..6b6dc6454cb6 --- /dev/null +++ b/pkgs/development/python-modules/dploot/default.nix @@ -0,0 +1,48 @@ +{ lib +, buildPythonPackage +, poetry-core +, pythonRelaxDepsHook +, fetchPypi +, impacket +, cryptography +, pyasn1 +, lxml +}: + +buildPythonPackage rec { + pname = "dploot"; + version = "2.2.4"; + pyproject = true; + + src = fetchPypi { + inherit pname version; + hash = "sha256-40/5KOlEFvPL9ohCfR3kqoikpKFfJO22MToq3GhamKM="; + }; + + pythonRelaxDeps = true; + + nativeBuildInputs = [ + poetry-core + pythonRelaxDepsHook + ]; + + propagatedBuildInputs = [ + impacket + cryptography + pyasn1 + lxml + ]; + + pythonImportsCheck = [ "dploot" ]; + + # No tests + doCheck = false; + + meta = { + homepage = "https://github.com/zblurx/dploot"; + description = "DPAPI looting remotely in Python"; + changelog = "https://github.com/zblurx/dploot/releases/tag/${version}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ vncsb ]; + }; +} diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index 999d769e2b59..2e1394143d63 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -58,25 +58,6 @@ let }; }; - dploot = buildPythonPackage rec { - pname = "dploot"; - version = "2.2.4"; - pyproject = true; - src = fetchPypi { - inherit pname version; - hash = "sha256-40/5KOlEFvPL9ohCfR3kqoikpKFfJO22MToq3GhamKM="; - }; - nativeBuildInputs = with python.pkgs; [ - poetry-core - ]; - propagatedBuildInputs = with python.pkgs; [ - impacket - cryptography - pyasn1 - lxml - ]; - }; - resource = buildPythonPackage rec { pname = "resource"; version = "0.2.1"; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 4177ee78eb41..e43bcc7954a1 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3388,6 +3388,8 @@ self: super: with self; { dpkt = callPackage ../development/python-modules/dpkt { }; + dploot = callPackage ../development/python-modules/dploot { }; + draftjs-exporter = callPackage ../development/python-modules/draftjs-exporter { }; dragonfly = callPackage ../development/python-modules/dragonfly { }; From 9f13a17f17886812c62d5418c323d0c3f1fea151 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 9 Jan 2024 19:00:47 +0000 Subject: [PATCH 3/8] netexec: fix test by using pytestCheckHook --- pkgs/tools/security/netexec/default.nix | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index 2e1394143d63..73599e8f88d1 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -78,7 +78,6 @@ python.pkgs.buildPythonApplication rec { pname = "netexec"; version = "1.1.0"; pyproject = true; - doCheck = true; pythonRelaxDeps = true; src = fetchFromGitHub { @@ -88,6 +87,14 @@ python.pkgs.buildPythonApplication rec { hash = "sha256-cNkZoIdfrKs5ZvHGKGBybCWGwA6C4rqjCOEM+pX70S8="; }; + postPatch = '' + substituteInPlace pyproject.toml \ + --replace '{ git = "https://github.com/Pennyw0rth/impacket.git", branch = "gkdi" }' '"*"' + + substituteInPlace pyproject.toml \ + --replace '{ git = "https://github.com/Pennyw0rth/oscrypto" }' '"*"' + ''; + nativeBuildInputs = with python.pkgs; [ poetry-core pythonRelaxDepsHook @@ -126,19 +133,15 @@ python.pkgs.buildPythonApplication rec { ]; nativeCheckInputs = with python.pkgs; [ - pytest + pytestCheckHook ]; - postPatch = '' - substituteInPlace pyproject.toml \ - --replace '{ git = "https://github.com/Pennyw0rth/impacket.git", branch = "gkdi" }' '"*"' - - substituteInPlace pyproject.toml \ - --replace '{ git = "https://github.com/Pennyw0rth/oscrypto" }' '"*"' + preCheck = '' + export HOME=$(mktemp -d) ''; meta = with lib; { - description = "Network service exploitation tool (Maintaned fork of CrackMapExec)"; + description = "Network service exploitation tool (maintained fork of CrackMapExec)"; homepage = "https://github.com/Pennyw0rth/NetExec"; changelog = "https://github.com/Pennyw0rth/NetExec/releases/tag/v${version}"; license = with licenses; [ bsd2 ]; From 29c1267fab998477c5d5719dce232381efe4b1d7 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Fri, 12 Jan 2024 19:55:43 +0000 Subject: [PATCH 4/8] netexec: fix version format in custom impacket override --- pkgs/tools/security/netexec/default.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index 73599e8f88d1..c94bfe4764f7 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -8,13 +8,18 @@ let python = python3.override { packageOverrides = self: super: { impacket = super.impacket.overridePythonAttrs { - version = "0.12.0.dev1"; + version = "0.12.0.dev1-unstable-2023-11-30"; src = fetchFromGitHub { owner = "Pennyw0rth"; repo = "impacket"; rev = "d370e6359a410063b2c9c68f6572c3b5fb178a38"; hash = "sha256-Jozn4lKAnLQ2I53+bx0mFY++OH5P4KyqVmrS5XJUY3E="; }; + # Fix version to be compliant with Python packaging rules + postPatch = '' + substituteInPlace setup.py \ + --replace 'version="{}.{}.{}.{}{}"' 'version="{}.{}.{}"' + ''; }; }; }; From ee64dd74118c846c53eb528590105674848805bb Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sat, 13 Jan 2024 03:05:09 +0000 Subject: [PATCH 5/8] netexec: remove some declared dependencies --- pkgs/tools/security/netexec/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index c94bfe4764f7..ed8ac330a11e 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -84,6 +84,14 @@ python.pkgs.buildPythonApplication rec { version = "1.1.0"; pyproject = true; pythonRelaxDeps = true; + pythonRemoveDeps = [ + # Lint + "ruff" + # Windows only dependency + "pyreadline" + # Fail to detect dev version requirement + "neo4j" + ]; src = fetchFromGitHub { owner = "Pennyw0rth"; From 7e42155024183dfac8aa12ed48bebf97ad96bfc7 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 14 Jan 2024 17:44:25 +0000 Subject: [PATCH 6/8] netexec: remove incorrectly included dependency from upstream --- pkgs/tools/security/netexec/default.nix | 65 +++---------------------- 1 file changed, 7 insertions(+), 58 deletions(-) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index ed8ac330a11e..9308de70a168 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -1,8 +1,6 @@ { lib , fetchFromGitHub , python3 -, buildPythonPackage -, fetchPypi }: let python = python3.override { @@ -23,68 +21,20 @@ let }; }; }; - - python-easyconfig = buildPythonPackage rec { - pname = "python-easyconfig"; - version = "0.1.7"; - src = fetchPypi { - inherit version; - pname = "Python-EasyConfig"; - hash = "sha256-tUjxmrhQtVFU9hFi8xTj27J24R47JpUbio+gaDwGuyk="; - }; - propagatedBuildInputs = with python.pkgs; [ - six - pyyaml - ]; - }; - - jsonform = buildPythonPackage rec { - pname = "jsonform"; - version = "0.0.2"; - doCheck = false; - src = fetchPypi { - inherit version; - pname = "JsonForm"; - hash = "sha256-cfi3ohU44wyphLad3gTwKYDNbNwhg6GKp8oC2VCZiOY="; - }; - propagatedBuildInputs = with python.pkgs; [ - jsonschema - ]; - }; - - jsonsir = buildPythonPackage rec { - pname = "jsonsir"; - version = "0.0.2"; - doCheck = false; - src = fetchPypi { - inherit version; - pname = "JsonSir"; - hash = "sha256-QBRHxekx94h4Uc6b8kB/401aqwsUZ7sku787dg5b0/s="; - }; - }; - - resource = buildPythonPackage rec { - pname = "resource"; - version = "0.2.1"; - doCheck = false; - src = fetchPypi { - inherit version; - pname = "Resource"; - hash = "sha256-mDVKvY7+c9WhDyEJnYC774Xs7ffKIqQW/yAlClGs2RY="; - }; - propagatedBuildInputs = with python.pkgs; [ - python-easyconfig - jsonform - jsonsir - ]; - }; in python.pkgs.buildPythonApplication rec { pname = "netexec"; version = "1.1.0"; pyproject = true; pythonRelaxDeps = true; + # TODO: remove those once upstream merge this PR and release a new version: + # https://github.com/Pennyw0rth/NetExec/pull/162 pythonRemoveDeps = [ + # Upstream incorrectly includes the wrong package as dependency. + # Should be `resource` from stdlib (https://docs.python.org/3/library/resource.html), + # not `RussellLuo/resource` (a repo not maintained in 4 years) + # See: https://github.com/Pennyw0rth/NetExec/commit/483dc69a2a7aa8f364adfc46096a8b5114c0a31a + "resource" # Lint "ruff" # Windows only dependency @@ -141,7 +91,6 @@ python.pkgs.buildPythonApplication rec { pyasn1-modules rich python-libnmap - resource oscrypto ]; From 78f2aadaec0350a1e8ea1ee02d67efe4bd822b5c Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Sun, 14 Jan 2024 13:37:18 +0000 Subject: [PATCH 7/8] netexec: mark as broken in Darwin --- pkgs/tools/security/netexec/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index 9308de70a168..f61691b6aea0 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -1,4 +1,5 @@ { lib +, stdenv , fetchFromGitHub , python3 }: @@ -109,5 +110,9 @@ python.pkgs.buildPythonApplication rec { license = with licenses; [ bsd2 ]; mainProgram = "nxc"; maintainers = with maintainers; [ vncsb ]; + # FIXME: failing fixupPhase: + # $ Rewriting #!/nix/store/-python3-3.11.7/bin/python3.11 to #!/nix/store/-python3-3.11.7 + # $ /nix/store/-wrap-python-hook/nix-support/setup-hook: line 65: 47758 Killed: 9 sed -i "$f" -e "1 s^#!/nix/store/-python3-3.11.7^#!/nix/store/-python3-3.11.7^" + broken = stdenv.isDarwin; }; } From 99b9a12a156183cce9a22b48efc08bb8d53e95cf Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 16 Jan 2024 10:14:05 +0000 Subject: [PATCH 8/8] netexec: 1.1.0 -> 1.1.0-unstable-2024-01-15 --- pkgs/tools/security/netexec/default.nix | 62 ++++++++++--------------- 1 file changed, 25 insertions(+), 37 deletions(-) diff --git a/pkgs/tools/security/netexec/default.nix b/pkgs/tools/security/netexec/default.nix index f61691b6aea0..625cd3974252 100644 --- a/pkgs/tools/security/netexec/default.nix +++ b/pkgs/tools/security/netexec/default.nix @@ -25,21 +25,10 @@ let in python.pkgs.buildPythonApplication rec { pname = "netexec"; - version = "1.1.0"; + version = "1.1.0-unstable-2024-01-15"; pyproject = true; pythonRelaxDeps = true; - # TODO: remove those once upstream merge this PR and release a new version: - # https://github.com/Pennyw0rth/NetExec/pull/162 pythonRemoveDeps = [ - # Upstream incorrectly includes the wrong package as dependency. - # Should be `resource` from stdlib (https://docs.python.org/3/library/resource.html), - # not `RussellLuo/resource` (a repo not maintained in 4 years) - # See: https://github.com/Pennyw0rth/NetExec/commit/483dc69a2a7aa8f364adfc46096a8b5114c0a31a - "resource" - # Lint - "ruff" - # Windows only dependency - "pyreadline" # Fail to detect dev version requirement "neo4j" ]; @@ -47,15 +36,13 @@ python.pkgs.buildPythonApplication rec { src = fetchFromGitHub { owner = "Pennyw0rth"; repo = "NetExec"; - rev = "refs/tags/v${version}"; - hash = "sha256-cNkZoIdfrKs5ZvHGKGBybCWGwA6C4rqjCOEM+pX70S8="; + rev = "9df72e2f68b914dfdbd75b095dd8f577e992615f"; + hash = "sha256-oQHtTE5hdlxHX4uc412VfNUrN0UHVbwI0Mm9kmJpNW4="; }; postPatch = '' substituteInPlace pyproject.toml \ - --replace '{ git = "https://github.com/Pennyw0rth/impacket.git", branch = "gkdi" }' '"*"' - - substituteInPlace pyproject.toml \ + --replace '{ git = "https://github.com/Pennyw0rth/impacket.git", branch = "gkdi" }' '"*"' \ --replace '{ git = "https://github.com/Pennyw0rth/oscrypto" }' '"*"' ''; @@ -65,34 +52,35 @@ python.pkgs.buildPythonApplication rec { ]; propagatedBuildInputs = with python.pkgs; [ - requests + aardwolf + aioconsole + aiosqlite + argcomplete + asyauth beautifulsoup4 + bloodhound-py + dploot + dsinternals + impacket lsassy - termcolor + masky + minikerberos msgpack neo4j + oscrypto + paramiko + pyasn1-modules pylnk3 pypsrp - paramiko - impacket - dsinternals - xmltodict - terminaltables - aioconsole - pywerview - minikerberos pypykatz - aardwolf - dploot - bloodhound-py - asyauth - masky - sqlalchemy - aiosqlite - pyasn1-modules - rich python-libnmap - oscrypto + pywerview + requests + rich + sqlalchemy + termcolor + terminaltables + xmltodict ]; nativeCheckInputs = with python.pkgs; [