Thousands of S3 buckets are left open on the internet, which makes them an easy target for bad people who want to get private information from the files in these buckets that can be tied to a person or an organization.
There isn’t much study or software that can use these S3 buckets to find secret exposures and search text files for specific keywords or regular expression patterns.
BucketLoot is an automated S3 Bucket Inspector that can scan all the text files in an open S3 bucket on systems like AWS, DigitalOcean, etc. at the same time.
It checks the text files that are out in the open for:
The end user can even look for string-based keywords or provide custom regular expression patterns that can be matched with the contents of these text files.
BucketLoot is a great recon tool for both bug hunters and experienced pentesters because of all of these things.
The tool lets users save the output in a JSON format, which makes it easier to use the data as an input in a third-party product or platform.
The tool is written in Go, so make sure to install it on your system before proceeding. The setup is pretty easy and straight forward.
Just follow the below steps in order to quickly install and get the binary working.
Firstly clone the repo to any directory/path of your liking,
git clone https://github.com/redhuntlabs/BucketLoot.git
Afer this, just run the following command in order to build the binary according to your environment.
go build
In order to setup the tool for the full scan mode (optional), you need to modify the credentials.json file and add the credentials for the target platforms for whom you would like to run a full scan against.
At the moment, BucketLoot only supports AWS for running full mode scans, and we expect the release of another one or two modules for other platforms very soon.
In order to run the AWS module for the full scan mode, you need to generate the Access Key and Secret Key from the IAM Dashboard by heading to the users section, clicking on any user you would like to use for the tool, going to the Security Credentials tab, clicking on the create access key button, choosing “Third-party service” and finally creating the accees key.
Make sure that the user has the “AmazonS3FullAccess” permission policy attached, since its absence may lead to errors and issues with the scan.
In order to run a basic scan without any extra flags, you just need to provide a target URL or target(s) file as an argument.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/
OR
umair@redhuntlabs:~/bucketloot$ ./bucketloot targets.txt
BucketLoot also offers several additional flags that can help customise your scan and get the right results that you need.
umair@redhuntlabs:~/bucketloot$ ./bucketloot -h
Usage of ./bucketloot:
-full
Go beyond the 1000 file scan limit [Requires additional setup!]
-log-errors
Log errors in final output
-max-size string
Maximum file size (in bytes)
-save string
Save tool output, should either end with .txt or .json [Default output file name is output.json]
-search string
Keyword(s) to look for during the scan. [Possible values -> keyword, keyword1:::keyword2, keywords.txt]
-slow
Set slow mode for the scan
If you would like to go beyond the maximum 1000 files per bucket limit, you can run BucketLoot’s Full scan mode by setting up the target platform’s access credentials.
Currently we only support full scan mode for Amazon Web Services and expect to release the modules for other platforms very soon.
If for some reason, during the full scan, the tool encounters any authentication or permission issue, it will automatically switch back to scraping mode for that individual bucket.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -full
BucketLoot allows users to save all the errors it encountered during the scan within the tool output. This can be helpful especially during the debugging process and can even help us to understand the reported issues better.
The flag creates an additional array named Errors within the JSON output.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -log-errors
Often users can encounter buckets that contain huge files. This can add up to the scan completion time and might not be an ideal scenario for systems with less bandwidth.
The -max-size flag allows users to provide the maximum file size which they would like to scan for (in bytes).
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -max-size 13521
Saves the JSON output that your tool generates for users to go through or parse for further processing. The tool saves the output in a file named output.json by default if the flag is provided. User has the ability to provide custom output file names, either in .txt or .json format.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -save
OR
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -save myscan.json
Users can use the -search flag in order to query for specific keywords or regular expressions within the file contents from an exposed storage bucket. There are several ways through which the keywords can be passed to the tool.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -search 'admin'
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -search 'admin:::login:::password:::API:::.*dev-instance'
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -search queries.txt
Designed for systems with low network bandwidth where the consistency of results is important, the -slow flag allows to run all the scans sequentially instead of concurrently [Fast mode] which is the default behavious of the tool.
Although this would definitely increase the overall scan time, the tool will provide consistent results while also making sure that it can run hassle-free locally.
umair@redhuntlabs:~/bucketloot$ ./bucketloot https://myvulninstance.s3.amazonaws.com/ -slow
BucketLoot returns a JSON output at the end of every scan. The tool has the following structure:
type bucketLootOpStruct struct {
Results []struct {
BucketUrl string `json:"bucketUrl"`
Assets []struct {
URL string `json:"url"`
Domain string `json:"domain"`
Subdomain string `json:"subdomain"`
} `json:"Assets"`
Secrets []struct {
Name string `json:"name"`
URL string `json:"url"`
} `json:"Secrets"`
Keywords []struct {
URL string `json:"url"`
Keyword string `json:"keyword"`
Type string `json:"type"`
} `json:"Keywords,omitempty"`
} `json:"Results"`
Version string `json:"version"`
Scanned []string `json:"Scanned"`
Skipped []string `json:"Skipped"`
Errors []string `json:"Errors,omitempty"`
}
The Keywords and Errors array only show up when their respective flags are provided as an input and thus omitted if empty.
Here, Results is an array storing the scan data for every individual misconfigured bucket that was scanned and from whom results were derivedd. The unique identifier here is the BucketURL field.
Outside of the array we have the version field containing the tool version, Scanned is an array showing the URLs that successfully got scanned, Skipped stores all the URLs which werne’t scanned either because they were not valid S3 endpoints, were private or had some issue while making a request.
The errors array (optional) stores all the errors caught during the scan as raw strings.
Here’s an example output for a basic scan to give you a glimpse of how the tool works,
➜ bucketloot git:(master) ✗ ./bucketloot https://bucketloot-testing.blr1.digitaloceanspaces.com/
,.--'''''''''--., ____ _ _ _ _
(\'-.,_____,.-'/) | _ \ | | | | | | | |
\\-.,_____,.-// | |_) |_ _ ___| | _____| |_| | ___ ___ | |_
;\\ //| | _ <| | | |/ __| |/ / _ \ __| | / _ \ / _ \| __|
| \\ ___ // | | |_) | |_| | (__| < __/ |_| |___| (_) | (_) | |_
| '-[___]-' | |____/ \__,_|\___|_|\_\___|\__|______\___/ \___/ \__|
| |
| | An Automated S3 Bucket Inspector
| | Developed by Umair Nehri (@umair9747) and Owais Shaikh (@4f77616973)
''-.,_____,.-''
Processing arguments...
Discovered a total of 3 bucket files...
Total bucket files of interest: 3
Starting to scan the files... [FAST]
Discovered SECRET[AWS Access Key ID Value] in https://bucketloot-testing.blr1.digitaloceanspaces.com/credentials.json
Discovered SECRET[AWS Access Key ID] in https://bucketloot-testing.blr1.digitaloceanspaces.com/credentials.json
Discovered URL(s) in https://bucketloot-testing.blr1.digitaloceanspaces.com/credentials.json
Discovered SECRET[Google API key] in https://bucketloot-testing.blr1.digitaloceanspaces.com/config.php
Discovered URL(s) in https://bucketloot-testing.blr1.digitaloceanspaces.com/dashboard.html
Discovered URL(s) in https://bucketloot-testing.blr1.digitaloceanspaces.com/config.php
{
"Results": [
{
"bucketUrl": "https://bucketloot-testing.blr1.digitaloceanspaces.com/",
"Assets": [
{
"url": "https://blackhat.com/",
"domain": "blackhat.com",
"subdomain": ""
},
{
"url": "https://certificates.blackhat.com/",
"domain": "blackhat.com",
"subdomain": "certificates.blackhat.com"
},
{
"url": "https://google.com/login",
"domain": "google.com",
"subdomain": ""
},
{
"url": "https://firecat.toolswatch.org/",
"domain": "toolswatch.org",
"subdomain": "firecat.toolswatch.org"
},
{
"url": "https://www.google.com",
"domain": "google.com",
"subdomain": "www.google.com"
},
{
"url": "http://example.com/dashboard",
"domain": "example.com",
"subdomain": ""
},
{
"url": "https://www.openai.com",
"domain": "openai.com",
"subdomain": "www.openai.com"
},
{
"url": "https://www.example.com/admin",
"domain": "example.com",
"subdomain": "www.example.com"
},
{
"url": "https://www.example.com/login.php",
"domain": "example.com",
"subdomain": "www.example.com"
},
{
"url": "https://www.example.com/reset-password",
"domain": "example.com",
"subdomain": "www.example.com"
},
{
"url": "https://example.com/api/endpoint",
"domain": "example.com",
"subdomain": ""
}
],
"Secrets": [
{
"name": "AWS Access Key ID Value",
"url": "https://bucketloot-testing.blr1.digitaloceanspaces.com/credentials.json"
},
{
"name": "AWS Access Key ID",
"url": "https://bucketloot-testing.blr1.digitaloceanspaces.com/credentials.json"
},
{
"name": "Google API key",
"url": "https://bucketloot-testing.blr1.digitaloceanspaces.com/config.php"
}
]
}
],
"version": "1.0",
"Scanned": [
"https://bucketloot-testing.blr1.digitaloceanspaces.com/"
],
"Skipped": null
}
Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…
This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…
GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…
Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…
The free and open-source security platform SecHub, provides a central API to test software with…
Don't worry if there are any bugs in the tool, we will try to fix…