Az - Blob Storage

Support HackTricks

기본 정보

문서에서 발췌: Azure Blob storage는 Microsoft의 클라우드용 객체 스토리지 솔루션입니다. Blob storage는 대량의 비정형 데이터를 저장하는 데 최적화되어 있습니다. 비정형 데이터는 특정 데이터 모델이나 정의를 따르지 않는 데이터로, 텍스트나 바이너리 데이터가 이에 해당합니다.

Blob storage는 세 가지 유형의 리소스를 제공합니다:

  • 스토리지 계정 (고유 이름)

  • 스토리지 계정 내의 컨테이너 (폴더)

  • 컨테이너 내의 blob

다양한 스토리지 유형

Blob storage

https://<storage-account>.blob.core.windows.net https://<stg-acc>.blob.core.windows.net/<container-name>?restype=container&comp=list

Azure Data Lake Storage Gen2

https://<storage-account>.dfs.core.windows.net

Azure Files

https://<storage-account>.file.core.windows.net

Queue storage

https://<storage-account>.queue.core.windows.net

Table storage

https://<storage-account>.table.core.windows.net

스토리지 접근

  • RBAC 역할을 통해 Azure AD 주체 사용.

  • 액세스 키: 스토리지 계정의 액세스 키 사용. 이는 스토리지 계정에 대한 전체 액세스를 제공합니다.

  • 공유 액세스 서명 (SAS): 시간 제한 및 특정 권한.

  • 액세스 키로 SAS URL을 생성할 수 있습니다 (탐지하기 더 복잡함).

  • SAS는 액세스 키에서 생성되므로, 키가 갱신되면 SAS는 작동을 멈춥니다.

공개 노출

"Allow Blob public access"가 활성화된 경우 (기본적으로 비활성화됨), 다음이 가능합니다:

  • blob 읽기에 대한 공개 액세스 제공 (이름을 알아야 함).

  • 컨테이너 blob 목록읽기.

스토리지 연결

어떤 스토리지를 찾으면 Microsoft Azure Storage Explorer 도구를 사용하여 연결할 수 있습니다.

SAS URLs

문서에서 발췌: 공유 액세스 서명 (SAS)은 스토리지 계정의 리소스에 대한 안전한 위임 액세스를 제공합니다. SAS를 사용하면 클라이언트가 데이터에 어떻게 액세스할 수 있는지에 대해 세밀한 제어가 가능합니다. 예를 들어:

  • 클라이언트가 액세스할 수 있는 리소스.

  • 해당 리소스에 대한 권한.

  • SAS의 유효 기간.

SAS URL은 다음과 같습니다: https://<container_name>.blob.core.windows.net/newcontainer?sp=r&st=2021-09-26T18:15:21Z&se=2021-10-27T02:14:21Z&spr=https&sv=2021-07-08&sr=c&sig=7S%2BZySOgy4aA3Dk0V1cJyTSIf1cW%2Fu3WFkhHV32%2B4PE%3D

Storage Explorer를 사용하여 데이터에 액세스하거나 python을 사용하세요:

#pip3 install azure-storage-blob
from azure.storage.blob import BlobServiceClient

# List containers
conn_str="<SAS URL>"
svc = BlobServiceClient.from_connection_string(conn_str=conn_str)
for c in svc.list_containers():
print(c['name'])

# List blobs inside the containers
container = svc.get_container_client(container=c['name'])

for b in container.list_blobs():
print(b['name'])


# Download all the blobs
blob_name = b['name'].split("/")[::-1][0]
blob = svc.get_blob_client(container=c['name'],blob=b['name'])
with open(blob_name,"wb") as f:
f.write(blob.download_blob().readall())

User delegation SAS

공유 액세스 서명(SAS) 토큰을 컨테이너, 디렉터리 또는 blob에 대한 액세스를 위해 Azure Active Directory (Azure AD) 자격 증명 또는 계정 키를 사용하여 보안할 수 있습니다. 사용자 위임 SAS를 생성하려면 먼저 사용자 위임 키를 요청한 다음 이 키를 사용하여 SAS에 서명해야 합니다.

**User Delegation Shared Access Signature (SAS)**는 Azure Blob StorageAzure Data Lake Storage Gen2에서 지원됩니다. 그러나 Stored Access Policies는 사용자 위임 SAS와 호환되지 않는다는 점에 유의해야 합니다.

사용자 위임 SAS는 스토리지 계정 키 대신 Azure AD 자격 증명으로 보안된다는 점에 유의하십시오. 이는 클라이언트/애플리케이션이 SAS를 생성하기 위해 스토리지 키를 저장/검색하는 것을 방지합니다.

Service SAS

서비스 SAS는 스토리지 계정 키로 보안됩니다. 서비스 SAS는 Azure Storage 서비스 중 하나의 리소스에 대한 액세스를 위임합니다: Blob storage, Queue storage, Table storage, 또는 Azure Files. 서비스 수준 SAS의 URI는 SAS가 액세스를 위임할 리소스에 대한 URI와 SAS 토큰으로 구성됩니다.

Azure Active Directory (Azure AD) 자격 증명을 사용하여 컨테이너 또는 blob에 대한 SAS를 보안하려면 사용자 위임 SAS를 사용하십시오.

Account SAS

계정 SAS는 두 개의 스토리지 계정 키 중 하나로 보안됩니다. 계정 SAS는 하나 이상의 스토리지 서비스에서 리소스에 대한 액세스를 위임합니다. 서비스 또는 사용자 위임 SAS를 통해 사용할 수 있는 모든 작업은 계정 SAS를 통해서도 사용할 수 있습니다.

문서에서 발췌: 계정 SAS를 생성함으로써 다음을 수행할 수 있습니다:

  • 서비스별 SAS로는 현재 사용할 수 없는 Get/Set Service PropertiesGet Service Stats 작업과 같은 서비스 수준 작업에 대한 액세스를 위임합니다.

  • 한 번에 스토리지 계정의 둘 이상의 서비스에 대한 액세스를 위임합니다. 예를 들어, 계정 SAS를 사용하여 Azure Blob Storage와 Azure Files의 리소스에 대한 액세스를 위임할 수 있습니다.

  • 객체별 SAS로는 사용할 수 없는 컨테이너, 큐, 테이블 및 파일 공유에 대한 쓰기 및 삭제 작업에 대한 액세스를 위임합니다.

  • 요청을 수락할 IP 주소 또는 IP 주소 범위를 지정합니다.

  • 요청을 수락할 HTTP 프로토콜을 지정합니다 (HTTPS 또는 HTTP/HTTPS).

Enumeration

# Get storage accounts
az storage account list #Get the account name from here

# Get keys to authenticate
az storage account keys list --account-name <name>

# Get shares
az storage share list --account-name <name> --account-key <key>

# Get dirs/files inside the share
az storage file list --account-name <name> --share-name <share-name> --account-key <key>
## If type is "dir", you can continue enumerationg files inside of it
az storage file list --account-name <name> --share-name <prev_dir/share-name> --account-key <key>

# Download a complete share (with directories and files inside of them)
az storage file download-batch -d . --source <share-name> --account-name <name> --account-key <key>

References

HackTricks 지원하기

Last updated