A Python-based HTTP tarpit designed to slow down malicious bots, collect data about their activities, report them to AbuseIPDB, and provide data for analysis and visualization.
- Asynchronous HTTP Tarpit: Built with
aiohttpto efficiently handle numerous slow connections. - Dynamic Slowdown: Configurable delay and response size to "freeze" clients.
- Detailed Data Collection: Logs IP, port, HTTP method, path, full headers, User-Agent, session duration, etc.
- GeoIP Enrichment: Identifies country, city, coordinates, and ASN інформації for each IP using local MaxMind GeoLite2 databases.
- Structured Storage: Events are stored in a local SQLite database for convenient querying and analysis.
- JSON Logging: Parallel JSON file logging for debugging and potential integration with external logging systems.
- AbuseIPDB Integration: Automatically reports suspicious IPs to AbuseIPDB via their API v2.
- Flexible Configuration: Server parameters, logging, database paths, and API keys are managed via a configuration module and an
.envfile.
- Language: Python (3.10+)
- Async:
asyncio,aiohttp - Project Management:
Poetry - Configuration:
python-dotenv - Geolocation:
geoip2-python - Database:
sqlite3 - Analysis:
pandas - Visualization:
matplotlib,seaborn,folium - Deployment: Nginx, Certbot (Let's Encrypt), Systemd, Docker
- Python 3.10 or newer
- Poetry (Python dependency manager)
-
Clone the repository:
git clone https://github.com/t1a0/http-tarpit.git http-tarpit cd http-tarpit -
Install Poetry (if not already installed): Follow the instructions on the official Poetry website.
-
Install project dependencies:
poetry install --no-dev
-
Configure environment variables: Create a
.envfile in the project root and add your AbuseIPDB API key:# .env ABUSEIPDB_API_KEY=YOUR_ABUSEIPDB_API_KEY
-
Set up GeoIP databases:
- Download the free
GeoLite2-City.mmdbandGeoLite2-ASN.mmdbdatabases from MaxMind. - Create a
data/directory in the project root (if it doesn't exist). - Place the downloaded
.mmdbfiles into thedata/directory.
- Download the free
-
Initialize SQLite Database: The database (
data/tarpit_events.db) and its table will be created automatically on the first run if the DB file doesn't exist.
To start the HTTP tarpit, execute the following command from the project root:
poetry run python main.py