Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/agarzon/badboys
Download bad IP addresses from different sources and block them using iptables and ipset
https://github.com/agarzon/badboys
blacklist chatgpt firewall ipset iptables python whitelist
Last synced: 28 days ago
JSON representation
Download bad IP addresses from different sources and block them using iptables and ipset
- Host: GitHub
- URL: https://github.com/agarzon/badboys
- Owner: agarzon
- License: mit
- Created: 2023-03-15T22:15:29.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2023-12-28T14:03:59.000Z (about 1 year ago)
- Last Synced: 2024-11-05T20:17:07.647Z (3 months ago)
- Topics: blacklist, chatgpt, firewall, ipset, iptables, python, whitelist
- Language: Python
- Homepage:
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Badboys - A simple python script to block bad IP addresses
A very simple python script to get bad IP addresses from a different URL and block them with iptable using ipset.
This script downloads bad IP addresses from different sources, removes whitelisted IPs from the list (supports subnet range CIDR), and then adds the remaining bad IPs to an ipset using the ipset command. It also flushes the existing ipset before adding the new bad IPs to it.
Your machine public IP address is automatically added to the whitelist.
This script was inspired by: https://github.com/trick77/ipset-blacklist which I used for many many years.
But I felt that I want to redo it from scratch and make it more simple and easy to use but with Python.
It worth mentioning that this script was made possible thanks to chatGPT. Even though I do not code in Python, I was able to make this script thanks to chatGPT in no more than 2 hours. Even the logo was made by chatGPT 😮!
The Dockerfile was used for me only during the development phase and it is not needed for the script to work.
## Requirements
- Python 3
- ipset
- iptables# Imstall dependencies
`pip3 install -r requirements.txt`
# Usage
Create your own config.yaml file based on sample.config.yaml and then run the script with:
`python3 badboys.py`
# DEBUG
I use this code to see how many entryes are in the ipset
`ipset list badboys | grep 'Number of entries' | cut -d' ' -f4`
## Licence
MIT License