bh_clues: --help, lab notice and clearer errors

argparse usage with an example, a header line in the output stating it is a
Norbourg-lab tool, and explicit messages for a missing collection or an
unknown account. The tool ISOs describe the script next to the wordlist.
This commit is contained in:
2026-10-26 23:21:52 -04:00
parent 28cf7080ee
commit ab96939b20
4 changed files with 87 additions and 29 deletions
+2
View File
@@ -30,6 +30,8 @@ Outils de l'atelier Norbourg
norbourg.txt : liste de mots ciblee (1716 entrees), dimensionnee pour que le
cassage prenne quelques secondes.
bh_clues.py : lit les JSON de bloodhound-python et imprime les droits
exploitables d'un compte (outil concu pour ce laboratoire).
Installation dans Kali :
+77 -27
View File
@@ -1,18 +1,29 @@
#!/usr/bin/env python3
"""Print the actionable BloodHound edges for one account.
"""bh_clues.py — BloodHound JSON reader for the Norbourg workshop lab.
The collector writes JSON for the GUI; this reads it back and answers the
question a participant actually has: "what can this account touch?"
bloodhound-python writes JSON for the BloodHound GUI, so a terminal user
sees a successful collection and nothing else. This script answers the
question a participant actually has: for one account, what can it touch?
bloodhound-python -d norbourg.lab -u svc_backup -p '...' -ns 10.10.10.10 -c All
It prints:
* the account's SPNs and groups (including nested groups),
* non-inherited ACEs held by the account or one of its groups,
* local AdminTo / PSRemote / CanRDP / CanDCOM edges,
and collapses GetChanges + GetChangesAll into a single DCSync line.
Written for the Norbourg lab (norbourg.lab). It only reads the JSON files
produced by the collector; it never talks to the network.
Typical use:
bloodhound-python -d norbourg.lab -u svc_backup -p 'Backup2023!' \
-ns 10.10.10.10 -c All
python3 bh_clues.py svc_backup
The directory argument defaults to the current one; the newest collection of
each type is used.
"""
from __future__ import annotations
import argparse
import glob
import json
import os
@@ -44,12 +55,40 @@ def short(obj: dict) -> str:
return f"{name} ({sam})" if sam else name
def main() -> int:
if len(sys.argv) < 2:
print(__doc__.strip().splitlines()[0], file=sys.stderr)
return 2
who = sys.argv[1].lower()
directory = sys.argv[2] if len(sys.argv) > 2 else "."
def parse_args(argv: list[str]) -> argparse.Namespace:
parser = argparse.ArgumentParser(
prog="bh_clues.py",
description=(
"Print the BloodHound edges of one account from the collector's JSON. "
"Built for the Norbourg workshop lab (norbourg.lab); it reads files only, "
"no network access."
),
epilog=(
"examples:\n"
" bloodhound-python -d norbourg.lab -u svc_backup -p 'Backup2023!' "
"-ns 10.10.10.10 -c All\n"
" python3 bh_clues.py svc_backup\n"
" python3 bh_clues.py svc_backup /tmp/collection\n"
),
formatter_class=argparse.RawDescriptionHelpFormatter,
)
parser.add_argument(
"account",
help="sAMAccountName to inspect (for example svc_backup or m.legault)",
)
parser.add_argument(
"directory",
nargs="?",
default=".",
help="directory holding the *_users.json files (default: current directory)",
)
return parser.parse_args(argv)
def main(argv: list[str] | None = None) -> int:
args = parse_args(sys.argv[1:] if argv is None else argv)
who = args.account.lower()
directory = args.directory
users = load(directory, "users")
groups = load(directory, "groups")
@@ -57,15 +96,24 @@ def main() -> int:
extra = load(directory, "domains") + load(directory, "ous") + load(directory, "containers")
if not users:
print("no *_users.json here — run bloodhound-python first", file=sys.stderr)
print(
f"no *_users.json in {directory!r} — run bloodhound-python there first",
file=sys.stderr,
)
return 1
target = next((u for u in users
target = next(
(u for u in users
if (u.get("Properties", {}).get("samaccountname") or "").lower() == who
or (u.get("Properties", {}).get("name") or "").split("@")[0].lower() == who),
None)
None,
)
if not target:
print(f"user not found in the collection: {who}", file=sys.stderr)
print(
f"account not found in this collection: {args.account}\n"
"check the spelling, or collect again with -c All",
file=sys.stderr,
)
return 1
sid = target["ObjectIdentifier"]
@@ -77,14 +125,15 @@ def main() -> int:
gid = group["ObjectIdentifier"]
if gid in principals:
continue
members = (group.get("Members") or [])
members = group.get("Members") or []
if any(m.get("ObjectIdentifier") in principals for m in members):
principals.add(gid)
changed = True
print("\n# bh_clues.py — Norbourg lab (norbourg.lab)")
print(f"# collection: {directory}")
print(f"\n{short(target)}")
spns = target.get("Properties", {}).get("serviceprincipalnames") or []
for spn in spns:
for spn in target.get("Properties", {}).get("serviceprincipalnames") or []:
print(f" SPN {spn}")
for group in groups:
if group["ObjectIdentifier"] in principals and group["ObjectIdentifier"] != sid:
@@ -102,17 +151,17 @@ def main() -> int:
continue
rows.append((right, short(obj)))
# The GUI shows a single DCSync edge; the JSON has the two rights.
for target in {t for r, t in rows if r in ("GetChanges", "GetChangesAll")}:
rights = {r for r, t in rows if t == target and r in ("GetChanges", "GetChangesAll")}
# The GUI shows a single DCSync edge; the JSON carries the two rights.
for target_name in {t for r, t in rows if r in ("GetChanges", "GetChangesAll")}:
rights = {r for r, t in rows if t == target_name and r in ("GetChanges", "GetChangesAll")}
if {"GetChanges", "GetChangesAll"} <= rights:
rows = [(r, t) for r, t in rows
if not (t == target and r in ("GetChanges", "GetChangesAll"))]
rows.append(("DCSync", target))
if not (t == target_name and r in ("GetChanges", "GetChangesAll"))]
rows.append(("DCSync", target_name))
found = len(rows)
for right, target in sorted(rows):
print(f" {right:<18} -> {target}")
for right, name in sorted(rows):
print(f" {right:<18} -> {name}")
for computer in computers:
for key, label in LOCAL:
@@ -123,6 +172,7 @@ def main() -> int:
if not found:
print(" (no exploitable edge — this account is a dead end)")
print()
return 0
+4
View File
@@ -146,6 +146,10 @@ impacket-changepasswd 'norbourg.lab/<cible>@10.10.10.10' -reset -newpass '<nouve
`-c all` n'est pas décoratif : la collecte par défaut n'inclut pas les listes de permissions
(`Aces`), et on conclut à tort qu'il n'y a aucun chemin.
`bh_clues.py` est fourni avec le laboratoire (`--help` pour l'aide) : il lit les JSON du
collecteur — aucun accès réseau — et affiche les groupes, les SPN et les droits réellement
exploitables d'un compte. La mention « dead end » est une information, pas une erreur.
Dans `impacket-changepasswd`, le compte **ciblé** est celui de l'URL et le compte qui
**s'authentifie** est passé par `-altuser`, sans préfixe de domaine : l'outil se connecte avec
cette identité alternative pour modifier l'autre compte.
@@ -594,6 +594,8 @@ Outils de l'atelier Norbourg
norbourg.txt : liste de mots ciblee, dimensionnee pour un cassage de
quelques secondes.
bh_clues.py : lit les JSON de bloodhound-python et imprime les droits
exploitables d'un compte (outil concu pour ce laboratoire).
sudo mkdir -p /opt/norbourg/wordlists
sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/