Skip to content

Commit

Permalink
Fixing Syntax & Downloading AZ Blobs recursively
Browse files Browse the repository at this point in the history
  • Loading branch information
Anon-Exploiter authored May 15, 2024
1 parent a2f1fa3 commit 00e4878
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions pentesting-cloud/azure-security/az-services/az-blob-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,20 @@ from azure.storage.blob import BlobServiceClient
conn_str="<SAS URL>"
svc = BlobServiceClient.from_connection_string(conn_str=conn_str)
for c in svc.list_containers():
print(c['name']
print(c['name'])

# List blobs inside conteiner
container = svc.get_container_client(container="<container_name>")
for b in container.list_blobs():
print(b['name']
# List blobs inside the containers
container = svc.get_container_client(container=c['name'])

# Download file
blob = svc.get_blob_client(container="<container_name>",blob="<blob_name>")
with open("download.out","wb") as f:
f.write(blob.download_blob().readall())
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())
```
{% endcode %}

Expand Down

0 comments on commit 00e4878

Please sign in to comment.