Git Product home page Git Product logo

s3recon's Introduction

PyPi release PyPi versions Downloads Documentation Status

Amazon S3 bucket finder and crawler.


Check out the s3recon docs

Installation

NOTE: s3recon requires python version >=3.6

$ pip install s3recon

Usage


usage: s3recon [-h] [-o file] [-d] [-p] [-t seconds] [-v] [-c num] word_list [word_list ...]

positional arguments:
  word_list                      read words from one or more <word-list> files

optional arguments:
  -h, --help                     show this help message and exit
  -o file, --output file         write output to <file>
  -d, --db                       write output to database
  -p, --public                   only include 'public' buckets in the output
  -t seconds, --timeout seconds  http request timeout in <seconds> (default: 30)
  -v, --version                  show program's version number and exit
  -c num, --concurrency num      maximum <num> of concurrent requests (default: # of lcpus)
  

Example 1: Output to a json file

1. Download a word-list.

The SecLists repository has a multitude of word-lists to choose from. For this example, let's download the sample word-list included in this repository.

$ curl -sSfL -o "word-list.txt" "https://raw.githubusercontent.com/clarketm/s3recon/master/data/words.txt"

2. Run s3recon.

Execute s3recon using the word-list.txt file and output the public S3 buckets to a json file named results.json.

$ s3recon "word-list.txt" -o "results.json" --public

- PRIVATE https://s3.sa-east-1.amazonaws.com/test-lyft
- PRIVATE https://s3.ap-south-1.amazonaws.com/test.amazon
+ PUBLIC https://walmart-dev.s3.us-east-1.amazonaws.com
- PRIVATE https://s3.ap-southeast-1.amazonaws.com/apple-prod
- PRIVATE https://walmart.s3.ap-southeast-1.amazonaws.com
...

3. Inspect the results.

Check the results.json output file to view the S3 buckets you have discovered!

$ cat "results.json"
{
    "public": {
        "total": 12,
        "hits": [
            "https://walmart-dev.s3.us-east-1.amazonaws.com",
            "https://apple-production.s3.ap-southeast-1.amazonaws.com",
            ...
        ]
    }
}

Note: to include private buckets in the results omit the -p, --public flag from the command.

4. Crawl the results.

Enumerate the static files located in each bucket and record the findings.

Coming soon!

Example 2: Output to a MongoDB database

1. Download a word-list.

The SecLists repository has a multitude of word-lists to choose from. For this example, let's download the sample word-list included in this repository.

$ curl -sSfL -o "word-list.txt" "https://raw.githubusercontent.com/clarketm/s3recon/master/data/words.txt"

2. Start an instance of MongoDB

$ docker run --name "mongo" -p 27017:27017 -v "mongodb_data:/data/db" -v "mongodb_config:/data/configdb" -d mongo

3. Run s3recon.

Execute s3recon using the word-list.txt file and output to MongoDB instance.

$ s3recon "word-list.txt" --db

- PRIVATE https://s3.sa-east-1.amazonaws.com/test-lyft
- PRIVATE https://s3.ap-south-1.amazonaws.com/test.amazon
+ PUBLIC https://walmart-dev.s3.us-east-1.amazonaws.com
- PRIVATE https://s3.ap-southeast-1.amazonaws.com/apple-prod
- PRIVATE https://walmart.s3.ap-southeast-1.amazonaws.com
...

3. Inspect the results.

Check the MongoDB database: s3recon collection: hits to view the S3 buckets you have discovered!

$ mongo "s3recon" --quiet --eval 'db.hits.find({}, {"url": 1, "access": 1, "_id": 0}).limit(5)'
{ "url" : "https://s3.us-east-2.amazonaws.com/apple", "access" : "private" }
{ "url" : "https://s3.us-west-1.amazonaws.com/microsoft-dev", "access" : "private" }
{ "url" : "https://s3.us-west-1.amazonaws.com/dev-microsoft", "access" : "private" }
{ "url" : "https://s3.us-east-2.amazonaws.com/amazon", "access" : "private" }
{ "url" : "https://s3.us-east-1.amazonaws.com/dev-amazon", "access" : "private" }

4. Crawl the results.

Enumerate the static files located in each bucket and record the findings.

Coming soon!

FAQ

Q: How do I configure this utility?

A:

s3recon can be configure using a yaml configuration file located in either the current working directory (e.g. ./s3recon.yml) or your home diretory (e.g. ~/s3recon.yml).

The following is the list of configurable values:

# s3recon.yml

database: { host: "0.0.0.0", ... }
  
separators: ["-", "_", "."]

environments: ["", "backup", "backups", ...]

regions: ["ap-northeast-1", "ap-northeast-2", ...]

To see the full list of configurable values (and their defaults) please refer to the s3recon.yml file in this repository.

Q: How do I customize the AWS regions used in the recon?

A:

The AWS regions can be altered by setting the regions array in your s3recon.yml configuration file.

# s3recon.yml

regions: [ "us-west-2", ...]

Q: How do I customize the environment values used in the recon?

A:

The environments are modifiers permuted with each item of the word-list (and the separator) to construct the bucket value in request. The value can be altered by setting the environments array in your s3recon.yml configuration file.

For example, to only search lines from the word-list verbatim (i.e. without modification) you can set this value to an empty array.

# s3recon.yml

environments: []

Q: How do I customize the MongoDB host and port?

A:

The database host and port can be configured by altering the database map in your s3recon.yml configuration file.

For example, host and port can be set directly inside the database map

# s3recon.yml

database: {
  host: "0.0.0.0",
  port: 27017
}

Q: How do I use a database other than MongoDB?

A:

Sorry, at the moment only MongoDB is supported.

Going Forward

  • Create crawl command to crawl public/private buckets found in find stage.
  • Separate out find and crawl as subcommands.
  • Store discovered buckets in a NoSQL database.

Disclaimer

This tools is distributed for educational and security purposes. I take no responsibility and assume no liability for the manner in which this tool is used.

License

MIT © Travis Clarke

s3recon's People

Contributors

clarketm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

s3recon's Issues

I am having this error while installing

$ pip install s3recon
Collecting s3recon
Downloading https://files.pythonhosted.org/packages/9c/d4/d762d5b5ece8b91de38a26ef63bc90237cd4c4fd0c48d5f9bcdd89b7fbd1/s3recon-1.1.2.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "/tmp/pip-install-Z4l4PM/s3recon/setup.py", line 11, in
with open_local(["s3recon", "init.py"]) as f:
File "/tmp/pip-install-Z4l4PM/s3recon/setup.py", line 8, in open_local
return open(path, mode=mode, encoding=encoding)
TypeError: 'encoding' is an invalid keyword argument for this function

----------------------------------------

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-Z4l4PM/s3recon/

pymongo errors when running s3recon

I am getting these errors when I run the s3recon command.

Traceback (most recent call last):
  File "/usr/local/bin/s3recon", line 10, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.7/dist-packages/s3recon/s3recon.py", line 212, in cli
    main(words=words, timeout=timeout, output=output, use_db=db, only_public=public)
  File "/usr/local/lib/python3.7/dist-packages/s3recon/s3recon.py", line 118, in main
    db = MongoDB(host=database["host"], port=database["port"])
  File "/usr/local/lib/python3.7/dist-packages/s3recon/mongodb.py", line 78, in __init__
    self.index(unique_indicies, unique=True)
  File "/usr/local/lib/python3.7/dist-packages/s3recon/mongodb.py", line 86, in index
    self.client[self.db_name][self.col_name].ensure_index(i, **kwargs)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/collection.py", line 2004, in ensure_index
    self.__create_index(keys, kwargs, session=None)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/collection.py", line 1860, in __create_index
    with self._socket_for_writes() as sock_info:
  File "/usr/local/lib/python3.7/dist-packages/pymongo/collection.py", line 197, in _socket_for_writes
    return self.__database.client._socket_for_writes()
  File "/usr/local/lib/python3.7/dist-packages/pymongo/mongo_client.py", line 1121, in _socket_for_writes
    server = self._get_topology().select_server(writable_server_selector)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/topology.py", line 226, in select_server
    address))
  File "/usr/local/lib/python3.7/dist-packages/pymongo/topology.py", line 184, in select_servers
    selector, server_timeout, address)
  File "/usr/local/lib/python3.7/dist-packages/pymongo/topology.py", line 200, in _select_servers_loop
    self._error_message(selector))
pymongo.errors.ServerSelectionTimeoutError: 0.0.0.0:27017: [Errno 111] Connection refused

Support Python2

Currently, s3recon only supports python3 due to the use of several python3-specific libraries, features, and idioms. It would be beneficial to users if the project worked with both python2 and python3.

Memory Leak heads up

When scanning with a large list ~9000 it will eat all available RAM I have 32GBs and 31 of it was used. I can also make a PR if that helps :)

Docker error

While trying to install on Docker I am getting the following error.

Collecting s3recon
  Downloading https://files.pythonhosted.org/packages/9c/d4/d762d5b5ece8b91de38a26ef63bc90237cd4c4fd0c48d5f9bcdd89b7fbd1/s3recon-1.1.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-V5dzlT/s3recon/setup.py", line 11, in <module>
        with open_local(["s3recon", "__init__.py"]) as f:
      File "/tmp/pip-build-V5dzlT/s3recon/setup.py", line 8, in open_local
        return open(path, mode=mode, encoding=encoding)
    TypeError: 'encoding' is an invalid keyword argument for this function

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.