daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR
git clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
Log | Files | Refs | README | LICENSE

import-powerview-powerup-sheet.py (2513B)


      1 #!/usr/bin/env python3
      2 """Import the vault's PowerView + PowerUp deep-dive into the AD collection."""
      3 
      4 from __future__ import annotations
      5 
      6 import re
      7 from pathlib import Path
      8 
      9 
     10 SOURCE = Path(
     11     "/home/daemon-sec/git/NetrunnerVault/02Cybersecurity/Cheatsheets/ActiveDirectory/"
     12     "PowerView-PowerUp-Cheatsheet.md"
     13 )
     14 REPO_ROOT = Path(__file__).resolve().parents[1]
     15 DESTINATION = REPO_ROOT / "src/content/sheets/active-directory/powerview-powerup.md"
     16 
     17 FRONTMATTER = """---
     18 title: "PowerView and PowerUp Deep-Dive"
     19 description: "Comprehensive PowerView domain-enumeration and PowerUp local Windows privilege-escalation reference, with read-only triage, validation, cleanup, and function indexes."
     20 category: active-directory
     21 subcategory: "Tooling & Recon"
     22 tags: [active-directory, powerview, powerup, powershell, enumeration, privilege-escalation]
     23 tools: [PowerView, PowerUp, PowerShell]
     24 difficulty: advanced
     25 updated: "2026-08-29"
     26 source: "vault:ActiveDirectory/PowerView-PowerUp-Cheatsheet.md"
     27 ---
     28 """
     29 
     30 DOWNLOADS = {
     31     "../Pentest%20Attack%20Flow/General%20Pentest%20Cheatsheets/attachments/PowerView.ps1": (
     32         "/downloads/pentest-workflow/PowerView.ps1"
     33     ),
     34     "../Pentest%20Attack%20Flow/General%20Pentest%20Cheatsheets/attachments/PowerUp.ps1": (
     35         "/downloads/pentest-workflow/PowerUp.ps1"
     36     ),
     37 }
     38 
     39 
     40 def main() -> None:
     41     body = SOURCE.read_text(encoding="utf-8")
     42     if not body.startswith("---\n"):
     43         raise SystemExit(f"Expected YAML frontmatter in {SOURCE}")
     44     _, _, body = body.split("---\n", 2)
     45 
     46     # Obsidian-only note furniture has no meaning on the generated site.
     47     body = re.sub(r"```dataviewjs\n.*?\n```\n*", "", body, count=1, flags=re.DOTALL)
     48 
     49     for source_href, public_href in DOWNLOADS.items():
     50         filename = Path(public_href).name
     51         checksum_href = f"{public_href}.sha256"
     52         body = body.replace(
     53             f"[{filename}]({source_href})",
     54             f"[{filename}]({public_href}) ([SHA-256]({checksum_href}))",
     55         )
     56 
     57     body = body.replace(
     58         "[[BloodHound-Cheatsheet]]",
     59         "[BloodHound cheat sheet](/sheets/active-directory/bloodhound/)",
     60     )
     61 
     62     unresolved = re.findall(r"!?\[\[[^\]]+\]\]", body)
     63     if unresolved:
     64         raise SystemExit(f"Unresolved Obsidian links: {unresolved}")
     65 
     66     DESTINATION.parent.mkdir(parents=True, exist_ok=True)
     67     DESTINATION.write_text(FRONTMATTER + body.lstrip(), encoding="utf-8")
     68     print(f"Imported {DESTINATION.relative_to(REPO_ROOT)}")
     69 
     70 
     71 if __name__ == "__main__":
     72     main()