repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
Base.astroAstro201 lines9.3 KiBraw download
---
import { ClientRouter } from 'astro:transitions';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import Icon from '../components/Icon.astro';
import SearchModal from '../components/SearchModal.astro';
import ReportIndexModal from '../components/ReportIndexModal.astro';
import { url } from '../lib/url';
import '../styles/app.css';
import { PALETTES, DEFAULT_PALETTE } from '../lib/palettes';
// Preload the two faces that paint above the fold — the wordmark in the
// masthead and the DM Mono the masthead/labels use — so the header does not flash
// its fallback on first paint. The rest load on demand via @font-face.
import notoWordmark from '../fonts/noto-sans-display-var-latin.woff2';
import dmMono from '../fonts/dm-mono-400.woff2';

interface Props {
  title?: string;
  description?: string;
  railless?: boolean;
}
const {
  title = 'DÆMON//SEC — Cyber & IT Cheatsheet Vault',
  description = 'A curated, glassy vault of the best IT and cybersecurity cheatsheets — Active Directory, enumeration, exploitation, priv-esc, and more.',
} = Astro.props;
const canonical = new URL(Astro.url.pathname, Astro.site).href;
// The pre-paint script's table: palette → browser-chrome colour per mode.
const CHROME = Object.fromEntries(PALETTES.map((p) => [p.id, p.chrome]));
---
<!doctype html>
<html lang="en" data-theme="light" data-palette="rose-pine">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>{title}</title>
    <meta name="description" content={description} />
    <link rel="canonical" href={canonical} />
    <link rel="icon" href={url('favicon.svg')} type="image/svg+xml" />
    <link rel="preload" href={notoWordmark} as="font" type="font/woff2" crossorigin />
    <link rel="preload" href={dmMono} as="font" type="font/woff2" crossorigin />
    <meta name="theme-color" content="#191724" media="(prefers-color-scheme: dark)" />
    <meta name="theme-color" content="#faf4ed" media="(prefers-color-scheme: light)" />
    <meta property="og:type" content="website" />
    <meta property="og:title" content={title} />
    <meta property="og:description" content={description} />
    <meta property="og:image" content={url('og.svg')} />
    <meta name="twitter:card" content="summary_large_image" />
    <!-- Set theme before first paint to avoid FOUC -->
    <script is:inline define:vars={{ CHROME, DEFAULT: DEFAULT_PALETTE }}>
      (function () {
        function apply() {
          try {
            var t = localStorage.getItem('theme');
            // Dawn (cream) is the default, matching the main DÆMON site.
            if (t !== 'light' && t !== 'dark') t = 'light';
            document.documentElement.setAttribute('data-theme', t);
            document.documentElement.style.colorScheme = t;
          } catch (e) {
            document.documentElement.setAttribute('data-theme', 'light');
          }
          palette();
        }

        /* The palette (palettes.css): Rosé Pine unless the reader chose
           another from the masthead. The browser chrome follows palette
           and mode together, so both theme-color metas are rewritten. */
        function palette() {
          var root = document.documentElement;
          var p = null;
          try { p = localStorage.getItem('palette'); } catch (e) {}
          if (!Object.prototype.hasOwnProperty.call(CHROME, p)) p = DEFAULT;
          root.setAttribute('data-palette', p);
          var c = CHROME[p][root.getAttribute('data-theme') === 'dark' ? 'night' : 'dawn'];
          var metas = document.querySelectorAll('meta[name="theme-color"]');
          for (var i = 0; i < metas.length; i++) metas[i].setAttribute('content', c);
        }

        apply();

        /* Every page ships `<html data-theme="light">` in its static markup,
           because that is the default and the build has no way to know what
           any given reader chose. On a view-transition navigation Astro
           swaps in the new document — attributes on <html> included — so
           that baked-in "light" overwrites the live attribute and the page
           reverts to dawn mid-session.

           This listener re-applies the stored choice on every swap. It runs
           in `astro:after-swap`, which fires after the new document is in
           place but before it is painted, so the correction never flashes.

           The listener is registered once, from an inline head script that
           executes on the first full load only — which is exactly why it
           has to be `is:inline` and live here rather than in app.ts: a
           bundled module re-imported per page would re-register it, and a
           deferred one would run too late to beat the paint. */
        document.addEventListener('astro:after-swap', apply);
      })();
    </script>
    <!-- Page iris. Every internal navigation opens the next page as a
         circle from the link that was pressed: the theme wipe's gesture,
         at page pace. The CSS is beside the theme wipe in global.css;
         this only supplies the origin and the end radius. -->
    <script is:inline>
      (function () {
        function centre(el) {
          var r = el.getBoundingClientRect();
          return { x: r.left + r.width / 2, y: r.top + r.height / 2 };
        }

        /* Where the last click landed. Capture phase, so it is recorded
           before the ClientRouter's own listener takes the click. A click
           with detail 0 came from the keyboard and has no pointer
           position, so it opens from the middle of the control. */
        var press = null;
        document.addEventListener('click', function (e) {
          var at = e.detail === 0 && e.target instanceof Element
            ? centre(e.target)
            : { x: e.clientX, y: e.clientY };
          at.t = Date.now();
          press = at;
        }, true);

        var origin = null;
        function paint() {
          if (!origin) return;
          var s = document.documentElement.style;
          s.setProperty('--vt-x', origin.x + 'px');
          s.setProperty('--vt-y', origin.y + 'px');
          s.setProperty('--vt-r', origin.r + 'px');
        }

        /* A press older than a second did not cause this navigation (back,
           forward, a scripted one), so it falls back to the link Astro
           reports, then to the middle of the screen. The radius reaches
           the farthest corner exactly, so the circle finishes as it
           covers the page rather than part-way through an overshoot. */
        document.addEventListener('astro:before-preparation', function (e) {
          var at = press && Date.now() - press.t < 1000 ? press
            : e.sourceElement instanceof Element ? centre(e.sourceElement)
            : { x: innerWidth / 2, y: innerHeight / 2 };
          origin = {
            x: at.x,
            y: at.y,
            r: Math.hypot(Math.max(at.x, innerWidth - at.x), Math.max(at.y, innerHeight - at.y)),
          };
          paint();
        });

        /* The swap replaces <html>'s attributes with the new page's, and
           the inline style carrying these three goes with them, so they
           are put back before the new page is painted, for the same
           reason as the theme note above. */
        document.addEventListener('astro:after-swap', paint);
      })();
    </script>
    <ClientRouter />
  </head>
  <body>
    <a class="skip-link" href="#main">Skip to content</a>
    <!-- Shared arrowhead for every inline-SVG flowchart (src/styles/flow.css).
         Defined once here so a diagram only has to reference `url(#flow-arrow)`.
         `context-stroke` makes the head take each edge's own stroke colour, so
         one marker serves foam forward edges and love back-edges alike. -->
    <svg width="0" height="0" aria-hidden="true" style="position:absolute" focusable="false">
      <defs>
        <marker id="flow-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7"
                markerHeight="7" orient="auto-start-reverse" markerUnits="userSpaceOnUse">
          <path class="flow-arrow" d="M0,0 L10,5 L0,10 z" fill="context-stroke" />
        </marker>
      </defs>
    </svg>
    <!-- The film over the whole page. It is what keeps a flat colour
         reading as stock rather than as a swatch, and it stands in for the
         texture the old glass build got from blur. -->
    <span class="grain" aria-hidden="true"></span>
    <Header />
    <main id="main" tabindex="-1">
      <slot />
    </main>
    <Footer />
    <!-- Sheets run to a couple of thousand lines; without this the only way
         back to the header is a long scroll. Hidden until app.ts marks it
         visible, so it never shows on a page short enough not to need it. -->
    <button id="to-top" class="to-top" type="button" hidden aria-label="Back to top">
      <Icon name="chevron" />
    </button>
    <SearchModal />
    <ReportIndexModal />
    <script>
      import '../scripts/app.ts';
    </script>
    <script>
      // The effects shared with daemon-sec.xyz (src/scripts/dmn): the cursor
      // pill and the sheet image viewer. Re-bound after each navigation.
      import { initDmn } from '../scripts/dmn/init';
      document.addEventListener('astro:page-load', initDmn);
      if (document.readyState !== 'loading') initDmn();
      else document.addEventListener('DOMContentLoaded', initDmn, { once: true });
    </script>
  </body>
</html>