mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2025-12-06 21:01:11 -08:00
Translated ['src/pentesting-cloud/aws-security/aws-privilege-escalation/
This commit is contained in:
@@ -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"""<a class="content_ref" href="/files/{href}"><span class="content_ref_label">{title}</span></a>"""
|
||||
|
||||
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
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
これらの権限を使用すると、**codestar IAMロールを悪用**して、**任意のアクション**を**cloudformationテンプレート**を通じて実行できます。
|
||||
|
||||
これを悪用するには、攻撃されたアカウントから**アクセス可能なS3バケットを作成**する必要があります。`toolchain.json`という名前のファイルをアップロードします。このファイルには、**cloudformationテンプレートのエクスプロイト**が含まれている必要があります。次のものを使用して、あなたの管理下にあるユーザーに管理ポリシーを設定し、**管理者権限を付与**できます:
|
||||
これを悪用するには、攻撃されたアカウントから**アクセス可能なS3バケット**を作成する必要があります。`toolchain.json`という名前のファイルをアップロードします。このファイルには、**cloudformationテンプレートのエクスプロイト**が含まれている必要があります。次のものを使用して、あなたの管理下にあるユーザーに管理ポリシーを設定し、**管理者権限を付与**できます:
|
||||
```json:toolchain.json
|
||||
{
|
||||
"Resources": {
|
||||
@@ -30,7 +30,9 @@
|
||||
```
|
||||
また、この `empty zip` ファイルを **bucket** に **upload** してください:
|
||||
|
||||
{% file src="../../../../images/empty.zip" %}
|
||||
{{#file}}
|
||||
empty.zip
|
||||
{{#endfile}}
|
||||
|
||||
**両方のファイルが被害者アカウントからアクセス可能なバケットであることを忘れないでください**。
|
||||
|
||||
|
||||
Reference in New Issue
Block a user