From f83698372a88c2873cf511a99a048975c14317ce Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Tue, 14 Jul 2026 14:58:21 -0400 Subject: [PATCH 1/4] fix(network-ops): auto-install impacket at tool import time MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Runtime doesn't process dependencies.python or dependencies.scripts, so impacket is never installed into the runtime's Python. Add _ensure_impacket_installed() that runs at module import — if `import impacket` fails, it pip-installs it via sys.executable. Co-Authored-By: Claude Opus 4.6 (1M context) --- capabilities/network-ops/tools/impacket.py | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/capabilities/network-ops/tools/impacket.py b/capabilities/network-ops/tools/impacket.py index fef4fcb..0faac1a 100644 --- a/capabilities/network-ops/tools/impacket.py +++ b/capabilities/network-ops/tools/impacket.py @@ -60,6 +60,36 @@ def _extract_real_path_from_wrapper(wrapper_path: Path) -> Path | None: return None +def _ensure_impacket_installed() -> None: + """Install impacket into the running Python if it's not importable. + + The runtime may not process ``dependencies.python`` from + ``capability.yaml``, so we do a best-effort pip install at import + time as a fallback. + """ + try: + import impacket as _ # noqa: F401 + except ImportError: + import subprocess + + logger.warning("impacket not importable — attempting pip install") + for extra_args in ([], ["--break-system-packages"]): + try: + subprocess.check_call( + [sys.executable, "-m", "pip", "install", "--quiet", "impacket>=0.12.0", *extra_args], + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL, + ) + logger.info("impacket installed successfully") + return + except subprocess.CalledProcessError: + continue + logger.error("Failed to install impacket — impacket tools will not work") + + +_ensure_impacket_installed() + + def _get_impacket_script_path() -> Path: """ Auto-discover the impacket scripts directory. From 75a1d6dfdab67edf6992d8029e85a1471f203102 Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Tue, 14 Jul 2026 15:03:35 -0400 Subject: [PATCH 2/4] style(network-ops): fix ruff formatting in _ensure_impacket_installed Co-Authored-By: Claude Opus 4.6 (1M context) --- capabilities/network-ops/tools/impacket.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/capabilities/network-ops/tools/impacket.py b/capabilities/network-ops/tools/impacket.py index 0faac1a..641cd7b 100644 --- a/capabilities/network-ops/tools/impacket.py +++ b/capabilities/network-ops/tools/impacket.py @@ -76,7 +76,15 @@ def _ensure_impacket_installed() -> None: for extra_args in ([], ["--break-system-packages"]): try: subprocess.check_call( - [sys.executable, "-m", "pip", "install", "--quiet", "impacket>=0.12.0", *extra_args], + [ + sys.executable, + "-m", + "pip", + "install", + "--quiet", + "impacket>=0.12.0", + *extra_args, + ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, ) From 1cedaff18dd11d177013383fd2cad6e77ea6ab65 Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Tue, 14 Jul 2026 15:17:37 -0400 Subject: [PATCH 3/4] fix(network-ops): add timeout, env var opt-out, and stderr visibility - Add 120s timeout to pip subprocess to prevent hangs on network issues - Catch TimeoutExpired and OSError in addition to CalledProcessError - Add DREADNODE_SKIP_AUTO_INSTALL=1 env var to disable auto-install in tests/CI - Stop suppressing pip stderr in install script so failures are diagnosable Co-Authored-By: Claude Opus 4.6 (1M context) --- .../network-ops/scripts/install_coercion_tools.sh | 2 +- capabilities/network-ops/tools/impacket.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/capabilities/network-ops/scripts/install_coercion_tools.sh b/capabilities/network-ops/scripts/install_coercion_tools.sh index 27438be..5e65ab0 100755 --- a/capabilities/network-ops/scripts/install_coercion_tools.sh +++ b/capabilities/network-ops/scripts/install_coercion_tools.sh @@ -8,7 +8,7 @@ set -euo pipefail # runtime Python can't import impacket, install it explicitly. if ! python3 -c "import impacket" 2>/dev/null; then echo "[+] Installing impacket into runtime Python" - python3 -m pip install --quiet "impacket>=0.12.0" 2>/dev/null \ + python3 -m pip install --quiet "impacket>=0.12.0" \ || python3 -m pip install --quiet --break-system-packages "impacket>=0.12.0" else echo "[*] impacket already importable, skipping" diff --git a/capabilities/network-ops/tools/impacket.py b/capabilities/network-ops/tools/impacket.py index 641cd7b..f3bd0c2 100644 --- a/capabilities/network-ops/tools/impacket.py +++ b/capabilities/network-ops/tools/impacket.py @@ -66,7 +66,12 @@ def _ensure_impacket_installed() -> None: The runtime may not process ``dependencies.python`` from ``capability.yaml``, so we do a best-effort pip install at import time as a fallback. + + Set ``DREADNODE_SKIP_AUTO_INSTALL=1`` to disable (useful in tests/CI). """ + if os.environ.get("DREADNODE_SKIP_AUTO_INSTALL", "").strip() in ("1", "true", "yes"): + return + try: import impacket as _ # noqa: F401 except ImportError: @@ -75,7 +80,7 @@ def _ensure_impacket_installed() -> None: logger.warning("impacket not importable — attempting pip install") for extra_args in ([], ["--break-system-packages"]): try: - subprocess.check_call( + subprocess.run( [ sys.executable, "-m", @@ -87,10 +92,12 @@ def _ensure_impacket_installed() -> None: ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, + check=True, + timeout=120, ) logger.info("impacket installed successfully") return - except subprocess.CalledProcessError: + except (subprocess.CalledProcessError, subprocess.TimeoutExpired, OSError): continue logger.error("Failed to install impacket — impacket tools will not work") From aa98223020d2068ff7a3a6dd0c08f24e18c0daf9 Mon Sep 17 00:00:00 2001 From: mkultraWasHere Date: Tue, 14 Jul 2026 15:57:22 -0400 Subject: [PATCH 4/4] chore(network-ops): bump version to 2.1.2 Co-Authored-By: Claude Opus 4.6 (1M context) --- capabilities/network-ops/capability.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/capabilities/network-ops/capability.yaml b/capabilities/network-ops/capability.yaml index 7016351..1f7ee57 100644 --- a/capabilities/network-ops/capability.yaml +++ b/capabilities/network-ops/capability.yaml @@ -1,6 +1,6 @@ schema: 1 name: network-ops -version: "2.1.1" +version: "2.1.2" description: > Network operations and Active Directory exploitation. Multi-agent pipeline for autonomous red teaming with Nmap scanning, Netexec