Skip to content

Commit

Permalink
Created module for enumerating AWS S3 Bucket files.
Browse files Browse the repository at this point in the history
  • Loading branch information
aconite33 authored and TheTechromancer committed Nov 14, 2023
1 parent ce66a46 commit 7b62645
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions bbot/modules/bucket_enum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from bbot.modules.base import BaseModule
import xml.etree.ElementTree as ET

class bucket_enum(BaseModule):
"""
Enumerate files in a public bucket
"""
scope_distance_modifier = 1
watched_events = ["STORAGE_BUCKET"]
produced_events = ["BUCKET_FILE"]
flags = ["passive", "safe", "cloud-enum"]

async def handle_event(self, event):
url = event.data["url"]
response = await self.helpers.request(url)
if response.status_code == 200:
content = response.text
root = ET.fromstring(content)
namespace = {'s3': 'http://s3.amazonaws.com/doc/2006-03-01/'}
keys = [key.text for key in root.findall('.//s3:Key', namespace)]
self.hugesuccess(f"Keys: {keys}")
for key in keys:
bucket_file = url + "/" + key
self.emit_event(bucket_file, "BUCKET_FILE", source=event)

0 comments on commit 7b62645

Please sign in to comment.