Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎉 v2.0.0 Huge Rewrite #112

Merged
merged 135 commits into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
135 commits
Select commit Hold shift + click to select a range
6659069
new file
Sep 30, 2019
7a391db
Maybe temporary main file
Sep 30, 2019
704de2e
Move bucket file for now and get bucket creation working
Sep 30, 2019
1c8440d
Greatly speed up credential checking
Sep 30, 2019
5b0c781
Fix tab issue and bucket name checking
Sep 30, 2019
6e370b9
Stub out next method calls
Sep 30, 2019
6de1686
Update gitignore to ignore all virtualenv's
Dec 14, 2019
25d60a2
Fix bug and create service class
Dec 15, 2019
c33ba26
Fix invalid code
Dec 15, 2019
08f226f
Create new service and start adding bucket methods
Dec 15, 2019
42ab306
check_bucket_exists sets the 'exists' value of the bucket passed
Dec 15, 2019
55ea605
Add AWS creds check
Dec 15, 2019
ad2b928
Get ListBucket permission checking working
Dec 15, 2019
70d8790
Start getting bucket object enumeration working
Dec 15, 2019
8179990
Get object enumeration working and tested
Dec 15, 2019
dbebc19
Implement getHumanReadableSize()
Dec 15, 2019
17e5960
Get read_acl permission checking working
Dec 15, 2019
ceda4e2
Force a bucket existance check before checking for permissions
Dec 15, 2019
a5e1463
Handle no aws creds
Dec 15, 2019
24255e9
Start commenting out refactored code and get scanner working
Dec 15, 2019
abcdd2d
Make decision on bucket permission slots and get ReadACL check working
sa7mon Jan 15, 2020
136d55e
Update list_bucket method to use new permission and fix tests
sa7mon Jan 15, 2020
231dfc4
Disable old tests for now and close #86
sa7mon Jan 15, 2020
36066da
Add check for bucket that allows AllUsers to read ACL. Closes #88
sa7mon Jan 15, 2020
4810b13
Create script to spin up a dangerous bucket temporarily
sa7mon Jan 17, 2020
1d9c715
Set timeout to 1 hour
sa7mon Jan 17, 2020
24cd1b8
Move to a Python file instead so we can use environment variables
sa7mon Jan 17, 2020
a1bc950
Add check for write permission
Jan 17, 2020
685c13b
Add write check test -- needs work
Jan 17, 2020
4ae188c
Merge branch 'enhancements' of github.com:sa7mon/S3Scanner into enhan…
sa7mon Jan 17, 2020
6b847d7
Probably break script
sa7mon Jan 17, 2020
3df52dd
Get ACL parsing working and start renaming permissions
Jan 17, 2020
b0216a7
Rename AllUsers to AuthUsers to align more closely with AWS docs
Jan 17, 2020
826d1b8
Call parse() from the perm_check method and get test working
Jan 17, 2020
cfa22e9
Cleanup and add test cases
Jan 17, 2020
523fdae
Add debug scripts
Feb 19, 2020
2c677d1
Use danger buckets for testing
Feb 19, 2020
9e42396
Ignore vscode folder
sa7mon Feb 19, 2020
46d4ee0
Fix name
sa7mon Feb 19, 2020
e7cac0a
Add argument to service to force no creds used and add test for write…
sa7mon Feb 19, 2020
7797926
Add some documentation. Closes #87
sa7mon Feb 19, 2020
8a7d3a4
Add ACL check method
sa7mon Feb 19, 2020
c6bca80
Add tests for write_acp
sa7mon Feb 19, 2020
d0f0d1f
Multiple permission can't be set when creating buckets apparently
sa7mon Feb 19, 2020
4c6e939
Move to using pytest parameter to choose to do dangerous tests
Jun 15, 2020
10f7934
Add pytest config to ignore collection warnings about TestUtils
Jun 15, 2020
21823d6
Remove standlone scripts
Jun 15, 2020
0b6a378
Fix check_perm_write test
Jun 15, 2020
4bd2173
Configure pytest for multiple test files
Jun 16, 2020
352bc5e
Add getHumanReadablePermissions()
Jun 16, 2020
8f863e2
Move most tests to test_service.py
Jun 16, 2020
3a74649
Add test_bucket for bucket-specific tests and get simple scanner.py w…
Jun 16, 2020
06e4cce
Change output format and skip tests if FullControl is found
Jun 16, 2020
26fda7b
Forgot to check for AllAccessDisabled
Jun 17, 2020
5f93333
Add Disabled check to writeACL check
Jun 17, 2020
2553cc9
Document remaining tests to write
sa7mon Jun 23, 2020
cf2bc03
Add dangerous checks
Jun 23, 2020
a529ce2
Merge branch 'enhancements' of github.com:sa7mon/S3Scanner into enhan…
sa7mon Jun 23, 2020
3277130
Formatting
sa7mon Jun 23, 2020
cc6e2ab
Add danger_bucket_3 for testing WriteACP
sa7mon Jun 24, 2020
5f3af2e
Accept just a bucket name as input
sa7mon Jun 24, 2020
3204aac
Start fixing up write and write_acl tests
sa7mon Jun 24, 2020
1dd5f52
Get check_perm_write_acl working and tested
sa7mon Jun 24, 2020
1265a0e
Add test case for check_perm_write_acl
sa7mon Jun 24, 2020
b66fbf6
Fix reference issue
sa7mon Jun 24, 2020
2ce78f5
Cleanup/move old tests
sa7mon Jun 24, 2020
d595fd9
Cleanup and add test docs
sa7mon Jun 24, 2020
3907fbc
Add custom exception and raise in enumerate_bucket_objects
sa7mon Jun 27, 2020
7bead7c
Cleanup and document tests
sa7mon Jun 27, 2020
6fac572
Fix logic and tests
sa7mon Jun 27, 2020
f011aae
Add test scenario
sa7mon Jun 27, 2020
86ca3cb
Add test scenarios
sa7mon Jun 27, 2020
058b4ee
Add Python 3.8 to Travis config
sa7mon Jun 27, 2020
c209c53
Add test scenarios
sa7mon Jun 27, 2020
447a61d
Finish up test_services scenarios
sa7mon Jun 27, 2020
d7827b7
Lint
sa7mon Jun 27, 2020
60b9d6a
Improve arguments
sa7mon Jun 28, 2020
d861ef1
Trim down requirements and get scanning working again
sa7mon Jun 28, 2020
8b6c41c
Update Travis config
sa7mon Jun 28, 2020
2984e46
Start work on dump mode
sa7mon Jul 1, 2020
d2c8a7b
Get dumping starting
sa7mon Jul 1, 2020
97bfdf2
Get bucket dumping working fully
sa7mon Apr 17, 2021
19ce4a6
Simplify import
sa7mon Apr 17, 2021
5c1ba90
Remove un-needed stuff
sa7mon Apr 17, 2021
4019c62
Improve scanner output template
sa7mon Apr 17, 2021
8fca2c7
Add --verbose argument to dump mode and make output match scan template
sa7mon Apr 17, 2021
4fd051b
Add coverage config and S3Bucket class tests
sa7mon Apr 17, 2021
f00fd77
Get rid of the cruft
sa7mon Apr 17, 2021
b45323a
Add testing for 3.9
sa7mon Apr 17, 2021
cc33e69
Cleanup and reformat log output
sa7mon Apr 17, 2021
1ac411b
Fix log format and ignore some things
sa7mon Apr 18, 2021
b447be4
Add scanner tests
sa7mon Apr 18, 2021
9629c5b
Add scanner tests
sa7mon Apr 18, 2021
3c1aa19
Ignore testutils
sa7mon Apr 18, 2021
5661b68
Get multi-threaded dumping working
sa7mon Apr 18, 2021
7f00e48
Configure threads via arg
sa7mon Apr 18, 2021
9dcee7e
Add docs
sa7mon Apr 18, 2021
9061d15
Add support for s3-compliant services
sa7mon Apr 18, 2021
9ebdf20
Fixed tests if run without aws creds configured
sa7mon Apr 18, 2021
ba633ce
Hopefully fix Travis failure via test folder
sa7mon Apr 18, 2021
9559350
Rename arg and fix default threads
sa7mon Apr 18, 2021
cc192b7
Fix directory and remove debug statement
sa7mon Apr 18, 2021
71acc72
Replace secrets
Apr 18, 2021
562f361
Add experimental Windows build
sa7mon Apr 18, 2021
5e10fc3
Add Windows jobs
sa7mon Apr 18, 2021
70e3107
Remove windows builds
sa7mon Apr 18, 2021
a5d615a
Support endpoints either path or vhost style
sa7mon Apr 18, 2021
0dd63ee
Test endpoints and add custom exception
sa7mon Apr 19, 2021
e3c8b0c
Always scan non-aws buckets anonymously
Apr 19, 2021
35c6cba
Move tests to folder
Apr 19, 2021
ec9b62a
Remove windows python3.9 job as choco doesn't install pip
Apr 19, 2021
c6ef00f
Cleanup service
sa7mon Apr 20, 2021
68e0a73
Add service tests
sa7mon Apr 20, 2021
bc28bd5
Update docstrings
Apr 20, 2021
2ab68df
Update docstrings
Apr 20, 2021
e75c7c2
Update docstrings and add if-main check
Apr 20, 2021
27efeba
Refactor s3Bucket class to S3Bucket
Apr 20, 2021
2dfc7de
Refactor object methods
Apr 20, 2021
46fd567
Refactor class name
Apr 20, 2021
980987d
Refactor method
Apr 20, 2021
a805591
Refactor constants
Apr 20, 2021
23a1e30
Only scan bucket permissions with creds if endpoint is AWS
Apr 20, 2021
8f08e35
Create new readme
Apr 20, 2021
6781c32
Lint
Apr 20, 2021
9d953f2
Move classes into package and fix imports
Apr 20, 2021
efce7d6
Package for pip
Apr 20, 2021
a43177f
Cleanup
Apr 20, 2021
c7fb4b1
Lint
Apr 20, 2021
a3bc5e3
Fix scan issue
Apr 21, 2021
3e74746
Update readme
Apr 21, 2021
99076c2
Use python3.8 in Docker
Apr 21, 2021
e97db9a
Update Dockerfile and readme
Apr 22, 2021
e8d75d0
Check for WriteACP permission
Apr 22, 2021
302ec41
Update readme
Apr 22, 2021
8580d8d
Resolve merge conflicts
Apr 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
venv*
tests/TestUtils.py
22 changes: 18 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
venv/
venv2.7/
# IDE
.idea/
.vscode/

