Home

Awesome

Sephiroth

A Python3 script to build cloud block lists for servers.

Last Commit Release Contributors License Docker Downloads Maintainability Code style: black

Requirements

Setup

Python

It is recommended to install sephiroth into a virtual environment. From a brand new Ubuntu 18.04 machine, the setup flow should look something like this:

sudo apt-get install python3 python3-pip && python -m pip install pipenv
mkdir sephiroth && cd sephiroth
pipenv install sephiroth

You can also get the always-latest updates by cloning directly from the repository.

git clone https://github.com/0xdade/sephiroth.git
cd sephiroth
pipenv install .

Docker

Alternatively, we provide a Dockerfile with build and run instructions, or you can fetch the latest version from dockerhub:

docker pull 0xdade/sephiroth
docker run --rm -v $(pwd):/app/output sephiroth -s nginx -t gcp

Usage

Sephiroth provides a built in help menu through the use of Python's argparse library. It tells you which commands are required, as well as other options.

sephiroth on ī‚  master [!] on šŸ³ v19.03.12 via sephiroth via šŸ 3.8.3
āžœ sephiroth --help
usage: Sephiroth [-h] -s {nginx,apache,iptables,ip6tables} -t {aws,azure,gcp,oci,asn,file,tor,do,linode,cloudflare} [-a ASN] [-f FILENAME] [-r REDIR_TARGET] [-p] [--no-ipv6] [--compacted] [-V]

Sephiroth is made to help block clouds.

options:
  -h, --help            show this help message and exit
  -s {nginx,apache,iptables,ip6tables}, --server {nginx,apache,iptables,ip6tables}
                        Type of server to build blocklist for
  -t {aws,azure,gcp,oci,asn,file,tor,do,linode,cloudflare}, --target {aws,azure,gcp,oci,asn,file,tor,do,linode,cloudflare}
                        Targets to block
  -a ASN, --asn ASN     ASN to block in AS#### format
  -f FILENAME, --file FILENAME
                        Files to block addresses from
  -r REDIR_TARGET, --redir REDIR_TARGET
                        Place to redirect requests to. (apache)
  -p, --proxy           Using PROXY Protocol? (nginx)
  --no-ipv6             Exclude ipv6 addresses from the block list where applicable
  --compacted           Compact neighboring cidr ranges. This produces smaller file sizes but loses detail about each range.
  -V, --version         show program's version number and exit

For more information, assistance, or to submit a pull request, please visit https://github.com/0xdade/sephiroth.

Example

sephiroth on ī‚  master [!?] on šŸ³ v19.03.8 via sephiroth took 7s
āžœ sephiroth -s nginx -t asn -a AS15169 -a AS31337 -t aws
(asn) Fetching IP ranges from api.hackertarget.com for 2 ASNs
(aws) Fetching IP ranges from Amazon
Your nginx blocklist for asn, aws can be found at output/2020-06-07_002847_nginx_asn_aws.conf

Please add this line to /etc/nginx/nginx.conf before the Virtual Host Configs.

        include /mnt/c/Users/dade/Desktop/sephiroth/output/2020-06-07_002847_nginx_asn_aws.conf;

Then you can use the $block_ip variable in your site config like so:

        if ($block_ip) {
                return 302 https://example.com;
        }

Supported Servers

Supported Providers

While Sephiroth began as a cloud blocking script, it became apparent that there were plenty of other sources of ip addresses that might be useful, and so we expanded. This is the list of currently supported providers.

Acknowledgements

These are resources I found while building sephiroth that I thought were quite helpful

License

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.