Files
balikci/README.md
salvacybersec af0510e486 feat: Add Ollama AI integration for automatic mail template generation
 New Features:
- 🤖 AI-powered mail template generation with Ollama
- 📧 Test mail sending with preview
- 🔧 Ollama server and model management
- 🎨 Beautiful AI generation dialog in Templates page
- ⚙️ Ollama settings panel with connection test

Backend:
- Add ollama.service.js - Ollama API integration
- Add ollama.controller.js - Template generation endpoint
- Add ollama.routes.js - /api/ollama/* routes
- Support for multiple Ollama models (llama3.2, mistral, gemma)
- JSON-formatted AI responses with subject + HTML body
- Configurable server URL and model selection

Frontend:
- Settings: Ollama configuration panel
  - Server URL input
  - Model selection
  - Connection test with model listing
- Templates: AI generation dialog
  - Company name, scenario, employee info inputs
  - Custom prompt for AI instructions
  - Auto-save to database
  - Test mail sending functionality

Documentation:
- OLLAMA_SETUP.md - Comprehensive setup guide
- Installation instructions
- Model recommendations
- Usage examples
- Troubleshooting

Tech Stack:
- Ollama API integration (REST)
- Axios HTTP client
- React dialogs with MUI
- Self-hosted AI (privacy-friendly)
- Zero external API dependencies

Example Usage:
  Company: Garanti Bankası
  Scenario: Account security warning
  → AI generates professional phishing test mail in seconds!
2025-11-10 21:13:58 +03:00

264 lines
7.6 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Oltalama Test Yönetim Paneli
Güvenlik farkındalık eğitimleri için basit ve etkili phishing test yönetim sistemi.
## ✨ Özellikler
- 🏢 **Şirket Bazlı Yönetim** - Her şirket için ayrı tracking
- 📧 **Gmail Entegrasyonu** - App Password ile kolay mail gönderimi
- 💬 **Telegram Bildirimleri** - Gerçek zamanlı tıklama bildirimleri
- 🤖 **Ollama AI Entegrasyonu** - AI ile otomatik mail şablonu oluşturma
- 📊 **Detaylı İstatistikler** - IP, konum, cihaz bilgileri
- 💾 **SQLite** - Tek dosya, kolay yedekleme
- 🎨 **Modern UI** - React ile responsive admin paneli
- ✉️ **Mail Şablonları** - HTML editör, önizleme ve test gönderimi
## 🚀 Hızlı Başlangıç
### Backend ✅ TAMAMLANDI
```bash
cd backend
npm install # ✅ Yapıldı
npm run db:migrate # ✅ Yapıldı
npm run db:seed # ✅ Yapıldı
npm run dev # ✅ Çalışıyor (background)
```
**API:** http://localhost:3000
**Default Admin:** Kurulum sırasında oluşturulur
### Frontend ✅ TAMAMLANDI
```bash
cd frontend
npm install # ✅ Yapıldı
npm run dev # ✅ Çalışıyor (background)
```
**UI:** http://localhost:5173
**Default Admin:** Kurulum sırasında oluşturulur
## 📂 Proje Yapısı
```
oltalama/
├── backend/ ✅ TAMAMLANDI (100%)
│ ├── src/
│ │ ├── controllers/ ✅ 7 dosya (auth, company, token, vb.)
│ │ ├── models/ ✅ 6 model + ilişkiler
│ │ ├── routes/ ✅ 7 route dosyası
│ │ ├── services/ ✅ Mail, Telegram, Token, Ollama AI
│ │ ├── utils/ ✅ GeoIP, User-Agent, Token Generator
│ │ └── app.js ✅
│ └── database/ ✅ oltalama.db (3 şirket, 2 şablon)
├── frontend/ ✅ TAMAMLANDI (100%)
│ ├── src/
│ │ ├── services/ ✅ 5 servis (auth, company, token, stats, template)
│ │ ├── context/ ✅ Auth context
│ │ ├── pages/ ✅ 6 sayfa (Login, Dashboard, Companies, Tokens, Templates, Settings)
│ │ └── components/ ✅ Layout + Navigation
└── devpan.md ✅ Detaylı plan
```
## ✅ Backend Tamamlandı (Faz 1-7)
### 1⃣ Authentication ✅
- [x] Session-based auth
- [x] Login/Logout endpoints
- [x] bcrypt password hashing
- [x] Auth middleware
### 2⃣ Company Management ✅
- [x] CRUD operations
- [x] Company stats (auto-update)
- [x] Company tokens listing
- [x] Validators & routes
### 3⃣ Token Management ✅
- [x] Unique token generation (crypto)
- [x] Create with/without mail
- [x] Company stats auto-update
- [x] Click history
### 4⃣ Tracking Endpoint ✅
- [x] `/t/:token` public endpoint
- [x] IP address capture
- [x] GeoIP location (geoip-lite)
- [x] User-Agent parsing
- [x] Landing page redirect
### 5⃣ Telegram & Mail ✅
- [x] Telegram real-time notifications
- [x] Gmail + Nodemailer integration
- [x] Handlebars template rendering
- [x] Test buttons in settings
### 6⃣ Templates & Settings ✅
- [x] Mail templates (2 seeded)
- [x] Template preview
- [x] Settings CRUD
- [x] Gmail/Telegram config
### 7⃣ Stats & Analytics ✅
- [x] Dashboard stats
- [x] Recent clicks
- [x] Company-based stats
- [x] Click logs with full details
## 📡 API Endpoints (35+)
**Backend API çalışıyor:** http://localhost:3000
```
✅ /api/auth/* - 4 endpoints
✅ /api/companies/* - 7 endpoints
✅ /api/tokens/* - 8 endpoints
✅ /api/templates/* - 3 endpoints
✅ /api/settings/* - 5 endpoints
✅ /api/stats/* - 3 endpoints
✅ /t/:token - Public tracking
✅ /health - Health check
```
## 🗄️ Database (SQLite)
**Lokasyon:** `backend/database/oltalama.db`
**6 Tablo - Tamamen İlişkili:**
- ✅ companies (3 örnek: Türk Telekom, İş Bankası, PTT)
- ✅ tracking_tokens (company_id FK)
- ✅ click_logs (IP, GeoIP, User-Agent)
- ✅ mail_templates (2 şablon: Banka, E-Devlet)
- ✅ settings (Gmail, Telegram)
- ✅ admin_user (admin/admin123)
## 🧪 Backend Test
```bash
# Health check
curl http://localhost:3000/health
# Login
curl -X POST http://localhost:3000/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'
# Get companies
curl http://localhost:3000/api/companies
# Get dashboard stats
curl http://localhost:3000/api/stats/dashboard
```
## 📊 Durum
**Backend:** ✅ 100% Tamamlandı (37 dosya)
**Frontend:** ✅ 100% Tamamlandı (15 dosya)
**Dokümantasyon:** ✅ 4 dosya (README.md, devpan.md, KULLANIM.md, QUICKSTART.md)
**Toplam Kaynak Kod:** 58 dosya
**Toplam Satır:** 6677+ satır
**Toplam İlerleme:** ✅ 100% Production Ready
### ✅ Tamamlanan Frontend Sayfaları
**Core Pages:**
- ✅ Login (Session-based auth)
- ✅ Dashboard (Stats, recent clicks)
- ✅ Companies (CRUD, grid view + detail)
- ✅ Tokens (Create & send, detail & history)
- ✅ Mail Şablonları (HTML editör + önizleme)
- ✅ Settings (Gmail, Telegram config)
**Components:**
- ✅ Layout (Sidebar, header, mobile responsive)
- ✅ Auth Context (Global auth state)
- ✅ API Services (5 services)
### 🚀 Proje Hazır!
Sistem kullanıma hazır. Gmail ve Telegram ayarlarını yaparak phishing testlerinizi başlatabilirsiniz.
## 🚀 Sunucu Kurulumu (Production)
### Otomatik Kurulum
```bash
cd /opt/oltalama
sudo ./deploy.sh
```
### Manuel Kurulum
Detaylı sunucu kurulum talimatları için:
```bash
cat DEPLOYMENT.md
```
**Önemli dosyalar:**
- `DEPLOYMENT.md` - Detaylı sunucu kurulum kılavuzu
- `deploy.sh` - Otomatik kurulum scripti
- `systemd/` - Systemd servis dosyaları
- `nginx/` - Nginx konfigürasyon örneği
**Portlar:**
- Backend: `3000` (değiştirilebilir)
- Frontend: `4173` (değiştirilebilir)
**Domain Seçenekleri:**
-**Tek Domain** (önerilen): `yourdomain.com` - Path-based routing
-**İki Domain**: `api.yourdomain.com` + `panel.yourdomain.com` - CORS aktif
**Process Manager:**
- ✅ PM2 (önerilen - otomatik restart, monitoring)
- ✅ Systemd (native Linux service)
**Reverse Proxy:**
- ✅ Nginx Proxy Manager (önerilen - GUI)
- ✅ Nginx (manuel konfig: `nginx/oltalama.conf`)
## 🛠️ Yardımcı Scriptler
### Admin Kullanıcı Yönetimi
```bash
# Yeni admin kullanıcısı oluştur
node scripts/create-admin.js
# Admin şifresini değiştir
node scripts/change-password.js
```
**Özellikler:**
- ✅ İnteraktif kullanıcı oluşturma
- ✅ Şifre güvenlik validasyonu (min 8 karakter, harf+rakam)
- ✅ Benzersiz kullanıcı adı kontrolü
- ✅ Güvenli bcrypt hash'leme
## 📚 Dokümantasyon
- **Ana Doküman:** `README.md` (bu dosya)
- **Sunucu Kurulumu:** `DEPLOYMENT.md` 🚀 (Production kurulum)
- **Ollama AI Entegrasyonu:** `OLLAMA_SETUP.md` 🤖 (AI mail şablon oluşturma)
- **Domain Yapılandırma:** `docs/DOMAIN_SETUP.md` 🌐 (Tek/İki domain)
- **Nginx Proxy Manager:** `docs/NGINX_PROXY_MANAGER.md` 🔄 (Reverse proxy)
- **Güvenlik Rehberi:** `SECURITY.md` 🔒 (Güvenlik en iyi uygulamaları)
- **Hızlı Başlangıç:** `QUICKSTART.md` ⚡ (5 dakika)
- **Kullanım Kılavuzu:** `KULLANIM.md` 📖 (Detaylı)
- **Development Plan:** `devpan.md` 🏗️ (Teknik detay)
- **Backend API:** `backend/README.md`
- **Frontend Guide:** `frontend/README.md`
- **Gmail Setup:** `devpan.md` içinde
- **Telegram Setup:** `devpan.md` içinde
## ⚠️ Güvenlik Uyarısı
Bu sistem yalnızca yasal ve etik phishing testleri için tasarlanmıştır. Kötü niyetli kullanım yasaktır.
---
**Versiyon:** 1.0.0
**Durum:** ✅ Production Ready
**Son Güncelleme:** Backend ve Frontend tamamlandı - Sistem kullanıma hazır!