2026-04-23 22:18:11 +03:00
|
|
|
|
# telegram-rss-bot
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Telegram bot that monitors cybersecurity RSS feeds and delivers real-time alerts. Articles are classified by severity and quality before delivery.
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Project Structure
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
```
|
|
|
|
|
|
rss_telegram_bot/
|
|
|
|
|
|
├── threat_intel_bot.py # Main bot — commands, subscriptions, alert dispatch
|
|
|
|
|
|
├── rss_manager.py # Feed fetching, dedup, message formatting
|
|
|
|
|
|
├── content_classifier.py # Severity/quality scoring, CVE/actor extraction
|
|
|
|
|
|
├── check_feeds.py # CLI utility to check feed health
|
|
|
|
|
|
├── feeds/
|
|
|
|
|
|
│ ├── news_feeds.json
|
|
|
|
|
|
│ ├── malware_feeds.json
|
|
|
|
|
|
│ ├── threat_intel_feeds.json
|
|
|
|
|
|
│ ├── osint_feeds.json
|
|
|
|
|
|
│ └── research_feeds.json
|
|
|
|
|
|
├── .env # Not committed — BOT_TOKEN + optional filters
|
|
|
|
|
|
├── subscribers.json # Auto-managed — chat/topic subscriptions
|
|
|
|
|
|
└── seen_articles.db # SQLite — tracks sent articles (7-day retention)
|
|
|
|
|
|
```
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Setup
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
pip install python-telegram-bot feedparser aiohttp beautifulsoup4
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Create `.env`:
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
```env
|
|
|
|
|
|
BOT_TOKEN=your_token_here
|
|
|
|
|
|
MIN_QUALITY_SCORE=0
|
|
|
|
|
|
ALLOWED_SEVERITIES=critical,high,medium,low
|
2026-03-08 17:32:52 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Run:
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
python3 threat_intel_bot.py
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Bot Commands
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
| Command | Action |
|
|
|
|
|
|
|---|---|
|
|
|
|
|
|
| `/on_<category>` | Subscribe this chat/topic to a category |
|
|
|
|
|
|
| `/off_<category>` | Unsubscribe |
|
|
|
|
|
|
| `/stats` | Check feed health and subscriber count |
|
|
|
|
|
|
| `/help` | Show commands |
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Categories: `news`, `malware`, `threat_intel`, `osint`, `research`
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
**Telegram Topics:** Run `/on_<category>` inside each topic to route categories to separate threads.
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Feed Management
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Each `feeds/*.json` file follows this structure:
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
|
|
|
|
|
```json
|
|
|
|
|
|
{
|
|
|
|
|
|
"category_name": {
|
2026-04-23 22:18:11 +03:00
|
|
|
|
"Feed Display Name": "https://example.com/rss.xml"
|
2026-03-08 17:32:52 +00:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Add or remove feeds by editing the JSON, then restart the bot. Run `python3 check_feeds.py` to verify feed health before deploying.
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Classification
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
**Severity** is keyword-based (title + description):
|
|
|
|
|
|
- `critical` — zero-days, active exploitation, RCE, ransomware
|
|
|
|
|
|
- `high` — privesc, auth bypass, code execution, kernel exploits
|
|
|
|
|
|
- `medium` — XSS, CSRF, DoS, memory corruption
|
|
|
|
|
|
- `low` — everything else
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
**Quality score (0–100)** factors in: source reputation, content length, presence of CVEs, PoC indicators, threat actor mentions, MITRE techniques.
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Filter via env vars:
|
|
|
|
|
|
```env
|
|
|
|
|
|
MIN_QUALITY_SCORE=50
|
|
|
|
|
|
ALLOWED_SEVERITIES=critical,high
|
2026-03-08 17:32:52 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Systemd Service (VPS)
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
`/etc/systemd/system/rss-bot.service`:
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
|
|
|
|
|
```ini
|
|
|
|
|
|
[Unit]
|
2026-04-23 22:18:11 +03:00
|
|
|
|
Description=Threat Intel RSS Telegram Bot
|
2026-03-08 17:32:52 +00:00
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
|
|
Type=simple
|
2026-04-23 22:18:11 +03:00
|
|
|
|
User=your_user
|
|
|
|
|
|
WorkingDirectory=/home/your_user/rss_telegram_bot
|
|
|
|
|
|
EnvironmentFile=/home/your_user/rss_telegram_bot/.env
|
|
|
|
|
|
ExecStart=/usr/bin/python3 threat_intel_bot.py
|
2026-03-08 17:32:52 +00:00
|
|
|
|
Restart=always
|
|
|
|
|
|
RestartSec=10
|
|
|
|
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
|
sudo systemctl daemon-reload
|
2026-04-23 22:18:11 +03:00
|
|
|
|
sudo systemctl enable --now rss-bot
|
|
|
|
|
|
sudo journalctl -u rss-bot -f
|
2026-03-08 17:32:52 +00:00
|
|
|
|
```
|
|
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
## Notes
|
2026-03-08 17:32:52 +00:00
|
|
|
|
|
2026-04-23 22:18:11 +03:00
|
|
|
|
- First run marks all current articles as seen — no flood on startup
|
|
|
|
|
|
- Polling interval: 5 minutes (`asyncio.sleep(300)` in `threat_intel_bot.py`)
|
|
|
|
|
|
- Only today's UTC articles are processed (strict date gate in `rss_manager.py`)
|
|
|
|
|
|
- `seen_articles.db` auto-purges entries older than 7 days
|