From bb3733a1c597e54b502639990377cbf6825d0ed0 Mon Sep 17 00:00:00 2001 From: Translator Date: Thu, 2 Jan 2025 21:34:59 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/kubernetes-security/kubernetes-pivotin --- book.toml | 1 + hacktricks-preprocessor.py | 18 +++-- .../kubernetes-pivoting-to-clouds.md | 10 +-- theme/book.js | 56 +++++++++++++ theme/css/chrome.css | 53 ++++++++++++- theme/index.hbs | 78 ++++++++++++------- theme/sponsor.js | 2 - 7 files changed, 174 insertions(+), 44 deletions(-) diff --git a/book.toml b/book.toml index e3330d5e6..f20e2d2a2 100644 --- a/book.toml +++ b/book.toml @@ -22,6 +22,7 @@ after = ["links"] [preprocessor.hacktricks] command = "python3 ./hacktricks-preprocessor.py" +env = "prod" [output.html] additional-css = ["theme/pagetoc.css", "theme/tabs.css"] diff --git a/hacktricks-preprocessor.py b/hacktricks-preprocessor.py index 37f549101..8e67ab77b 100644 --- a/hacktricks-preprocessor.py +++ b/hacktricks-preprocessor.py @@ -30,14 +30,16 @@ def ref(matchobj): href = matchobj.groups(0)[0].strip() title = href if href.startswith("http://") or href.startswith("https://"): - # pass - try: - raw_html = str(urlopen(Request(href, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0'})).read()) - match = re.search('(.*?)', raw_html) - title = match.group(1) if match else href - except Exception as e: - logger.debug(f'Error opening URL {href}: {e}') - pass #nDont stop on broken link + if context['config']['preprocessor']['hacktricks']['env'] == 'dev': + pass + else: + try: + raw_html = str(urlopen(Request(href, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0'})).read()) + match = re.search('(.*?)', raw_html) + title = match.group(1) if match else href + except Exception as e: + logger.debug(f'Error opening URL {href}: {e}') + pass #nDont stop on broken link else: try: if href.endswith("/"): diff --git a/src/pentesting-cloud/kubernetes-security/kubernetes-pivoting-to-clouds.md b/src/pentesting-cloud/kubernetes-security/kubernetes-pivoting-to-clouds.md index a3cd867d7..5e1f9e9bb 100644 --- a/src/pentesting-cloud/kubernetes-security/kubernetes-pivoting-to-clouds.md +++ b/src/pentesting-cloud/kubernetes-security/kubernetes-pivoting-to-clouds.md @@ -6,7 +6,7 @@ Si estás ejecutando un clúster de k8s dentro de GCP, probablemente querrás que alguna aplicación que se ejecute dentro del clúster tenga acceso a GCP. Hay 2 formas comunes de hacerlo: -### Montando claves GCP-SA como secreto +### Montando claves de GCP-SA como secreto Una forma común de dar **acceso a una aplicación de kubernetes a GCP** es: @@ -23,7 +23,7 @@ Una forma común de dar **acceso a una aplicación de kubernetes a GCP** es: Una forma de dar acceso a un GSA a un clúster de GKE es vinculándolos de esta manera: -- Crear una cuenta de servicio de Kubernetes en el mismo espacio de nombres que tu clúster de GKE usando el siguiente comando: +- Crear una cuenta de servicio de Kubernetes en el mismo namespace que tu clúster de GKE usando el siguiente comando: ```bash Copy codekubectl create serviceaccount ``` @@ -46,7 +46,7 @@ iam.gke.io/gcp-service-account= Con la Identidad de Carga de Trabajo, podemos configurar una [cuenta de servicio de Kubernetes](https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/) para actuar como una [cuenta de servicio de Google](https://cloud.google.com/iam/docs/understanding-service-accounts). Los pods que se ejecutan con la cuenta de servicio de Kubernetes se autenticarán automáticamente como la cuenta de servicio de Google al acceder a las API de Google Cloud. -La **primera serie de pasos** para habilitar este comportamiento es **habilitar la Identidad de Carga de Trabajo en GCP** ([**pasos**](https://medium.com/zeotap-customer-intelligence-unleashed/gke-workload-identity-a-secure-way-for-gke-applications-to-access-gcp-services-f880f4e74e8c)) y crear la SA de GCP que deseas que k8s imite. +La **primera serie de pasos** para habilitar este comportamiento es **habilitar la Identidad de Carga de Trabajo en GCP** ([**pasos**](https://medium.com/zeotap-customer-intelligence-unleashed/gke-workload-identity-a-secure-way-for-gke-applications-to-access-gcp-services-f880f4e74e8c)) y crear la SA de GCP que deseas que k8s impersonifique. - **Habilitar la Identidad de Carga de Trabajo** en un nuevo clúster ```bash @@ -54,7 +54,7 @@ gcloud container clusters update \ --region=us-central1 \ --workload-pool=.svc.id.goog ``` -- **Crear/Actualizar un nuevo nodepool** (los clústeres Autopilot no necesitan esto) +- **Crear/Actualizar un nuevo grupo de nodos** (los clústeres Autopilot no necesitan esto) ```bash # You could update instead of create gcloud container node-pools create --cluster= --workload-metadata=GKE_METADATA --region=us-central1 @@ -143,7 +143,7 @@ done | grep -B 1 "gcp-service-account" Una forma (desactualizada) de dar roles IAM a los Pods es usar un [**Kiam**](https://github.com/uswitch/kiam) o un [**Kube2IAM**](https://github.com/jtblin/kube2iam) **servidor.** Básicamente, necesitarás ejecutar un **daemonset** en tu clúster con un **tipo de rol IAM privilegiado**. Este daemonset será el que dará acceso a los roles IAM a los pods que lo necesiten. -Primero que nada, necesitas configurar **qué roles se pueden acceder dentro del namespace**, y lo haces con una anotación dentro del objeto namespace: +Primero que nada, necesitas configurar **qué roles pueden ser accedidos dentro del namespace**, y lo haces con una anotación dentro del objeto namespace: ```yaml:Kiam kind: Namespace metadata: diff --git a/theme/book.js b/theme/book.js index 1c8d77287..b11674b5a 100644 --- a/theme/book.js +++ b/theme/book.js @@ -590,6 +590,62 @@ function playground_text(playground, hidden = true) { }); })(); + + +(function menubarLanguage() { + var menubarLanguageToggleButton = document.getElementById('menubar-languages-toggle'); + var menubarLanguagePopup = document.getElementById('menubar-languages-popup'); + var languageButtons = menubarLanguagePopup.querySelectorAll('.menu-bar-link'); + + function showLanguage() { + menubarLanguagePopup.style.display = 'flex'; + menubarLanguageToggleButton.setAttribute('aria-expanded', true); + } + + function hideLanguage() { + menubarLanguagePopup.style.display = 'none'; + menubarLanguageToggleButton.setAttribute('aria-expanded', false); + menubarLanguageToggleButton.focus(); + } + + menubarLanguageToggleButton.addEventListener('click', function () { + if (menubarLanguagePopup.style.display === 'flex') { + hideLanguage(); + } else { + showLanguage(); + } + }); + + menubarLanguagePopup.addEventListener('focusout', function(e) { + // e.relatedTarget is null in Safari and Firefox on macOS (see workaround below) + if (!!e.relatedTarget && !menubarLanguageToggleButton.contains(e.relatedTarget) && !menubarLanguagePopup.contains(e.relatedTarget)) { + hideLanguage(); + } + }); + + // Should not be needed, but it works around an issue on macOS & iOS: https://github.com/rust-lang/mdBook/issues/628 + document.addEventListener('click', function(e) { + if (menubarLanguagePopup.style.display === 'block' && !menubarLanguageToggleButton.contains(e.target) && !menubarLanguagePopup.contains(e.target)) { + hideLanguage(); + } + }); + + languageButtons.forEach((btn) => { + btn.addEventListener('click', function(e) { + const regex = /(?:(?:\/)+(?[a-z]{2}(?=\/|$)))?(?(?:\/)*.*)?/g + var match = regex.exec(window.location.pathname) + + var path = match.groups.path + console.log(`Path: ${path} ${typeof path}`) + + const lang = match.groups.lang + console.log(`Lang: ${lang}`) + + window.location = `/${e.target.id}${path}${window.location.hash}` + }); + }) +})(); + (function chapterNavigation() { document.addEventListener('keydown', function (e) { if (e.altKey || e.ctrlKey || e.metaKey || e.shiftKey) { return; } diff --git a/theme/css/chrome.css b/theme/css/chrome.css index 8cbda7c69..17e541163 100644 --- a/theme/css/chrome.css +++ b/theme/css/chrome.css @@ -83,6 +83,13 @@ body.sidebar-visible #menu-bar { } } +.right-buttons .icons { + display: flex; + flex-direction: row; + flex-wrap: wrap; + column-gap: 0.5rem; +} + .icon-button { border: none; background: var(--bg); @@ -138,11 +145,13 @@ body.sidebar-visible #menu-bar { } /* Collapse Menu Popup */ - +#menubar-collapse-toggle { + position: relative; +} #menubar-collapse-popup { position: absolute; - right: 30px; - top: var(--menu-bar-height); + right: 0px; + top: 35px; z-index: 105; border-radius: 5px; font-size: 14px; @@ -172,6 +181,44 @@ body.sidebar-visible #menu-bar { background-color: var(--theme-hover); } +/* Languages Menu Popup */ +#menubar-languages-toggle { + position: relative; +} + +#menubar-languages-popup { + position: absolute; + right: 0px; + top: 35px; + z-index: 105; + border-radius: 5px; + font-size: 14px; + color: var(--fg); + background: var(--bg); + border: 1px solid var(--table-border-color); + margin: 0; + padding: 0px; + display: none; + flex-direction: column; + max-height: 300px; + width: 150px; + overflow: scroll; +} +#menubar-languages-popup .menu-bar-link { + border: 0; + margin: 0; + padding: 8px 20px; + line-height: 25px; + white-space: nowrap; + text-align: start; + cursor: pointer; + color: inherit; + background: inherit; + font-size: inherit; +} +#menubar-languages-popup .menu-bar-link:hover { + background-color: var(--theme-hover); +} .left-buttons { display: flex; diff --git a/theme/index.hbs b/theme/index.hbs index 049bc3ea7..419bb6e7a 100644 --- a/theme/index.hbs +++ b/theme/index.hbs @@ -144,34 +144,60 @@