diff --git a/hacktricks-preprocessor.py b/hacktricks-preprocessor.py index 7a4dd84a1..0077da80f 100644 --- a/hacktricks-preprocessor.py +++ b/hacktricks-preprocessor.py @@ -1,4 +1,5 @@ import json +import os import sys import re import logging @@ -26,7 +27,7 @@ def findtitle(search ,obj, key, path=(),): def ref(matchobj): - logger.debug(f'Match: {matchobj.groups(0)[0].strip()}') + logger.debug(f'Ref match: {matchobj.groups(0)[0].strip()}') href = matchobj.groups(0)[0].strip() title = href if href.startswith("http://") or href.startswith("https://"): @@ -69,8 +70,39 @@ def ref(matchobj): return result +def files(matchobj): + logger.debug(f'Files match: {matchobj.groups(0)[0].strip()}') + href = matchobj.groups(0)[0].strip() + title = "" + + try: + for root, dirs, files in os.walk(os.getcwd()+'/src/files'): + logger.debug(root) + logger.debug(files) + if href in files: + title = href + logger.debug(f'File search result: {os.path.join(root, href)}') + + except Exception as e: + logger.debug(e) + logger.debug(f'Error searching file: {href}') + print(f'Error searching file: {href}') + sys.exit(1) + + if title=="": + logger.debug(f'Error searching file: {href}') + print(f'Error searching file: {href}') + sys.exit(1) + + template = f"""{title}""" + + result = template + + return result + + def add_read_time(content): - regex = r'(# .*(?=\n))' + regex = r'(<\/style>\n# .*(?=\n))' new_content = re.sub(regex, lambda x: x.group(0) + "\n\nReading time: {{ #reading_time }}", content) return new_content @@ -104,6 +136,8 @@ if __name__ == '__main__': current_chapter = chapter regex = r'{{[\s]*#ref[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endref[\s]*}}' new_content = re.sub(regex, ref, chapter['content']) + regex = r'{{[\s]*#file[\s]*}}(?:\n)?([^\\\n]*)(?:\n)?{{[\s]*#endfile[\s]*}}' + new_content = re.sub(regex, files, chapter['content']) new_content = add_read_time(new_content) chapter['content'] = new_content diff --git a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/iam-passrole-codestar-createproject.md b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/iam-passrole-codestar-createproject.md index ca26cebfb..e2eeb8757 100644 --- a/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/iam-passrole-codestar-createproject.md +++ b/src/pentesting-cloud/aws-security/aws-privilege-escalation/aws-codestar-privesc/iam-passrole-codestar-createproject.md @@ -2,7 +2,7 @@ {{#include ../../../../banners/hacktricks-training.md}} -Con questi permessi puoi **abusare di un ruolo IAM di codestar** per eseguire **azioni arbitrarie** tramite un **template cloudformation**. +Con queste autorizzazioni puoi **abusare di un ruolo IAM di codestar** per eseguire **azioni arbitrarie** tramite un **template cloudformation**. Per sfruttare questo, devi creare un **bucket S3 accessibile** dall'account attaccato. Carica un file chiamato `toolchain.json`. Questo file dovrebbe contenere l'**exploit del template cloudformation**. Il seguente può essere utilizzato per impostare una policy gestita a un utente sotto il tuo controllo e **dargli permessi di amministratore**: ```json:toolchain.json @@ -30,11 +30,13 @@ Per sfruttare questo, devi creare un **bucket S3 accessibile** dall'account atta ``` Carica anche questo `empty zip` file nel **bucket**: -{% file src="../../../../images/empty.zip" %} +{{#file}} +empty.zip +{{#endfile}} Ricorda che il **bucket con entrambi i file deve essere accessibile dall'account della vittima**. -Con entrambi i file caricati, puoi ora procedere all'**exploitation** creando un progetto **codestar**: +Con entrambe le cose caricate, puoi ora procedere all'**exploitation** creando un progetto **codestar**: ```bash PROJECT_NAME="supercodestar"