# Virtualenv
venv*/

# Cache
__pycache__
*.pyc
.cache/

# Testing
.pytest_cache
list-buckets/
test/
.coverage
htmlcov/
temp-*/
buckets.txt
test/

# Pip build
build/
dist/
S3Scanner.egg-info/
26 changes: 19 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
language: python
matrix:
jobs:
include:
- python: '3.6'
env:
- secure: QCHu2+V5MO4OtZfBmB9yZVof0NeHK/3CGmErdK/4ICnvfkf4wteYKdDgFsZyzt/ns3BCuP3dZvXEU9p4EEudjMEv66RvPyr+q29JhK42a+HjHP7XAHBMLEENkihtBtrsnfr7NrSgPtfLkG4XaJVyn9mPCvo4JuDotldC4jlAEJqkByKbh5koI4533WOG36pmvO7jcsuqm3+ii7J9PYCRqqbqjvWjt1eJx8ITiBPbJ8+1e32HGWKSMJMJhe2RlxuhglQmOMlZDKrtQ/5u+pgMWtItjP798zJRyKEG8zrt+PM2vgYBeHB9rFMqCmtEO68zpB+HhYXb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0NdjZBEGO7zE1u5c4dxYEctDVvCz/kmH7hl70zajot9cYihh8VLvLwpGBYepTf2a+vhRwdxeZ81KuI3SeOBqNJwyT6wZMw9AfEOmK9LqyS9vBqusujwua+W/DDeqYFo99HkS2uMdX4/IfAB5DDhVakMrff8rrUuf1K1H6rtV7qckOHDET+wdjqymZkPD/mjjW+ibAattls4cZU3I7NRVsnNiZmXAT410A92y6JEiZPuG1djz/57yrqQ3S4KzVhgBq1t5WJRc84dUKCbYnwY4fDL4BH8lkync="
- name: "Python: 3.6"
os: windows
language: shell
before_install:
- choco install python --version=3.6.8
- python -m pip install -U pip setuptools
env: PATH=/c/Python36:/c/Python36/Scripts:$PATH
cache:
directories:
- $LOCALAPPDATA/pip/Cache

