Sephiroth
A Python3 script to build cloud block lists for servers.
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,caddy,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,caddy,iptables,ip6tables}, --server {nginx,apache,caddy,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
nginx- Makes use of nginx'sngx_http_geo_modulewhich comes with the nginx package in Ubuntu 18.04. Optionally supports the use ofproxy_protocol, in the event that you are using a PROXY-enabled redirector.apache- Generates a mod_rewrite rule set to do conditional redirects based on cloud ip ranges. Does not (to my knowledge) supportproxy_protocolusage. Requires-r REDIR_TARGETfor the RewriteRulecaddy- Generates a list of IP addresses, each prepended with theremote_iprequest matcher.iptables- Generates a set of iptables DROP rules to block access from listed IPv4 ranges.ip6tables- Generates a set of ip6tables DROP rules to block access from listed IPv6 ranges.
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.
aws- Amazon Web Services. Obtained via the documented download process.azure- Azure Cloud. Fetched via a two part process. Fetch the html of the download page and then parse the html to get thefailoverLinkanchor tag. That JSON is then downloaded.gcp- Google Cloud Platform. Fetches thecloud.jsonas documented via the docs.oci- Oracle Cloud Infrastructure. Fetched via the documented download processasn- Lookup IP ranges by ASN. Uses Hackertarget API to make fetching results painless. Limited to 100 ASN lookups per day per source IP.file- Read line-separated list of addresses from one or more files. Lines that begin with # are ignored and lines that contain a # after the address save the comment into the output.tor- Fetch the bulk list of Tor exit nodes from the torproject.org website and add them to the list.do- Digital Ocean. Fetched fromgoogle.csvas documented on the Platform page.linode- Linode. Fetched from geoip.linode.comcloudflare- Cloudflare. Fetched from documented API
Setup
Python
It is recommended to install sephiroth into its own virtual environment using a tool like pipx.
pipx install sephiroth
You can also get the always-latest updates by cloning directly from the repository, however this installation requires setting up uv to install the dependencies needed.
git clone https://github.com/0xdade/sephiroth.git
cd sephiroth
uv sync
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
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.
Metadata
Release files for sephiroth 1.0.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sephiroth-1.0.6.tar.gz | 11.9 kB | With provenance | Details for sephiroth-1.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sephiroth-1.0.6-py3-none-any.whl | Python 3 | none | any | Details for sephiroth-1.0.6-py3-none-any.whl |
Total release size: 33.9 kB
Release files / sephiroth-1.0.6.tar.gz
| Download URL | sephiroth-1.0.6.tar.gz |
|---|---|
| Size | 11.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f44d4ac36abc294b3805b0c5157a3374e15b911c2022c143998565295140e471
|
|
BLAKE2b-256 checksum How to use checksums |
3e360f43158ab6b29e451bdefff3f6655db8ce0e2be986dc9a297cfb2b56d1c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2025.
Transparency logRelease files / sephiroth-1.0.6-py3-none-any.whl
| Download URL | sephiroth-1.0.6-py3-none-any.whl |
|---|---|
| Size | 22.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e26ad4aa0839b62608465ec4280a893646f57fe409e4fdb366d33e75600eac76
|
|
BLAKE2b-256 checksum How to use checksums |
8d65e98b927a2a2df3563a333b9110d75535603840d8a343a9ca6c75ba214069
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.8
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2025.
Transparency logSecurity for sephiroth 1.0.6
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for sephiroth-1.0.6.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 16, 2025.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.