mirror of
https://github.com/HackTricks-wiki/hacktricks-cloud.git
synced 2026-03-12 21:22:57 -07: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
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
{{#include ../../../../banners/hacktricks-training.md}}
|
||||
|
||||
이 권한을 사용하면 **codestar IAM 역할을 악용**하여 **임의의 작업**을 **cloudformation 템플릿**을 통해 수행할 수 있습니다.
|
||||
이 권한을 사용하면 **codestar IAM 역할**을 악용하여 **임의의 작업**을 **cloudformation 템플릿**을 통해 수행할 수 있습니다.
|
||||
|
||||
이를 악용하려면 공격받는 계정에서 **접근 가능한 S3 버킷**을 생성해야 합니다. `toolchain.json`이라는 파일을 업로드합니다. 이 파일에는 **cloudformation 템플릿 악용**이 포함되어야 합니다. 다음 템플릿을 사용하여 귀하의 제어 하에 있는 사용자에게 관리 정책을 설정하고 **관리자 권한을 부여**할 수 있습니다:
|
||||
이를 악용하려면 공격받는 계정에서 **접근 가능한 S3 버킷**을 생성해야 합니다. `toolchain.json`이라는 파일을 업로드합니다. 이 파일에는 **cloudformation 템플릿 악용**이 포함되어야 합니다. 다음 템플릿을 사용하여 귀하의 제어 하에 있는 사용자에게 관리 정책을 설정하고 **관리자 권한**을 부여할 수 있습니다:
|
||||
```json:toolchain.json
|
||||
{
|
||||
"Resources": {
|
||||
@@ -30,11 +30,13 @@
|
||||
```
|
||||
또한 이 `empty zip` 파일을 **버킷**에 **업로드**하세요:
|
||||
|
||||
{% file src="../../../../images/empty.zip" %}
|
||||
{{#file}}
|
||||
empty.zip
|
||||
{{#endfile}}
|
||||
|
||||
**두 파일이 모두 피해자 계정에서 접근 가능해야 한다는 점을 기억하세요**.
|
||||
**두 파일이 모두 피해자 계정에서 접근 가능해야** 한다는 점을 기억하세요.
|
||||
|
||||
두 가지를 업로드한 후, **codestar** 프로젝트를 생성하여 **악용**을 진행할 수 있습니다:
|
||||
두 가지를 업로드한 후, **코드스타** 프로젝트를 생성하여 **악용**을 진행할 수 있습니다:
|
||||
```bash
|
||||
PROJECT_NAME="supercodestar"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user