cache: pip
install:
- pip install -r requirements.txt
script:
- pytest ./test_scanner.py -s
- pytest -s
notifications:
email: false
email: false
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM python:3-alpine
FROM python:3.8-alpine
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python", "s3scanner.py"]
RUN pip install boto3
RUN pip install .
ENTRYPOINT ["python", "-m", "S3Scanner"]
File renamed without changes.
202 changes: 102 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,134 +1,136 @@
# S3Scanner
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Build Status](https://travis-ci.org/sa7mon/S3Scanner.svg?branch=master)](https://travis-ci.org/sa7mon/S3Scanner)

A tool to find open S3 buckets and dump their contents :droplet:

![1 - s3finder.py](https://user-images.githubusercontent.com/3712226/40662408-e1d19468-631b-11e8-8d69-0075a6c8ab0d.png)

### If you've earned a bug bounty using this tool, please consider donating to support it's development

[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XG5BGLQZPJ9H8)
A tool to find open S3 buckets and dump their contents💧

<img src="https://user-images.githubusercontent.com/3712226/115632654-d4f8c280-a2cd-11eb-87ee-c70bbd4f1edb.png" width="85%"/>

## Usage

<pre>
usage: s3scanner [-h] [-o OUTFILE] [-d] [-l] [--version] buckets

# s3scanner - Find S3 buckets and dump!
#
# Author: Dan Salmon - @bltjetpack, github.com/sa7mon
usage: s3scanner [-h] [--version] [--threads n] [--endpoint-url ENDPOINT_URL] [--endpoint-address-style {path,vhost}] [--insecure] {scan,dump} ...

positional arguments:
buckets Name of text file containing buckets to check
s3scanner: Audit unsecured S3 buckets
by Dan Salmon - github.com/sa7mon, @bltjetpack

optional arguments:
-h, --help show this help message and exit
-o OUTFILE, --out-file OUTFILE
Name of file to save the successfully checked buckets in (Default: buckets.txt)
-d, --dump Dump all found open buckets locally
-l, --list Save bucket file listing to local file: ./list-buckets/${bucket}.txt
--version Display the current version of this tool
--threads n, -t n Number of threads to use. Default: 4
--endpoint-url ENDPOINT_URL, -u ENDPOINT_URL
URL of S3-compliant API. Default: https://s3.amazonaws.com
--endpoint-address-style {path,vhost}, -s {path,vhost}
Address style to use for the endpoint. Default: path
--insecure, -i Do not verify SSL

mode:
{scan,dump} (Must choose one)
scan Scan bucket permissions
dump Dump the contents of buckets
</pre>

The tool takes in a list of bucket names to check. Found S3 buckets are output to file. The tool will also dump or list the contents of 'open' buckets locally.

### Interpreting Results

This tool will attempt to get all available information about a bucket, but it's up to you to interpret the results.
## Support
🚀 If you've found this tool useful, please consider donating to support its development

[Settings available](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/set-bucket-permissions.html) for buckets:
* Object Access (object in this case refers to files stored in the bucket)
* List Objects
* Write Objects
* ACL Access
* Read Permissions
* Write Permissions

Any or all of these permissions can be set for the 2 main user groups:
* Authenticated Users
* Public Users (those without AWS credentials set)
* (They can also be applied to specific users, but that's out of scope)

**What this means:** Just because a bucket returns "AccessDenied" for it's ACLs doesn't mean you can't read/write to it.
Conversely, you may be able to list ACLs but not read/write to the bucket
[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XG5BGLQZPJ9H8)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B54D93O)

## Installation
1. (Optional) `virtualenv venv && source ./venv/bin/activate`
2. `pip install -r requirements.txt`
3. `python ./s3scanner.py`

(Compatibility has been tested with Python 2.7 and 3.6)

### Using Docker
```shell
pip3 install s3scanner
```

1. Build the [Docker](https://docs.docker.com/) image:
or via Docker:

```bash
sudo docker build -t s3scanner https://github.com/sa7mon/S3Scanner.git
```shell
docker build . -t s3scanner:latest
docker run --rm s3scanner:latest scan --bucket my-buket
```

2. Run the Docker image:
or from source:

```bash
sudo docker run -v /input-data-dir/:/data s3scanner --out-file /data/results.txt /data/names.txt
```shell
git clone git@github.com:sa7mon/S3Scanner.git
cd S3Scanner
pip3 install -r requirements.txt
python3 -m S3Scanner
```
This command assumes that `names.txt` with domains to enumerate is in `/input-data-dir/` on host machine.

## Features

* ⚡️ Multi-threaded scanning
* 🔭 Supports tons of S3-compatible APIs
* 🕵️‍♀️ Scans all bucket permissions to find misconfigurations
* 💾 Dump bucket contents to a local folder
* 🐳 Docker support

## Examples
This tool accepts the following type of bucket formats to check:

- bucket name - `google-dev`
- domain name - `uber.com`, `sub.domain.com`
- full s3 url - `yahoo-staging.s3-us-west-2.amazonaws.com` (To easily combine with other tools like [bucket-stream](https://github.com/eth0izzle/bucket-stream))
- bucket:region - `flaws.cloud:us-west-2`

```bash
> cat names.txt
flaws.cloud
google-dev
testing.microsoft.com
yelp-production.s3-us-west-1.amazonaws.com
github-dev:us-east-1
```

1. Dump all open buckets, log both open and closed buckets to found.txt

```bash
> python ./s3scanner.py --include-closed --out-file found.txt --dump names.txt
```
2. Just log open buckets to the default output file (buckets.txt)

```bash
> python ./s3scanner.py names.txt
```
3. Save file listings of all open buckets to file
```bash
> python ./s3scanner.py --list names.txt

```

## Contributing
Issues are welcome and Pull Requests are appreciated. All contributions should be compatible with both Python 2.7 and 3.6.

| master | [![Build Status](https://travis-ci.org/sa7mon/S3Scanner.svg?branch=master)](https://travis-ci.org/sa7mon/S3Scanner) |
|:------------:|:-------------------------------------------------------------------------------------------------------------------------:|
| enhancements | [![Build Status](https://travis-ci.org/sa7mon/S3Scanner.svg?branch=enhancements)](https://travis-ci.org/sa7mon/S3Scanner) |
| bugs | [![Build Status](https://travis-ci.org/sa7mon/S3Scanner.svg?branch=bugs)](https://travis-ci.org/sa7mon/S3Scanner) |

### Testing
* All test are currently in `test_scanner.py`
* Run tests with in 2.7 and 3.6 virtual environments.
* This project uses **pytest-xdist** to run tests. Use `pytest -n NUM` where num is number of parallel processes.
* Run individual tests like this: `pytest -q -s test_scanner.py::test_namehere`

### Contributors

* Scan AWS buckets listed in a file with 8 threads
```shell
$ s3scanner --threads 8 scan --buckets-file ./bucket-names.txt
```
* Scan a bucket in Digital Ocean Spaces
```shell
$ s3scanner --endpoint-url https://sfo2.digitaloceanspaces.com scan --bucket my-bucket
```
* Dump a single AWS bucket
```shell
$ s3scanner dump --bucket my-bucket-to-dump
```
* Scan a single Dreamhost Objects bucket which uses the vhost address style and an invalid SSL cert
```shell
$ s3scanner --endpoint-url https://objects.dreamhost.com --endpoint-address-style vhost --insecure scan --bucket my-bucket
```

## S3-compatible APIs

`S3Scanner` can scan and dump buckets in S3-compatible APIs services other than AWS by using the
`--endpoint-url` argument. Depending on the service, you may also need the `--endpoint-address-style`
or `--insecure` arguments as well.

Some services have different endpoints corresponding to different regions

**Note:** `S3Scanner` currently only supports scanning for anonymous user permissions of non-AWS services

| Service | Example Endpoint | Address Style | Insecure ? |
|---------|------------------|:-------------:|:----------:|
| DigitalOcean Spaces (SFO2 region) | https://sfo2.digitaloceanspaces.com | path | No |
| Dreamhost | https://objects.dreamhost.com | vhost | Yes |
| Linode Object Storage (eu-central-1 region) | https://eu-central-1.linodeobjects.com | vhost | No |
| Scaleway Object Storage (nl-ams region) | https://s3.nl-ams.scw.cloud | path | No |
| Wasabi Cloud Storage | http://s3.wasabisys.com/ | path | Yes |

📚 Current status of non-AWS APIs can be found [in the project wiki](https://github.com/sa7mon/S3Scanner/wiki/S3-Compatible-APIs)

## Interpreting Results

This tool will attempt to get all available information about a bucket, but it's up to you to interpret the results.

[Possible permissions](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/set-bucket-permissions.html) for buckets:

* Read - List and view all files
* Write - Write files to bucket
* Read ACP - Read all Access Control Policies attached to bucket
* Write ACP - Write Access Control Policies to bucket
* Full Control - All above permissions

Any or all of these permissions can be set for the 2 main user groups:
* Authenticated Users
* Public Users (those without AWS credentials set)
* Individual users/groups (out of scope of this tool)

**What this means:** Just because a bucket doesn't allow reading/writing ACLs doesn't mean you can't read/write files in the bucket. Conversely, you may be able to list ACLs but not read/write to the bucket

## Contributors
* [Ohelig](https://github.com/Ohelig)
* [vysecurity](https://github.com/vysecurity)
* [janmasarik](https://github.com/janmasarik)
* [alanyee](https://github.com/alanyee)
* [klau5dev](https://github.com/klau5dev)
* [hipotermia](https://github.com/hipotermia)

## License
License: [MIT](LICENSE.txt) https://opensource.org/licenses/MIT

MIT
Loading