-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created module for enumerating AWS S3 Bucket files.
- Loading branch information
1 parent
ce66a46
commit 7b62645
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |