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

hacktricks.ts (1399B)


      1 import { getCollection, type CollectionEntry } from 'astro:content';
      2 
      3 export type HackTricksPage = CollectionEntry<'hacktricks'>;
      4 
      5 export async function allHackTricks(): Promise<HackTricksPage[]> {
      6   return await getCollection('hacktricks');
      7 }
      8 
      9 export function hackTricksHref(entry: HackTricksPage): string {
     10   return `hacktricks/${entry.id}`;
     11 }
     12 
     13 export interface HackTricksSection {
     14   slug: string;
     15   title: string;
     16   items: HackTricksPage[];
     17   count: number;
     18 }
     19 
     20 export async function hackTricksBySection(): Promise<HackTricksSection[]> {
     21   const pages = await allHackTricks();
     22   const grouped = new Map<string, HackTricksPage[]>();
     23   for (const page of pages) {
     24     const items = grouped.get(page.data.sectionSlug) ?? [];
     25     items.push(page);
     26     grouped.set(page.data.sectionSlug, items);
     27   }
     28 
     29   return [...grouped].map(([slug, items]) => ({
     30     slug,
     31     title: items[0].data.section,
     32     items: items.sort((a, b) => a.data.title.localeCompare(b.data.title)),
     33     count: items.length,
     34   })).sort((a, b) => a.title.localeCompare(b.title));
     35 }
     36 
     37 export function prevNext(
     38   order: HackTricksPage[],
     39   current: HackTricksPage,
     40 ): { prev?: HackTricksPage; next?: HackTricksPage } {
     41   const index = order.findIndex((page) => page.id === current.id);
     42   return {
     43     prev: index > 0 ? order[index - 1] : undefined,
     44     next: index >= 0 && index < order.length - 1 ? order[index + 1] : undefined,
     45   };
     46 }