janiel01 commited on
Commit
99e98ea
·
verified ·
1 Parent(s): 232038c

Upload 18 files

Browse files
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Copiar dependências primeiro (melhor aproveitamento do cache do Docker)
6
+ COPY requirements.txt .
7
+ RUN pip install --no-cache-dir -r requirements.txt
8
+
9
+ # Copiar o restante do projeto
10
+ COPY . .
11
+
12
+ # HF Spaces expõe a porta 7860
13
+ EXPOSE 7860
14
+
15
+ CMD ["python", "app.py"]
agents/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+
agents/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (171 Bytes). View file
 
agents/__pycache__/html_agent.cpython-311.pyc ADDED
Binary file (5.31 kB). View file
 
agents/__pycache__/orchestrator.cpython-311.pyc ADDED
Binary file (4.4 kB). View file
 
agents/__pycache__/text_agent.cpython-311.pyc ADDED
Binary file (3.42 kB). View file
 
agents/__pycache__/url_agent.cpython-311.pyc ADDED
Binary file (3.21 kB). View file
 
agents/__pycache__/vision_agent.cpython-311.pyc ADDED
Binary file (1.9 kB). View file
 
agents/html_agent.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from bs4 import BeautifulSoup
2
+ import requests
3
+ import logging
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+ class HTMLStructuralAgent:
8
+ def __init__(self):
9
+ self.name = "HTML Structural Analyzer"
10
+
11
+ def _fetch_html(self, url):
12
+ try:
13
+ # Tentar buscar a página com um timeout curto
14
+ response = requests.get(url, timeout=5, headers={'User-Agent': 'Mozilla/5.0'})
15
+ return response.text
16
+ except Exception as e:
17
+ logger.warning(f"Não foi possível buscar HTML da URL {url}: {e}")
18
+ return None
19
+
20
+ def analyze(self, html_content=None, url=None):
21
+ """
22
+ Analisa a estrutura do HTML em busca de anomalias comuns em phishing.
23
+ Pode receber o HTML diretamente ou uma URL para tentar buscar.
24
+ """
25
+ if not html_content and url:
26
+ html_content = self._fetch_html(url)
27
+
28
+ if not html_content:
29
+ return {"agent": self.name, "score": 0, "findings": ["HTML não disponível para análise"], "result": "Neutral"}
30
+
31
+ try:
32
+ soup = BeautifulSoup(html_content, 'html.parser')
33
+ score = 0
34
+ findings = []
35
+
36
+ # 1. Verificar campos de senha em sites sem HTTPS (se tivermos a URL)
37
+ if url and not url.startswith('https'):
38
+ if soup.find('input', {'type': 'password'}):
39
+ score += 0.8
40
+ findings.append("Campo de senha encontrado em conexão não segura (HTTP)")
41
+
42
+ # 2. Verificar formulários que apontam para domínios diferentes
43
+ forms = soup.find_all('form')
44
+ for form in forms:
45
+ action = form.get('action', '').lower()
46
+ if action.startswith('http') and url:
47
+ from urllib.parse import urlparse
48
+ action_domain = urlparse(action).netloc
49
+ current_domain = urlparse(url).netloc
50
+ if action_domain != current_domain:
51
+ score += 0.5
52
+ findings.append(f"Formulário enviando dados para domínio externo: {action_domain}")
53
+
54
+ # 3. Presença de tags estranhas ou ocultas
55
+ hidden_elements = soup.find_all(style=lambda value: value and ('display:none' in value.replace(' ', '') or 'visibility:hidden' in value.replace(' ', '')))
56
+ if len(hidden_elements) > 5:
57
+ score += 0.2
58
+ findings.append("Muitos elementos ocultos detectados (possível tentativa de ofuscação)")
59
+
60
+ # 4. Links externos massivos (muitos links apontando para fora)
61
+ links = soup.find_all('a', href=True)
62
+ if len(links) > 0:
63
+ external_links = [l for l in links if l['href'].startswith('http')]
64
+ if len(external_links) / len(links) > 0.8:
65
+ score += 0.3
66
+ findings.append("Alta proporção de links externos")
67
+
68
+ # Normalizar score
69
+ final_score = min(max(score, 0), 1.0)
70
+ result = "Phishing" if final_score > 0.4 else "Legítima"
71
+
72
+ return {
73
+ "agent": self.name,
74
+ "score": final_score,
75
+ "result": result,
76
+ "findings": findings
77
+ }
78
+ except Exception as e:
79
+ logger.error(f"Erro na análise do HTMLStructuralAgent: {e}")
80
+ return {"agent": self.name, "score": 0, "findings": [f"Erro ao processar HTML: {str(e)}"], "result": "Error"}
agents/orchestrator.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agents.url_agent import URLLexicalAgent
2
+ from agents.text_agent import NLPTextAgent
3
+ from agents.html_agent import HTMLStructuralAgent
4
+ from agents.vision_agent import VisionAgent
5
+ import logging
6
+
7
+ logger = logging.getLogger(__name__)
8
+
9
+ class PhishingOrchestrator:
10
+ def __init__(self):
11
+ logger.info("Inicializando Orquestrador de Agentes...")
12
+ self.url_agent = URLLexicalAgent()
13
+ self.text_agent = NLPTextAgent()
14
+ self.html_agent = HTMLStructuralAgent()
15
+ self.vision_agent = VisionAgent()
16
+ logger.info("Todos os agentes foram inicializados.")
17
+
18
+ def analyze_full(self, url=None, text=None, html=None, image_data=None):
19
+ """
20
+ Executa uma análise completa usando todos os agentes disponíveis.
21
+ """
22
+ results = []
23
+
24
+ # 1. Análise de URL
25
+ if url:
26
+ results.append(self.url_agent.analyze(url))
27
+
28
+ # 2. Análise de Texto (NLP)
29
+ if text:
30
+ results.append(self.text_agent.analyze(text))
31
+ elif url and not text:
32
+ results.append(self.text_agent.analyze(url))
33
+
34
+ # 3. Análise de HTML
35
+ if html or url:
36
+ results.append(self.html_agent.analyze(html_content=html, url=url))
37
+
38
+ # 4. Análise de Visão (Imagem)
39
+ if image_data:
40
+ results.append(self.vision_agent.analyze(image_data=image_data))
41
+
42
+ # 5. Consolidação (Ensemble)
43
+ final_verdict = self._consolidate(results)
44
+
45
+ return {
46
+ "verdict": final_verdict["result"],
47
+ "risk_score": final_verdict["score"],
48
+ "agent_details": results,
49
+ "summary": final_verdict["summary"]
50
+ }
51
+
52
+ def _consolidate(self, results):
53
+ """
54
+ Consolida os resultados dos agentes em uma decisão final.
55
+ """
56
+ if not results:
57
+ return {"result": "Desconhecido", "score": 0, "summary": "Nenhum dado fornecido."}
58
+
59
+ total_score = 0
60
+ weights = {
61
+ "URL Lexical Analyzer": 0.25,
62
+ "NLP Text Analyzer": 0.35,
63
+ "HTML Structural Analyzer": 0.25,
64
+ "Vision Analysis Agent": 0.15
65
+ }
66
+
67
+ total_weight = 0
68
+ agent_results = []
69
+
70
+ for res in results:
71
+ agent_name = res.get("agent", "Unknown Agent")
72
+ weight = weights.get(agent_name, 0.25)
73
+ score = res.get("score", 0)
74
+ total_score += score * weight
75
+ total_weight += weight
76
+ agent_results.append(f"{agent_name}: {res.get('result', 'Unknown')} ({score:.2f})")
77
+
78
+ # ... rest of consolidation logic ...
79
+
80
+ # Média ponderada
81
+ final_score = total_score / total_weight if total_weight > 0 else 0
82
+
83
+ # Veredito baseado no score consolidado
84
+ if final_score > 0.6:
85
+ result = "Phishing"
86
+ summary = "Alta probabilidade de fraude detectada por múltiplos agentes."
87
+ elif final_score > 0.4:
88
+ result = "Suspeito"
89
+ summary = "Padrões anômalos detectados. Recomenda-se cautela extrema."
90
+ else:
91
+ result = "Legítima"
92
+ summary = "A análise não encontrou evidências significativas de phishing."
93
+
94
+ return {
95
+ "result": result,
96
+ "score": final_score,
97
+ "summary": summary
98
+ }
agents/text_agent.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import pipeline
2
+ import logging
3
+
4
+ logger = logging.getLogger(__name__)
5
+
6
+ class NLPTextAgent:
7
+ def __init__(self, model_name="ealvaradob/bert-finetuned-phishing"):
8
+ self.name = "NLP Text Analyzer"
9
+ self.model_name = model_name
10
+ self.pipe = self._load_model()
11
+
12
+ def _load_model(self):
13
+ try:
14
+ logger.info(f"Carregando modelo para {self.name}: {self.model_name}...")
15
+ pipe = pipeline("text-classification", model=self.model_name)
16
+ logger.info(f"Modelo {self.model_name} carregado com sucesso.")
17
+ return pipe
18
+ except Exception as e:
19
+ logger.error(f"Erro ao carregar o modelo NLP: {e}")
20
+ return None
21
+
22
+ def analyze(self, text):
23
+ """
24
+ Analisa o conteúdo textual (e-mail ou corpo da página) usando NLP.
25
+ """
26
+ if not text or len(text.strip()) < 10:
27
+ return {"agent": self.name, "score": 0, "findings": ["Texto insuficiente para análise NLP"], "result": "Neutral"}
28
+
29
+ if self.pipe is None:
30
+ return {"agent": self.name, "score": 0, "findings": ["Modelo NLP não disponível"], "result": "Error"}
31
+
32
+ try:
33
+ # Predição usando a pipeline do Transformers
34
+ # Nota: truncamos o texto para o limite do modelo (geralmente 512 tokens)
35
+ prediction = self.pipe(text[:512])[0]
36
+
37
+ label = prediction['label'].lower()
38
+ confidence = prediction['score']
39
+
40
+ # Mapeamento (depende do modelo, mas geralmente LABEL_1 ou 'phishing')
41
+ is_phishing = "phishing" in label or "1" in label
42
+ result = "Phishing" if is_phishing else "Legítima"
43
+
44
+ # Ajustamos o score para ser positivo para phishing
45
+ score = confidence if is_phishing else (1 - confidence)
46
+
47
+ return {
48
+ "agent": self.name,
49
+ "score": float(score),
50
+ "result": result,
51
+ "findings": [f"Confiança do modelo ({self.model_name}): {confidence:.2%}"]
52
+ }
53
+ except Exception as e:
54
+ logger.error(f"Erro na análise do NLPTextAgent: {e}")
55
+ return {"agent": self.name, "score": 0, "findings": [f"Erro interno: {str(e)}"], "result": "Error"}
agents/url_agent.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+ from urllib.parse import urlparse
3
+
4
+ class URLLexicalAgent:
5
+ def __init__(self):
6
+ self.name = "URL Lexical Analyzer"
7
+
8
+ def analyze(self, url):
9
+ """
10
+ Analisa a URL em busca de padrões lexicais suspeitos.
11
+ """
12
+ if not url:
13
+ return {"score": 0, "findings": ["URL não fornecida"], "result": "Neutral"}
14
+
15
+ parsed = urlparse(url)
16
+ netloc = parsed.netloc
17
+ path = parsed.path
18
+
19
+ score = 0
20
+ findings = []
21
+
22
+ # 1. Verificar IPs em vez de nomes de domínio
23
+ ip_pattern = r"^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$"
24
+ if re.match(ip_pattern, netloc):
25
+ score += 0.8
26
+ findings.append("Uso de endereço IP em vez de domínio")
27
+
28
+ # 2. Comprimento da URL
29
+ if len(url) > 75:
30
+ score += 0.3
31
+ findings.append("URL excessivamente longa")
32
+
33
+ # 3. Número de pontos no domínio (subdomínios excessivos)
34
+ dot_count = netloc.count('.')
35
+ if dot_count > 3:
36
+ score += 0.4
37
+ findings.append(f"Número elevado de subdomínios ({dot_count})")
38
+
39
+ # 4. Presença de caracteres suspeitos (@ ou hífens excessivos)
40
+ if "@" in url:
41
+ score += 0.7
42
+ findings.append("Uso de símbolo '@' (frequentemente usado para mascarar URLs)")
43
+
44
+ if netloc.count('-') > 2:
45
+ score += 0.2
46
+ findings.append("Muitos hífens no domínio")
47
+
48
+ # 5. Palavras-chave suspeitas no domínio ou path
49
+ suspicious_keywords = ["login", "verify", "update", "secure", "account", "bank", "pay", "paypal", "signin"]
50
+ found_keywords = [kw for kw in suspicious_keywords if kw in url.lower()]
51
+ if found_keywords:
52
+ score += 0.2 * len(found_keywords)
53
+ findings.append(f"Palavras-chave suspeitas encontradas: {', '.join(found_keywords)}")
54
+
55
+ # Normalizar score (cap em 1.0)
56
+ final_score = min(max(score, 0), 1.0)
57
+ result = "Phishing" if final_score > 0.5 else "Legítima"
58
+
59
+ return {
60
+ "agent": self.name,
61
+ "score": final_score,
62
+ "result": result,
63
+ "findings": findings
64
+ }
agents/vision_agent.py ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+
4
+ logger = logging.getLogger(__name__)
5
+
6
+ class VisionAgent:
7
+ def __init__(self):
8
+ self.name = "Vision Analysis Agent"
9
+
10
+ def analyze(self, image_data=None, image_path=None):
11
+ """
12
+ Analisa uma imagem em busca de padrões de phishing.
13
+ Para esta versão inicial, focamos em metadados e detecção básica.
14
+ """
15
+ score = 0
16
+ findings = []
17
+
18
+ if not image_data and not image_path:
19
+ return {
20
+ "agent": self.name,
21
+ "score": 0,
22
+ "result": "Neutral",
23
+ "findings": ["Nenhuma imagem fornecida para análise."]
24
+ }
25
+
26
+ try:
27
+ # Lógica simulada de Visão Computacional / OCR
28
+ # Em uma implementação real, usaríamos bibliotecas como Tesseract, OpenCV
29
+ # ou modelos como CLIP/ViT.
30
+
31
+ # Simulação: Se for uma captura de tela de login (placeholder logic)
32
+ findings.append("Análise visual concluída: Padrões estruturais de página de login detectados.")
33
+
34
+ # Exemplo de verificação de 'suspicion'
35
+ # (Aqui poderíamos adicionar lógica de OCR para capturar texto da imagem)
36
+
37
+ return {
38
+ "agent": self.name,
39
+ "score": 0.2, # Score baixo por enquanto (análise básica)
40
+ "result": "Legítima",
41
+ "findings": findings
42
+ }
43
+ except Exception as e:
44
+ logger.error(f"Erro na análise de visão: {e}")
45
+ return {
46
+ "agent": self.name,
47
+ "score": 0,
48
+ "result": "Error",
49
+ "findings": [f"Erro ao processar imagem: {str(e)}"]
50
+ }
app.py ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify, render_template
2
+ from flask_cors import CORS
3
+ from flask_sqlalchemy import SQLAlchemy
4
+ from datetime import datetime
5
+ import logging
6
+ import os
7
+
8
+ # Configuração de logging
9
+ logging.basicConfig(
10
+ level=logging.INFO,
11
+ format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
12
+ )
13
+ logger = logging.getLogger(__name__)
14
+
15
+ # Configurações
16
+ MODEL_NAME = "ealvaradob/bert-finetuned-phishing"
17
+
18
+ # Caminho absoluto para o banco de dados (melhor compatibilidade no Windows)
19
+ basedir = os.path.abspath(os.path.dirname(__file__))
20
+ db_path = os.path.join(basedir, 'phishing_history.db')
21
+
22
+ # Inicializar o Flask
23
+ app = Flask(__name__,
24
+ static_folder='static',
25
+ template_folder='templates')
26
+ CORS(app)
27
+
28
+ # Banco de Dados
29
+ app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + db_path.replace('\\', '/')
30
+ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
31
+ db = SQLAlchemy(app)
32
+
33
+ class ScannedURL(db.Model):
34
+ id = db.Column(db.Integer, primary_key=True)
35
+ url = db.Column(db.String(500), nullable=False)
36
+ result = db.Column(db.String(50), nullable=False)
37
+ confidence = db.Column(db.Float)
38
+ description = db.Column(db.Text)
39
+ timestamp = db.Column(db.DateTime, default=datetime.utcnow)
40
+
41
+ def to_dict(self):
42
+ return {
43
+ 'id': self.id,
44
+ 'url': self.url,
45
+ 'result': self.result,
46
+ 'confidence': round(self.confidence * 100, 2) if self.confidence else None,
47
+ 'description': self.description,
48
+ 'timestamp': self.timestamp.strftime('%H:%M - %d/%m/%Y')
49
+ }
50
+
51
+ # Criar banco de dados se não existir
52
+ with app.app_context():
53
+ db.create_all()
54
+
55
+ from agents.orchestrator import PhishingOrchestrator
56
+
57
+ # ... (logging and db config remain the same)
58
+
59
+ # Inicializar o Orquestrador Multi-Agente
60
+ orchestrator = PhishingOrchestrator()
61
+
62
+ @app.route('/')
63
+ def index():
64
+ return render_template('index.html')
65
+
66
+ @app.route('/predict', methods=['POST'])
67
+ def predict():
68
+ try:
69
+ # Check for multi-part form data (for images) or JSON
70
+ if request.is_json:
71
+ data = request.get_json()
72
+ else:
73
+ data = request.form.to_dict()
74
+
75
+ url = data.get('url', '').strip()
76
+ text = data.get('text', '').strip()
77
+ html = data.get('html', '').strip()
78
+
79
+ image_data = None
80
+ if 'image' in request.files:
81
+ file = request.files['image']
82
+ if file.filename != '':
83
+ # Process small images in memory or save them
84
+ image_data = file.read()
85
+ elif 'image_b64' in data:
86
+ import base64
87
+ image_data = base64.b64decode(data['image_b64'].split(',')[-1])
88
+
89
+ logger.info(f"Analisando Multi-Modal: URL={url}, Text={bool(text)}, HTML={bool(html)}, Image={bool(image_data)}")
90
+
91
+ if not any([url, text, html, image_data]):
92
+ return jsonify({'error': 'Nenhum dado fornecido para análise.'}), 400
93
+
94
+ # Executar análise multi-modal
95
+ results = orchestrator.analyze_full(url=url, text=text, html=html, image_data=image_data)
96
+
97
+ result = results['verdict']
98
+ confidence = results['risk_score']
99
+ description = results['summary']
100
+
101
+ # Salvar no Banco de Dados (usamos a URL ou um placeholder se for só texto/imagem)
102
+ record_url = url if url else f"Analysis: {datetime.now().strftime('%H:%M:%S')}"
103
+ try:
104
+ new_scan = ScannedURL(
105
+ url=record_url,
106
+ result=result,
107
+ confidence=confidence,
108
+ description=description
109
+ )
110
+ db.session.add(new_scan)
111
+ db.session.commit()
112
+ except Exception as db_err:
113
+ logger.error(f"Erro ao salvar no banco: {db_err}")
114
+
115
+ response = {
116
+ 'result': result,
117
+ 'url': record_url,
118
+ 'description': description,
119
+ 'confidence': round(confidence * 100, 2),
120
+ 'agent_details': results['agent_details']
121
+ }
122
+
123
+ return jsonify(response)
124
+
125
+ except Exception as e:
126
+ logger.error(f"Erro ao processar requisição multi-modal: {e}")
127
+ return jsonify({'error': 'Erro interno do servidor.'}), 500
128
+
129
+ @app.route('/history', methods=['GET'])
130
+ def get_history():
131
+ try:
132
+ # Pega as últimas 10 análises
133
+ history = ScannedURL.query.order_by(ScannedURL.timestamp.desc()).limit(10).all()
134
+ return jsonify([item.to_dict() for item in history])
135
+ except Exception as e:
136
+ logger.error(f"Erro ao buscar histórico: {e}")
137
+ return jsonify({'error': 'Erro ao buscar histórico.'}), 500
138
+
139
+ @app.route('/stats', methods=['GET'])
140
+ def get_stats():
141
+ try:
142
+ total = ScannedURL.query.count()
143
+ phishing = ScannedURL.query.filter_by(result='Phishing').count()
144
+ suspect = ScannedURL.query.filter_by(result='Suspeito').count()
145
+ safe = ScannedURL.query.filter(ScannedURL.result.in_(['Legítima', 'Safe'])).count()
146
+
147
+ # Média de confiança
148
+ from sqlalchemy import func
149
+ avg_conf = db.session.query(func.avg(ScannedURL.confidence)).scalar() or 0
150
+
151
+ # Taxa de detecção (phishing + suspeito / total)
152
+ detection_rate = round(((phishing + suspect) / total * 100), 1) if total > 0 else 0
153
+
154
+ # Últimas 7 análises para o mini-gráfico
155
+ recent = ScannedURL.query.order_by(ScannedURL.timestamp.desc()).limit(7).all()
156
+ timeline = [{'date': r.timestamp.strftime('%d/%m'), 'result': r.result} for r in reversed(recent)]
157
+
158
+ return jsonify({
159
+ 'total': total,
160
+ 'phishing': phishing,
161
+ 'suspect': suspect,
162
+ 'safe': safe,
163
+ 'detection_rate': detection_rate,
164
+ 'avg_confidence': round(avg_conf * 100, 1),
165
+ 'timeline': timeline
166
+ })
167
+ except Exception as e:
168
+ logger.error(f"Erro ao buscar estatísticas: {e}")
169
+ return jsonify({'error': 'Erro ao buscar estatísticas.'}), 500
170
+
171
+ if __name__ == '__main__':
172
+ app.run(host='0.0.0.0', port=7860, debug=False)
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ flask
2
+ flask-cors
3
+ flask-sqlalchemy
4
+ requests
5
+ beautifulsoup4
static/script.js ADDED
@@ -0,0 +1,447 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ document.addEventListener('DOMContentLoaded', () => {
2
+ const urlForm = document.getElementById('url-form');
3
+ const urlInput = document.getElementById('url-input');
4
+ const textInput = document.getElementById('text-input');
5
+ const htmlInput = document.getElementById('html-input');
6
+ const imageUpload = document.getElementById('image-upload');
7
+ const imagePreview = document.getElementById('image-preview');
8
+ const previewImg = document.getElementById('preview-img');
9
+ const removeImageBtn = document.getElementById('remove-image');
10
+
11
+ const analyzeBtn = document.getElementById('analyze-btn');
12
+ const loadingSpinner = document.getElementById('loading');
13
+ const resultCard = document.getElementById('result-card');
14
+
15
+ const omniPlusBtn = document.getElementById('omni-plus-btn');
16
+ const omniMenu = document.getElementById('omni-menu');
17
+ const omniMenuItems = document.querySelectorAll('.omni-menu-item');
18
+
19
+ const sidebar = document.querySelector('.sidebar');
20
+ const sidebarToggle = document.getElementById('sidebar-toggle');
21
+ const navAnalyzer = document.getElementById('nav-analyzer');
22
+
23
+ let currentMode = 'url';
24
+ let selectedFile = null;
25
+
26
+ // --- Sidebar & Navigation ---
27
+ const overlay = document.createElement('div');
28
+ overlay.className = 'sidebar-overlay';
29
+ document.body.appendChild(overlay);
30
+
31
+ // All sidebar toggle buttons (analyzer page + stats page)
32
+ document.querySelectorAll('.sidebar-toggle-btn').forEach(btn => {
33
+ btn.addEventListener('click', () => {
34
+ const isActive = sidebar.classList.toggle('active');
35
+ overlay.style.display = isActive ? 'block' : 'none';
36
+ });
37
+ });
38
+
39
+ overlay.addEventListener('click', () => {
40
+ sidebar.classList.remove('active');
41
+ overlay.style.display = 'none';
42
+ });
43
+
44
+ // Close button inside sidebar
45
+ const sidebarClose = document.getElementById('sidebar-close');
46
+ if (sidebarClose) {
47
+ sidebarClose.addEventListener('click', () => {
48
+ sidebar.classList.remove('active');
49
+ overlay.style.display = 'none';
50
+ });
51
+ }
52
+
53
+ if (navAnalyzer) {
54
+ navAnalyzer.addEventListener('click', (e) => {
55
+ e.preventDefault();
56
+ showPage('analyzer');
57
+ if (window.innerWidth <= 1024) sidebar.classList.remove('active');
58
+ overlay.style.display = 'none';
59
+ });
60
+ }
61
+
62
+ // --- Page Navigation ---
63
+ const analyzerPage = document.querySelector('.main-content:not(#stats-page)');
64
+ const statsPage = document.getElementById('stats-page');
65
+ const navStats = document.getElementById('nav-stats');
66
+ const statsBackBtn = document.getElementById('stats-back-btn');
67
+
68
+ function showPage(page) {
69
+ if (page === 'stats') {
70
+ analyzerPage.classList.add('d-none');
71
+ statsPage.classList.remove('d-none');
72
+ navAnalyzer.classList.remove('active');
73
+ navStats.classList.add('active');
74
+ fetchStats();
75
+ } else {
76
+ statsPage.classList.add('d-none');
77
+ analyzerPage.classList.remove('d-none');
78
+ navStats.classList.remove('active');
79
+ navAnalyzer.classList.add('active');
80
+ }
81
+ window.scrollTo({ top: 0, behavior: 'smooth' });
82
+ }
83
+
84
+ if (navStats) {
85
+ navStats.addEventListener('click', (e) => {
86
+ e.preventDefault();
87
+ showPage('stats');
88
+ if (window.innerWidth <= 1024) sidebar.classList.remove('active');
89
+ overlay.style.display = 'none';
90
+ });
91
+ }
92
+
93
+ if (statsBackBtn) {
94
+ statsBackBtn.addEventListener('click', () => showPage('analyzer'));
95
+ }
96
+
97
+ // --- Omni-Menu Logic ---
98
+ omniPlusBtn.addEventListener('click', (e) => {
99
+ e.stopPropagation();
100
+ omniMenu.classList.toggle('active');
101
+ });
102
+
103
+ document.addEventListener('click', () => {
104
+ omniMenu.classList.remove('active');
105
+ });
106
+
107
+ omniMenuItems.forEach(item => {
108
+ item.addEventListener('click', () => {
109
+ const mode = item.dataset.mode;
110
+ if (mode) switchMode(mode);
111
+ omniMenu.classList.remove('active');
112
+ });
113
+ });
114
+
115
+ function switchMode(mode) {
116
+ currentMode = mode;
117
+
118
+ // Hide all
119
+ urlInput.classList.add('d-none');
120
+ textInput.classList.add('d-none');
121
+ htmlInput.classList.add('d-none');
122
+
123
+ // Remove 'required' from all
124
+ urlInput.removeAttribute('required');
125
+ textInput.removeAttribute('required');
126
+ htmlInput.removeAttribute('required');
127
+
128
+ // Show selected
129
+ if (mode === 'url') {
130
+ urlInput.classList.remove('d-none');
131
+ urlInput.setAttribute('required', '');
132
+ urlInput.focus();
133
+ } else if (mode === 'text') {
134
+ textInput.classList.remove('d-none');
135
+ textInput.setAttribute('required', '');
136
+ textInput.focus();
137
+ } else if (mode === 'html') {
138
+ htmlInput.classList.remove('d-none');
139
+ htmlInput.setAttribute('required', '');
140
+ htmlInput.focus();
141
+ }
142
+ }
143
+
144
+ // --- File/Image Handling ---
145
+ imageUpload.addEventListener('change', (e) => {
146
+ const file = e.target.files[0];
147
+ if (file && file.type.startsWith('image/')) {
148
+ selectedFile = file;
149
+ const reader = new FileReader();
150
+ reader.onload = (e) => {
151
+ previewImg.src = e.target.result;
152
+ imagePreview.classList.remove('d-none');
153
+ };
154
+ reader.readAsDataURL(file);
155
+ }
156
+ });
157
+
158
+ removeImageBtn.addEventListener('click', () => {
159
+ selectedFile = null;
160
+ imageUpload.value = '';
161
+ imagePreview.classList.add('d-none');
162
+ });
163
+
164
+ // --- Analysis Submission ---
165
+ urlForm.addEventListener('submit', async (e) => {
166
+ e.preventDefault();
167
+
168
+ const url = urlInput.value.trim();
169
+ const text = textInput.value.trim();
170
+ const html = htmlInput.value.trim();
171
+
172
+ if (currentMode === 'url' && !url && !selectedFile) return;
173
+ if (currentMode === 'text' && !text) return;
174
+ if (currentMode === 'html' && !html) return;
175
+
176
+ // Reset UI
177
+ resultCard.style.display = 'none';
178
+ loadingSpinner.style.display = 'block';
179
+ analyzeBtn.disabled = true;
180
+
181
+ try {
182
+ const formData = new FormData();
183
+ if (currentMode === 'url' && url) formData.append('url', url);
184
+ if (currentMode === 'text' && text) formData.append('text', text);
185
+ if (currentMode === 'html' && html) formData.append('html', html);
186
+ if (selectedFile) formData.append('image', selectedFile);
187
+
188
+ const response = await fetch('/predict', {
189
+ method: 'POST',
190
+ body: formData // Fetch automatically sets content-type for FormData
191
+ });
192
+
193
+ const data = await response.json();
194
+
195
+ if (data.error) {
196
+ showError(data.error);
197
+ } else {
198
+ showResult(data);
199
+ fetchHistory();
200
+ }
201
+ } catch (error) {
202
+ showError('Erro ao conectar com o serviço de análise multi-modal.');
203
+ console.error(error);
204
+ } finally {
205
+ loadingSpinner.style.display = 'none';
206
+ analyzeBtn.disabled = false;
207
+ }
208
+ });
209
+
210
+ function showResult(data) {
211
+ const isPhishing = data.result === 'Phishing';
212
+ const isSuspect = data.result === 'Suspeito';
213
+ const colorClass = isPhishing ? 'is-phishing' : (isSuspect ? 'text-warning' : 'is-safe');
214
+ const borderColor = isPhishing ? 'var(--danger)' : (isSuspect ? 'orange' : 'var(--success)');
215
+ const icon = isPhishing ? 'fa-shield-virus' : (isSuspect ? 'fa-exclamation-triangle' : 'fa-shield-check');
216
+ const statusText = isPhishing ? 'Potencial Phishing' : (isSuspect ? 'Análise Suspeita' : 'URL Legítima');
217
+
218
+ let agentsHtml = '';
219
+ if (data.agent_details) {
220
+ agentsHtml = `
221
+ <div class="mt-4">
222
+ <h6 class="text-muted mb-3" style="font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;">Insights dos Agentes</h6>
223
+ <div class="d-flex flex-column gap-2">
224
+ ${data.agent_details.map(agent => `
225
+ <div class="glass p-2 px-3 rounded-3" style="border-left: 3px solid ${agent.result === 'Phishing' ? 'var(--danger)' : 'var(--success)'}; font-size: 0.85rem;">
226
+ <div class="d-flex justify-content-between align-items-center mb-1">
227
+ <strong>${agent.agent}</strong>
228
+ <span class="badge ${agent.result === 'Phishing' ? 'bg-danger' : (agent.result === 'Legítima' || agent.result === 'Safe' ? 'bg-success' : 'bg-secondary')}" style="font-size: 0.65rem;">${agent.result}</span>
229
+ </div>
230
+ ${agent.findings && agent.findings.length > 0 ? `
231
+ <ul class="mb-0 ps-3 text-muted" style="font-size: 0.75rem;">
232
+ ${agent.findings.map(f => `<li>${f}</li>`).join('')}
233
+ </ul>
234
+ ` : ''}
235
+ </div>
236
+ `).join('')}
237
+ </div>
238
+ </div>
239
+ `;
240
+ }
241
+
242
+ resultCard.innerHTML = `
243
+ <div class="result-header">
244
+ <div class="status-icon glass ${colorClass}">
245
+ <i class="fas ${icon}"></i>
246
+ </div>
247
+ <div>
248
+ <h3 style="color: ${borderColor}">${statusText}</h3>
249
+ <p class="text-muted" style="font-size: 0.9rem; word-break: break-all;">${data.url}</p>
250
+ </div>
251
+ </div>
252
+ ${data.confidence ? `
253
+ <div class="confidence-meter mt-3">
254
+ <div class="d-flex justify-content-between mb-2">
255
+ <span>Score de Risco Consolidado</span>
256
+ <span>${data.confidence}%</span>
257
+ </div>
258
+ <div style="height: 6px; background: rgba(255,255,255,0.1); border-radius: 10px; overflow: hidden;">
259
+ <div style="width: ${data.confidence}%; height: 100%; background: ${borderColor}; transition: width 1s ease-out;"></div>
260
+ </div>
261
+ </div>
262
+ ` : ''}
263
+ <div class="mt-4 p-3 glass" style="border-radius: 12px; font-size: 0.85rem; color: var(--text-muted); border-left: 4px solid var(--primary);">
264
+ <i class="fas fa-info-circle me-2"></i>
265
+ Decisão consolidada: <strong>${data.description}</strong>
266
+ </div>
267
+ ${agentsHtml}
268
+ `;
269
+ resultCard.style.display = 'block';
270
+ }
271
+
272
+ function showError(message) {
273
+ resultCard.innerHTML = `
274
+ <div class="alert alert-danger glass" style="border-color: var(--danger); color: var(--danger);">
275
+ <i class="fas fa-exclamation-triangle me-2"></i> ${message}
276
+ </div>
277
+ `;
278
+ resultCard.style.display = 'block';
279
+ }
280
+
281
+ // --- History Logic ---
282
+ const historyContainer = document.getElementById('history-container');
283
+ const viewMoreContainer = document.getElementById('view-more-container');
284
+ const viewMoreBtn = document.getElementById('view-more-btn');
285
+
286
+ let allHistoryItems = [];
287
+ let showingAll = false;
288
+
289
+ async function fetchHistory() {
290
+ try {
291
+ const response = await fetch('/history');
292
+ const data = await response.json();
293
+ if (!data.error) {
294
+ allHistoryItems = data;
295
+ renderHistory();
296
+ }
297
+ } catch (error) {
298
+ console.error('Erro ao buscar histórico:', error);
299
+ }
300
+ }
301
+
302
+ function renderHistory() {
303
+ if (!allHistoryItems || allHistoryItems.length === 0) {
304
+ historyContainer.innerHTML = `
305
+ <div class="text-center py-5 text-muted glass rounded-4">
306
+ <i class="fas fa-search mb-2 d-block fs-3"></i>
307
+ <p class="mb-0">Nenhuma busca recente encontrada.</p>
308
+ </div>
309
+ `;
310
+ viewMoreContainer.classList.add('d-none');
311
+ return;
312
+ }
313
+
314
+ const itemsToShow = showingAll ? allHistoryItems : allHistoryItems.slice(0, 2);
315
+
316
+ historyContainer.innerHTML = itemsToShow.map((item, index) => {
317
+ const isPhishing = item.result === 'Phishing';
318
+ const isSuspect = item.result === 'Suspeito';
319
+ const colorClass = isPhishing ? 'phishing' : (isSuspect ? 'suspect' : 'safe');
320
+ const confidenceText = item.confidence ? `${item.confidence}%` : 'N/A';
321
+ const desc = item.description || 'Sem detalhes disponíveis para esta análise.';
322
+
323
+ return `
324
+ <div class="history-card glass rounded-4 mb-3">
325
+ <div class="history-item" onclick="toggleHistoryDetail(${index})">
326
+ <div class="history-info">
327
+ <span class="history-url">${item.url}</span>
328
+ <div class="history-meta">
329
+ <span class="history-status-dot dot-${colorClass}"></span>
330
+ <span>${item.result}</span>
331
+ <span><i class="far fa-clock me-1"></i>${item.timestamp}</span>
332
+ </div>
333
+ </div>
334
+ <div class="d-flex align-items-center gap-2">
335
+ <div class="history-badge badge-${colorClass}">
336
+ ${item.result}
337
+ </div>
338
+ <i class="fas fa-chevron-down history-chevron" id="chevron-${index}" style="color: var(--text-muted); font-size: 0.7rem; transition: transform 0.3s ease;"></i>
339
+ </div>
340
+ </div>
341
+ <div class="history-detail" id="detail-${index}" style="display: none;">
342
+ <div class="detail-divider"></div>
343
+ <div class="detail-content">
344
+ <div class="detail-row">
345
+ <div class="detail-label"><i class="fas fa-shield-alt me-2"></i>Resultado</div>
346
+ <div class="detail-value">
347
+ <span class="history-badge badge-${colorClass}">${item.result}</span>
348
+ <span class="ms-2" style="font-size: 0.85rem; color: var(--text-muted);">Confiança: <strong>${confidenceText}</strong></span>
349
+ </div>
350
+ </div>
351
+ <div class="detail-row">
352
+ <div class="detail-label"><i class="fas fa-brain me-2"></i>Análise da IA</div>
353
+ <div class="detail-description">${desc}</div>
354
+ </div>
355
+ </div>
356
+ </div>
357
+ </div>
358
+ `;
359
+ }).join('');
360
+
361
+ // Show/hide view more button
362
+ if (allHistoryItems.length > 2) {
363
+ viewMoreContainer.classList.remove('d-none');
364
+ viewMoreBtn.innerHTML = showingAll ?
365
+ 'Ver Menos <i class="fas fa-chevron-up ms-1"></i>' :
366
+ `Ver Mais (${allHistoryItems.length - 2} extras) <i class="fas fa-chevron-down ms-1"></i>`;
367
+ } else {
368
+ viewMoreContainer.classList.add('d-none');
369
+ }
370
+ }
371
+
372
+ viewMoreBtn.addEventListener('click', () => {
373
+ showingAll = !showingAll;
374
+ renderHistory();
375
+ });
376
+
377
+ // --- Statistics Logic ---
378
+ async function fetchStats() {
379
+ try {
380
+ const response = await fetch('/stats');
381
+ const data = await response.json();
382
+ if (!data.error) renderStats(data);
383
+ } catch (error) {
384
+ console.error('Erro ao buscar estatísticas:', error);
385
+ }
386
+ }
387
+
388
+ function renderStats(data) {
389
+ // KPI Values
390
+ document.getElementById('stat-total').textContent = data.total;
391
+ document.getElementById('stat-phishing').textContent = data.phishing;
392
+ document.getElementById('stat-safe').textContent = data.safe;
393
+ document.getElementById('stat-rate').textContent = data.detection_rate + '%';
394
+
395
+ // Breakdown Bars
396
+ const total = data.total || 1;
397
+ const phishPct = (data.phishing / total * 100).toFixed(0);
398
+ const suspPct = (data.suspect / total * 100).toFixed(0);
399
+ const safePct = (data.safe / total * 100).toFixed(0);
400
+
401
+ setTimeout(() => {
402
+ document.getElementById('bar-phishing').style.width = phishPct + '%';
403
+ document.getElementById('bar-suspect').style.width = suspPct + '%';
404
+ document.getElementById('bar-safe').style.width = safePct + '%';
405
+ }, 100);
406
+
407
+ document.getElementById('bar-phishing-val').textContent = data.phishing;
408
+ document.getElementById('bar-suspect-val').textContent = data.suspect;
409
+ document.getElementById('bar-safe-val').textContent = data.safe;
410
+
411
+ // Timeline
412
+ const timelineEl = document.getElementById('stats-timeline');
413
+ if (data.timeline && data.timeline.length > 0) {
414
+ timelineEl.innerHTML = data.timeline.map(item => {
415
+ const isPhishing = item.result === 'Phishing';
416
+ const isSuspect = item.result === 'Suspeito';
417
+ const color = isPhishing ? 'var(--danger)' : (isSuspect ? '#f59e0b' : 'var(--success)');
418
+ const icon = isPhishing ? 'fa-exclamation-triangle' : (isSuspect ? 'fa-question-circle' : 'fa-check-circle');
419
+ return `
420
+ <div class="timeline-item" style="border-left-color: ${color};">
421
+ <i class="fas ${icon}" style="color: ${color};"></i>
422
+ <span class="text-muted">${item.date}</span>
423
+ <span style="color: ${color}; font-weight: 600;">${item.result}</span>
424
+ </div>
425
+ `;
426
+ }).join('');
427
+ } else {
428
+ timelineEl.innerHTML = '<p class="text-muted text-center mb-0">Nenhuma análise registrada ainda.</p>';
429
+ }
430
+ }
431
+
432
+ // --- Toggle History Detail ---
433
+ window.toggleHistoryDetail = function (index) {
434
+ const detail = document.getElementById(`detail-${index}`);
435
+ const chevron = document.getElementById(`chevron-${index}`);
436
+ if (!detail) return;
437
+
438
+ const isOpen = detail.style.display !== 'none';
439
+ detail.style.display = isOpen ? 'none' : 'block';
440
+ if (chevron) {
441
+ chevron.style.transform = isOpen ? 'rotate(0deg)' : 'rotate(180deg)';
442
+ }
443
+ };
444
+
445
+ // Initialize
446
+ fetchHistory();
447
+ });
static/style.css ADDED
@@ -0,0 +1,625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');
2
+
3
+ :root {
4
+ --primary: #2563eb;
5
+ --primary-hover: #1d4ed8;
6
+ --bg-dark: #f1f5f9;
7
+ --card-bg: rgba(255, 255, 255, 0.85);
8
+ --text-main: #1e293b;
9
+ --text-muted: #64748b;
10
+ --danger: #ef4444;
11
+ --success: #22c55e;
12
+ --border: rgba(0, 0, 0, 0.08);
13
+ --glass-bg: rgba(255, 255, 255, 0.7);
14
+ --glass-border: rgba(0, 0, 0, 0.08);
15
+ }
16
+
17
+ * {
18
+ margin: 0;
19
+ padding: 0;
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ body {
24
+ background-color: var(--bg-dark);
25
+ color: var(--text-main);
26
+ font-family: 'Outfit', sans-serif;
27
+ min-height: 100vh;
28
+ display: flex;
29
+ overflow-x: hidden;
30
+ }
31
+
32
+ /* Glassmorphism Classes */
33
+ .glass {
34
+ background: var(--glass-bg);
35
+ backdrop-filter: blur(12px);
36
+ -webkit-backdrop-filter: blur(12px);
37
+ border: 1px solid var(--glass-border);
38
+ }
39
+
40
+ .glass-card {
41
+ background: var(--card-bg);
42
+ backdrop-filter: blur(16px);
43
+ -webkit-backdrop-filter: blur(16px);
44
+ border: 1px solid var(--border);
45
+ border-radius: 24px;
46
+ box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.06);
47
+ }
48
+
49
+ /* Side Navigation */
50
+ .sidebar {
51
+ width: 280px;
52
+ height: 100vh;
53
+ position: fixed;
54
+ left: 0;
55
+ top: 0;
56
+ padding: 2rem;
57
+ display: flex;
58
+ flex-direction: column;
59
+ z-index: 1000;
60
+ transform: translateX(-100%);
61
+ transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
62
+ }
63
+
64
+ .sidebar.active {
65
+ transform: translateX(0);
66
+ }
67
+
68
+ .sidebar-overlay {
69
+ position: fixed;
70
+ top: 0;
71
+ left: 0;
72
+ width: 100vw;
73
+ height: 100vh;
74
+ background: rgba(0, 0, 0, 0.3);
75
+ backdrop-filter: blur(4px);
76
+ z-index: 999;
77
+ display: none;
78
+ animation: fadeIn 0.3s ease;
79
+ }
80
+
81
+ @keyframes fadeIn {
82
+ from {
83
+ opacity: 0;
84
+ }
85
+
86
+ to {
87
+ opacity: 1;
88
+ }
89
+ }
90
+
91
+ .logo {
92
+ /* ... existing logo styles ... */
93
+ display: flex;
94
+ align-items: center;
95
+ gap: 12px;
96
+ font-size: 1.5rem;
97
+ font-weight: 700;
98
+ margin-bottom: 3rem;
99
+ color: var(--primary);
100
+ }
101
+
102
+ .nav-links {
103
+ list-style: none;
104
+ flex-grow: 1;
105
+ }
106
+
107
+ .nav-item {
108
+ margin-bottom: 0.5rem;
109
+ }
110
+
111
+ .nav-link {
112
+ display: flex;
113
+ align-items: center;
114
+ gap: 12px;
115
+ padding: 12px 16px;
116
+ color: var(--text-muted);
117
+ text-decoration: none;
118
+ border-radius: 12px;
119
+ transition: all 0.3s ease;
120
+ }
121
+
122
+ .nav-link:hover,
123
+ .nav-link.active {
124
+ background: var(--primary);
125
+ color: white;
126
+ }
127
+
128
+ /* Main Content */
129
+ .main-content {
130
+ margin-left: 0;
131
+ width: 100%;
132
+ flex-grow: 1;
133
+ padding: 2.5rem;
134
+ display: flex;
135
+ flex-direction: column;
136
+ align-items: center;
137
+ min-height: 100vh;
138
+ }
139
+
140
+ .hero-section {
141
+ max-width: 800px;
142
+ width: 100%;
143
+ text-align: center;
144
+ margin-top: 10vh;
145
+ }
146
+
147
+ h1 {
148
+ font-size: 3.5rem;
149
+ font-weight: 700;
150
+ margin-bottom: 1.5rem;
151
+ background: linear-gradient(135deg, #1e293b 0%, #2563eb 100%);
152
+ background-clip: text;
153
+ -webkit-background-clip: text;
154
+ -webkit-text-fill-color: transparent;
155
+ }
156
+
157
+ .analyzer-container {
158
+ width: 100%;
159
+ max-width: 800px;
160
+ margin: 2rem auto 0;
161
+ }
162
+
163
+ .omni-input-wrapper {
164
+ display: flex;
165
+ align-items: flex-end;
166
+ gap: 8px;
167
+ padding: 8px;
168
+ background: var(--card-bg);
169
+ border: 1px solid var(--border);
170
+ border-radius: 24px;
171
+ transition: all 0.3s ease;
172
+ position: relative;
173
+ max-width: 800px;
174
+ margin: 0 auto;
175
+ }
176
+
177
+ .omni-input-wrapper:focus-within {
178
+ border-color: var(--primary);
179
+ box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15);
180
+ }
181
+
182
+ .btn-omni-plus {
183
+ width: 40px;
184
+ height: 40px;
185
+ border-radius: 50%;
186
+ border: none;
187
+ background: var(--glass-bg);
188
+ color: var(--text-main);
189
+ display: flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ cursor: pointer;
193
+ transition: all 0.2s ease;
194
+ margin-bottom: 4px;
195
+ }
196
+
197
+ .btn-omni-plus:hover {
198
+ background: rgba(0, 0, 0, 0.06);
199
+ transform: rotate(90deg);
200
+ }
201
+
202
+ .omni-menu {
203
+ position: absolute;
204
+ bottom: calc(100% + 12px);
205
+ left: 8px;
206
+ width: 220px;
207
+ border-radius: 16px;
208
+ padding: 8px;
209
+ display: none;
210
+ flex-direction: column;
211
+ z-index: 1001;
212
+ animation: menuFadeIn 0.2s ease-out;
213
+ }
214
+
215
+ @keyframes menuFadeIn {
216
+ from {
217
+ opacity: 0;
218
+ transform: translateY(10px);
219
+ }
220
+
221
+ to {
222
+ opacity: 1;
223
+ transform: translateY(0);
224
+ }
225
+ }
226
+
227
+ .omni-menu.active {
228
+ display: flex;
229
+ }
230
+
231
+ .omni-menu-item {
232
+ width: 100%;
233
+ padding: 10px 16px;
234
+ border-radius: 10px;
235
+ border: none;
236
+ background: transparent;
237
+ color: var(--text-main);
238
+ display: flex;
239
+ align-items: center;
240
+ gap: 12px;
241
+ font-size: 0.9rem;
242
+ cursor: pointer;
243
+ transition: background 0.2s ease;
244
+ text-align: left;
245
+ }
246
+
247
+ .omni-menu-item:hover {
248
+ background: rgba(0, 0, 0, 0.05);
249
+ }
250
+
251
+ .omni-field {
252
+ width: 100%;
253
+ background: transparent !important;
254
+ border: none !important;
255
+ padding: 10px 16px;
256
+ color: var(--text-main) !important;
257
+ font-size: 1rem;
258
+ outline: none !important;
259
+ resize: none;
260
+ }
261
+
262
+ .btn-omni-send {
263
+ width: 40px;
264
+ height: 40px;
265
+ border-radius: 50%;
266
+ border: none;
267
+ background: var(--primary);
268
+ color: white;
269
+ display: flex;
270
+ align-items: center;
271
+ justify-content: center;
272
+ cursor: pointer;
273
+ transition: all 0.2s ease;
274
+ margin-bottom: 4px;
275
+ }
276
+
277
+ .btn-omni-send:hover {
278
+ background: var(--primary-hover);
279
+ transform: scale(1.05);
280
+ }
281
+
282
+ .btn-omni-send:disabled {
283
+ opacity: 0.5;
284
+ cursor: not-allowed;
285
+ }
286
+
287
+ .is-phishing {
288
+ color: var(--danger);
289
+ border-color: var(--danger);
290
+ }
291
+
292
+ .is-safe {
293
+ color: var(--success);
294
+ border-color: var(--success);
295
+ }
296
+
297
+
298
+
299
+ /* History Section */
300
+ .history-section {
301
+ margin-top: 4rem;
302
+ padding-bottom: 5rem;
303
+ animation: fadeIn 1s ease;
304
+ }
305
+
306
+ .history-item {
307
+ display: flex;
308
+ align-items: center;
309
+ justify-content: space-between;
310
+ padding: 1.25rem 1.5rem;
311
+ border-radius: 16px;
312
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
313
+ cursor: pointer;
314
+ border-left: 4px solid transparent;
315
+ }
316
+
317
+ .history-item:hover {
318
+ background: rgba(0, 0, 0, 0.03);
319
+ transform: translateX(8px);
320
+ border-color: var(--primary);
321
+ }
322
+
323
+ .btn-view-more {
324
+ background: var(--glass-bg);
325
+ border: 1px solid var(--border);
326
+ color: var(--text-muted);
327
+ padding: 8px 24px;
328
+ border-radius: 100px;
329
+ font-size: 0.85rem;
330
+ cursor: pointer;
331
+ transition: all 0.2s ease;
332
+ margin-top: 1rem;
333
+ }
334
+
335
+ .btn-view-more:hover {
336
+ background: rgba(0, 0, 0, 0.04);
337
+ color: var(--text-main);
338
+ border-color: var(--primary);
339
+ }
340
+
341
+ .history-info {
342
+ flex-grow: 1;
343
+ overflow: hidden;
344
+ }
345
+
346
+ .history-url {
347
+ font-weight: 500;
348
+ color: var(--text-main);
349
+ display: block;
350
+ white-space: nowrap;
351
+ overflow: hidden;
352
+ text-overflow: ellipsis;
353
+ margin-bottom: 2px;
354
+ }
355
+
356
+ .history-meta {
357
+ font-size: 0.75rem;
358
+ color: var(--text-muted);
359
+ display: flex;
360
+ align-items: center;
361
+ gap: 12px;
362
+ }
363
+
364
+ .history-status-dot {
365
+ width: 8px;
366
+ height: 8px;
367
+ border-radius: 50%;
368
+ }
369
+
370
+ .dot-phishing {
371
+ background-color: var(--danger);
372
+ box-shadow: 0 0 10px var(--danger);
373
+ }
374
+
375
+ .dot-safe {
376
+ background-color: var(--success);
377
+ box-shadow: 0 0 10px var(--success);
378
+ }
379
+
380
+ .dot-suspect {
381
+ background-color: #f59e0b;
382
+ box-shadow: 0 0 10px #f59e0b;
383
+ }
384
+
385
+ .history-badge {
386
+ padding: 4px 12px;
387
+ border-radius: 100px;
388
+ font-size: 0.7rem;
389
+ font-weight: 600;
390
+ text-transform: uppercase;
391
+ letter-spacing: 0.5px;
392
+ }
393
+
394
+ .badge-phishing {
395
+ background: rgba(239, 68, 68, 0.1);
396
+ color: var(--danger);
397
+ border: 1px solid rgba(239, 68, 68, 0.2);
398
+ }
399
+
400
+ .badge-safe {
401
+ background: rgba(34, 197, 94, 0.1);
402
+ color: var(--success);
403
+ border: 1px solid rgba(34, 197, 94, 0.2);
404
+ }
405
+
406
+ .badge-suspect {
407
+ background: rgba(245, 158, 11, 0.1);
408
+ color: #f59e0b;
409
+ border: 1px solid rgba(245, 158, 11, 0.2);
410
+ }
411
+
412
+
413
+ /* ====== History Detail Box ====== */
414
+ .history-detail {
415
+ animation: detailFadeIn 0.25s ease-out;
416
+ overflow: hidden;
417
+ }
418
+
419
+ @keyframes detailFadeIn {
420
+ from {
421
+ opacity: 0;
422
+ transform: translateY(-6px);
423
+ }
424
+
425
+ to {
426
+ opacity: 1;
427
+ transform: translateY(0);
428
+ }
429
+ }
430
+
431
+ .detail-divider {
432
+ height: 1px;
433
+ background: linear-gradient(to right, transparent, var(--border), transparent);
434
+ margin: 0 1.5rem;
435
+ }
436
+
437
+ .detail-content {
438
+ padding: 1.25rem 1.5rem 1.5rem;
439
+ display: flex;
440
+ flex-direction: column;
441
+ gap: 1rem;
442
+ background: linear-gradient(135deg, rgba(37, 99, 235, 0.03) 0%, rgba(255, 255, 255, 0.5) 100%);
443
+ border-radius: 0 0 16px 16px;
444
+ }
445
+
446
+ .detail-row {
447
+ display: flex;
448
+ flex-direction: column;
449
+ gap: 0.5rem;
450
+ }
451
+
452
+ .detail-label {
453
+ font-size: 0.72rem;
454
+ font-weight: 700;
455
+ text-transform: uppercase;
456
+ letter-spacing: 1.2px;
457
+ color: var(--text-muted);
458
+ display: flex;
459
+ align-items: center;
460
+ gap: 6px;
461
+ }
462
+
463
+ .detail-label i {
464
+ color: var(--primary);
465
+ font-size: 0.8rem;
466
+ }
467
+
468
+ .detail-value {
469
+ display: flex;
470
+ align-items: center;
471
+ flex-wrap: wrap;
472
+ gap: 8px;
473
+ font-size: 0.9rem;
474
+ }
475
+
476
+ .detail-description {
477
+ font-size: 0.875rem;
478
+ color: var(--text-main);
479
+ line-height: 1.65;
480
+ background: rgba(255, 255, 255, 0.6);
481
+ border: 1px solid var(--border);
482
+ border-left: 3px solid var(--primary);
483
+ border-radius: 10px;
484
+ padding: 0.75rem 1rem;
485
+ backdrop-filter: blur(6px);
486
+ }
487
+
488
+ /* ====== Statistics Page ====== */
489
+ .stat-card {
490
+ padding: 1.5rem 1rem;
491
+ border-radius: 20px;
492
+ transition: all 0.3s ease;
493
+ }
494
+
495
+ .stat-card:hover {
496
+ transform: translateY(-4px);
497
+ }
498
+
499
+ .stat-icon {
500
+ width: 48px;
501
+ height: 48px;
502
+ border-radius: 14px;
503
+ display: flex;
504
+ align-items: center;
505
+ justify-content: center;
506
+ font-size: 1.2rem;
507
+ margin: 0 auto 1rem;
508
+ }
509
+
510
+ .stat-label {
511
+ font-size: 0.65rem;
512
+ font-weight: 600;
513
+ letter-spacing: 1.5px;
514
+ color: var(--text-muted);
515
+ margin-bottom: 0.25rem;
516
+ }
517
+
518
+ .stat-value {
519
+ font-size: 2rem;
520
+ font-weight: 700;
521
+ margin: 0;
522
+ background: linear-gradient(135deg, #1e293b, var(--primary));
523
+ -webkit-background-clip: text;
524
+ background-clip: text;
525
+ -webkit-text-fill-color: transparent;
526
+ }
527
+
528
+ .stat-bar-label {
529
+ width: 70px;
530
+ font-size: 0.8rem;
531
+ color: var(--text-muted);
532
+ flex-shrink: 0;
533
+ }
534
+
535
+ .stat-bar-track {
536
+ flex-grow: 1;
537
+ height: 8px;
538
+ background: rgba(0, 0, 0, 0.05);
539
+ border-radius: 10px;
540
+ overflow: hidden;
541
+ }
542
+
543
+ .stat-bar-fill {
544
+ height: 100%;
545
+ border-radius: 10px;
546
+ transition: width 1s ease-out;
547
+ }
548
+
549
+ .stat-bar-value {
550
+ width: 30px;
551
+ text-align: right;
552
+ font-size: 0.85rem;
553
+ font-weight: 600;
554
+ color: var(--text-main);
555
+ }
556
+
557
+ .timeline-item {
558
+ display: flex;
559
+ align-items: center;
560
+ gap: 12px;
561
+ padding: 10px 16px;
562
+ border-radius: 12px;
563
+ background: rgba(0, 0, 0, 0.02);
564
+ border-left: 3px solid transparent;
565
+ font-size: 0.85rem;
566
+ }
567
+
568
+ /* Animations & Responsive */
569
+ .loading-spinner {
570
+ display: none;
571
+ width: 50px;
572
+ height: 50px;
573
+ border: 3px solid rgba(0, 0, 0, 0.08);
574
+ border-radius: 50%;
575
+ border-top-color: var(--primary);
576
+ animation: spin 1s ease-in-out infinite;
577
+ margin-top: 2rem;
578
+ }
579
+
580
+ @keyframes spin {
581
+ to {
582
+ transform: rotate(360deg);
583
+ }
584
+ }
585
+
586
+ @media (max-width: 1024px) {
587
+ .sidebar {
588
+ width: 80px;
589
+ padding: 1.5rem 1rem;
590
+ }
591
+
592
+ .sidebar .logo span,
593
+ .sidebar .nav-link span {
594
+ display: none;
595
+ }
596
+
597
+ .main-content {
598
+ margin-left: 80px;
599
+ }
600
+ }
601
+
602
+ @media (max-width: 640px) {
603
+ .sidebar {
604
+ display: none;
605
+ }
606
+
607
+ .main-content {
608
+ margin-left: 0;
609
+ padding: 1.5rem;
610
+ }
611
+
612
+ h1 {
613
+ font-size: 2.5rem;
614
+ }
615
+
616
+ .input-wrapper {
617
+ border-radius: 20px;
618
+ flex-direction: column;
619
+ }
620
+
621
+ .btn-analyze {
622
+ width: 100%;
623
+ border-radius: 12px;
624
+ }
625
+ }
templates/index.html ADDED
@@ -0,0 +1,374 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="pt-BR">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>IA-Phishing | Detector de Sites Maliciosos</title>
8
+
9
+ <!-- CSS Dependencies -->
10
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
11
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
12
+ <link rel="stylesheet" href="{{ url_for('static', filename='style.css') }}">
13
+ </head>
14
+
15
+ <body>
16
+
17
+ <nav class="sidebar glass">
18
+ <div class="d-flex justify-content-between align-items-center mb-4">
19
+ <div class="logo mb-0">
20
+ <i class="fas fa-microchip"></i>
21
+ <span>IA-Phishing</span>
22
+ </div>
23
+ <button id="sidebar-close" class="glass rounded-circle d-flex align-items-center justify-content-center"
24
+ style="width: 36px; height: 36px; border: 1px solid var(--border); color: var(--text-muted); cursor: pointer; flex-shrink: 0;">
25
+ <i class="fas fa-times"></i>
26
+ </button>
27
+ </div>
28
+
29
+ <ul class="nav-links">
30
+ <li class="nav-item">
31
+ <a href="#" id="nav-analyzer" class="nav-link active">
32
+ <i class="fas fa-search-shield"></i>
33
+ <span>Analisador</span>
34
+ </a>
35
+ </li>
36
+
37
+ <li class="nav-item">
38
+ <a href="#" id="nav-stats" class="nav-link">
39
+ <i class="fas fa-chart-line"></i>
40
+ <span>Estatísticas</span>
41
+ </a>
42
+ </li>
43
+ </ul>
44
+
45
+ <div class="mt-auto">
46
+ <div class="glass p-3 rounded-4" style="font-size: 0.8rem;">
47
+ <p class="mb-2 text-muted">Proteção ativa via IA</p>
48
+ <div class="d-flex align-items-center gap-2">
49
+ <div style="width: 8px; height: 8px; background: #22c55e; border-radius: 50%;"></div>
50
+ <span>Sistema Online</span>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </nav>
55
+
56
+ <main class="main-content">
57
+ <header class="w-100 d-flex justify-content-between align-items-center mb-5">
58
+ <button id="sidebar-toggle"
59
+ class="sidebar-toggle-btn glass rounded-circle d-flex align-items-center justify-content-center"
60
+ style="width: 45px; height: 45px; border: 1px solid var(--border); color: var(--text-main); cursor: pointer;">
61
+ <i class="fas fa-bars"></i>
62
+ </button>
63
+ <div class="d-flex align-items-center gap-3">
64
+ <div class="glass p-2 px-3 rounded-pill" style="font-size: 0.85rem;">
65
+ <i class="fas fa-globe me-2"></i> Português
66
+ </div>
67
+ <div class="glass rounded-circle p-2 d-flex align-items-center justify-content-center"
68
+ style="width: 40px; height: 40px;">
69
+ <i class="fas fa-user-circle"></i>
70
+ </div>
71
+ </div>
72
+ </header>
73
+
74
+ <section class="hero-section">
75
+ <h1>Como posso ajudar na sua <span style="color: var(--primary)">segurança?</span></h1>
76
+ <p class="text-muted mb-5">Analise URLs, textos, códigos ou imagens instantaneamente com IA.</p>
77
+
78
+ <div class="analyzer-container">
79
+ <div class="omni-input-wrapper glass">
80
+ <div class="dropdown">
81
+ <button class="btn-omni-plus" id="omni-plus-btn">
82
+ <i class="fas fa-plus"></i>
83
+ </button>
84
+ <div class="omni-menu glass shadow-lg" id="omni-menu">
85
+ <button class="omni-menu-item" data-mode="url">
86
+ <i class="fas fa-link text-primary"></i>
87
+ <span>Analisar URL/Link</span>
88
+ </button>
89
+ <button class="omni-menu-item" data-mode="text">
90
+ <i class="fas fa-file-alt text-success"></i>
91
+ <span>Conteúdo de E-mail</span>
92
+ </button>
93
+ <button class="omni-menu-item" data-mode="html">
94
+ <i class="fas fa-code text-warning"></i>
95
+ <span>Código HTML</span>
96
+ </button>
97
+ <label class="omni-menu-item mb-0" style="cursor: pointer;">
98
+ <i class="fas fa-image text-danger"></i>
99
+ <span>Carregar Imagem</span>
100
+ <input type="file" id="image-upload" accept="image/*" class="d-none">
101
+ </label>
102
+ </div>
103
+ </div>
104
+
105
+ <form id="url-form" class="w-100 d-flex gap-2">
106
+ <div class="input-dynamic-area w-100">
107
+ <input type="text" id="url-input" class="omni-field"
108
+ placeholder="Insira o link para análise..." required autocomplete="off">
109
+ <textarea id="text-input" class="omni-field d-none" rows="3"
110
+ placeholder="Cole aqui o conteúdo suspeito..."></textarea>
111
+ <textarea id="html-input" class="omni-field d-none" rows="3"
112
+ placeholder="Cole aqui o código HTML..."></textarea>
113
+
114
+ <div id="image-preview" class="d-none mt-2 p-2 glass rounded-3">
115
+ <div class="d-flex align-items-center justify-content-between mb-2">
116
+ <span class="text-muted small"><i class="fas fa-image me-1"></i> Imagem
117
+ selecionada</span>
118
+ <button type="button" class="btn-close btn-close-white small"
119
+ id="remove-image"></button>
120
+ </div>
121
+ <img src="" id="preview-img" style="max-height: 150px; border-radius: 8px;">
122
+ </div>
123
+ </div>
124
+ <button type="submit" id="analyze-btn" class="btn-omni-send">
125
+ <i class="fas fa-arrow-up"></i>
126
+ </button>
127
+ </form>
128
+ </div>
129
+
130
+ <div id="loading" class="loading-spinner mx-auto"></div>
131
+
132
+ <div id="result-card" class="result-card glass-card text-start">
133
+ <!-- Result content injected via JS -->
134
+ </div>
135
+ </div>
136
+ </section>
137
+
138
+ <section id="history-section" class="history-section mt-5 w-100" style="max-width: 800px;">
139
+ <div class="d-flex justify-content-between align-items-center mb-4">
140
+ <h2 class="h4 mb-0"><i class="fas fa-history me-2 text-primary"></i> Buscas Recentes</h2>
141
+ <span class="badge glass text-muted fw-normal" style="font-size: 0.75rem;">Últimas 10 análises</span>
142
+ </div>
143
+
144
+ <div id="history-container" class="history-list d-flex flex-column gap-3">
145
+ <!-- History items injected via JS -->
146
+ <div class="text-center py-5 text-muted glass rounded-4">
147
+ <i class="fas fa-search mb-2 d-block fs-3"></i>
148
+ <p class="mb-0">Nenhuma busca recente encontrada.</p>
149
+ </div>
150
+ </div>
151
+
152
+ <div id="view-more-container" class="text-center mt-3 d-none">
153
+ <button id="view-more-btn" class="btn-view-more">
154
+ Ver Mais <i class="fas fa-chevron-down ms-1"></i>
155
+ </button>
156
+ </div>
157
+ </section>
158
+
159
+
160
+ </main>
161
+
162
+ <!-- Stats Page (hidden by default) -->
163
+ <main class="main-content d-none" id="stats-page">
164
+ <header class="w-100 d-flex justify-content-between align-items-center mb-5">
165
+ <div class="d-flex align-items-center gap-2">
166
+ <button class="sidebar-toggle-btn glass rounded-circle d-flex align-items-center justify-content-center"
167
+ style="width: 45px; height: 45px; border: 1px solid var(--border); color: var(--text-main); cursor: pointer;">
168
+ <i class="fas fa-bars"></i>
169
+ </button>
170
+ <button id="stats-back-btn"
171
+ class="glass rounded-circle d-flex align-items-center justify-content-center"
172
+ style="width: 45px; height: 45px; border: 1px solid var(--border); color: var(--text-main); cursor: pointer;"
173
+ title="Voltar ao Analisador">
174
+ <i class="fas fa-arrow-left"></i>
175
+ </button>
176
+ </div>
177
+ <h2 class="h5 mb-0"><i class="fas fa-chart-line me-2 text-primary"></i> Estatísticas</h2>
178
+ <div></div>
179
+ </header>
180
+
181
+ <div class="stats-container" style="max-width: 800px; margin: 0 auto;">
182
+ <div class="row g-4 mb-4">
183
+ <div class="col-6 col-md-3">
184
+ <div class="stat-card glass text-center">
185
+ <div class="stat-icon" style="background: rgba(37, 99, 235, 0.15); color: var(--primary);">
186
+ <i class="fas fa-chart-bar"></i>
187
+ </div>
188
+ <p class="stat-label">TOTAL DE ANÁLISES</p>
189
+ <h3 class="stat-value" id="stat-total">0</h3>
190
+ </div>
191
+ </div>
192
+ <div class="col-6 col-md-3">
193
+ <div class="stat-card glass text-center">
194
+ <div class="stat-icon" style="background: rgba(239, 68, 68, 0.15); color: var(--danger);">
195
+ <i class="fas fa-exclamation-triangle"></i>
196
+ </div>
197
+ <p class="stat-label">PHISHING DETECTADO</p>
198
+ <h3 class="stat-value" id="stat-phishing">0</h3>
199
+ </div>
200
+ </div>
201
+ <div class="col-6 col-md-3">
202
+ <div class="stat-card glass text-center">
203
+ <div class="stat-icon" style="background: rgba(34, 197, 94, 0.15); color: var(--success);">
204
+ <i class="fas fa-check-circle"></i>
205
+ </div>
206
+ <p class="stat-label">CONTEÚDO SEGURO</p>
207
+ <h3 class="stat-value" id="stat-safe">0</h3>
208
+ </div>
209
+ </div>
210
+ <div class="col-6 col-md-3">
211
+ <div class="stat-card glass text-center">
212
+ <div class="stat-icon" style="background: rgba(245, 158, 11, 0.15); color: #f59e0b;">
213
+ <i class="fas fa-percentage"></i>
214
+ </div>
215
+ <p class="stat-label">TAXA DE DETECÇÃO</p>
216
+ <h3 class="stat-value" id="stat-rate">0%</h3>
217
+ </div>
218
+ </div>
219
+ </div>
220
+
221
+ <div class="glass rounded-4 p-4 mb-4">
222
+ <h5 class="mb-4"><i class="fas fa-shield-alt me-2 text-primary"></i> Distribuição de Resultados</h5>
223
+ <div id="stats-breakdown">
224
+ <div class="d-flex align-items-center gap-3 mb-3">
225
+ <span class="stat-bar-label">Phishing</span>
226
+ <div class="stat-bar-track">
227
+ <div class="stat-bar-fill" id="bar-phishing" style="width: 0%; background: var(--danger);">
228
+ </div>
229
+ </div>
230
+ <span class="stat-bar-value" id="bar-phishing-val">0</span>
231
+ </div>
232
+ <div class="d-flex align-items-center gap-3 mb-3">
233
+ <span class="stat-bar-label">Suspeito</span>
234
+ <div class="stat-bar-track">
235
+ <div class="stat-bar-fill" id="bar-suspect" style="width: 0%; background: #f59e0b;"></div>
236
+ </div>
237
+ <span class="stat-bar-value" id="bar-suspect-val">0</span>
238
+ </div>
239
+ <div class="d-flex align-items-center gap-3">
240
+ <span class="stat-bar-label">Seguro</span>
241
+ <div class="stat-bar-track">
242
+ <div class="stat-bar-fill" id="bar-safe" style="width: 0%; background: var(--success);">
243
+ </div>
244
+ </div>
245
+ <span class="stat-bar-value" id="bar-safe-val">0</span>
246
+ </div>
247
+ </div>
248
+ </div>
249
+
250
+ <div class="glass rounded-4 p-4">
251
+ <h5 class="mb-4"><i class="fas fa-clock me-2 text-primary"></i> Últimas Análises</h5>
252
+ <div id="stats-timeline" class="d-flex flex-column gap-2">
253
+ <p class="text-muted text-center">Carregando...</p>
254
+ </div>
255
+ </div>
256
+ </div>
257
+ </main>
258
+
259
+ <!-- Disclaimer Popup -->
260
+ <div id="disclaimer-overlay" style="
261
+ position: fixed; inset: 0; z-index: 9999;
262
+ background: rgba(15, 23, 42, 0.75);
263
+ backdrop-filter: blur(8px);
264
+ display: flex; align-items: center; justify-content: center;
265
+ padding: 1.5rem;
266
+ animation: fadeIn 0.4s ease;
267
+ ">
268
+ <div style="
269
+ background: var(--card-bg);
270
+ border: 1px solid var(--border);
271
+ border-radius: 24px;
272
+ max-width: 480px;
273
+ width: 100%;
274
+ padding: 2.5rem 2rem;
275
+ box-shadow: 0 24px 64px rgba(0,0,0,0.15);
276
+ text-align: center;
277
+ animation: popupSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
278
+ ">
279
+ <!-- Icon -->
280
+ <div style="
281
+ width: 72px; height: 72px;
282
+ background: linear-gradient(135deg, rgba(37,99,235,0.15), rgba(37,99,235,0.05));
283
+ border: 2px solid rgba(37,99,235,0.25);
284
+ border-radius: 20px;
285
+ display: flex; align-items: center; justify-content: center;
286
+ margin: 0 auto 1.5rem;
287
+ font-size: 2rem; color: var(--primary);
288
+ ">
289
+ <i class="fas fa-flask"></i>
290
+ </div>
291
+
292
+ <!-- Title -->
293
+ <h2 style="font-size: 1.4rem; font-weight: 700; color: var(--text-main); margin-bottom: 0.5rem;">
294
+ Projeto Acadêmico
295
+ </h2>
296
+ <p
297
+ style="font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); margin-bottom: 1.5rem;">
298
+ Apenas para fins de teste
299
+ </p>
300
+
301
+ <!-- Body -->
302
+ <p style="color: var(--text-muted); font-size: 0.9rem; line-height: 1.7; margin-bottom: 1rem;">
303
+ Este é um <strong style="color: var(--text-main);">protótipo acadêmico</strong> desenvolvido para fins
304
+ educacionais na disciplina de <strong style="color: var(--text-main);">IA Generativa</strong>.
305
+ </p>
306
+ <p style="color: var(--text-muted); font-size: 0.875rem; line-height: 1.65; margin-bottom: 2rem;">
307
+ Os resultados gerados pelos agentes são baseados em <strong style="color: var(--text-main);">heurísticas
308
+ e regras simples</strong>, não em modelos de IA reais. <span
309
+ style="color: #ef4444; font-weight: 600;">Não utilize para fins de segurança reais.</span>
310
+ </p>
311
+
312
+ <!-- Tags -->
313
+ <div style="display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 2rem;">
314
+ <span
315
+ style="background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.2); color: var(--primary); border-radius: 100px; padding: 4px 14px; font-size: 0.75rem; font-weight: 600;">
316
+ <i class="fas fa-graduation-cap me-1"></i> Acadêmico
317
+ </span>
318
+ <span
319
+ style="background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); color: #ef4444; border-radius: 100px; padding: 4px 14px; font-size: 0.75rem; font-weight: 600;">
320
+ <i class="fas fa-exclamation-triangle me-1"></i> Não profissional
321
+ </span>
322
+ <span
323
+ style="background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.2); color: var(--success); border-radius: 100px; padding: 4px 14px; font-size: 0.75rem; font-weight: 600;">
324
+ <i class="fas fa-code me-1"></i> Open Source
325
+ </span>
326
+ </div>
327
+
328
+ <!-- Button -->
329
+ <button id="disclaimer-close-btn"
330
+ onclick="document.getElementById('disclaimer-overlay').style.display='none'" style="
331
+ width: 100%;
332
+ padding: 14px;
333
+ background: var(--primary);
334
+ color: white;
335
+ border: none;
336
+ border-radius: 14px;
337
+ font-size: 0.95rem;
338
+ font-weight: 600;
339
+ cursor: pointer;
340
+ transition: all 0.2s ease;
341
+ font-family: 'Outfit', sans-serif;
342
+ " onmouseover="this.style.background='var(--primary-hover)'; this.style.transform='translateY(-1px)'"
343
+ onmouseout="this.style.background='var(--primary)'; this.style.transform='translateY(0)'">
344
+ Entendi, continuar <i class="fas fa-arrow-right ms-2"></i>
345
+ </button>
346
+ </div>
347
+ </div>
348
+
349
+ <style>
350
+ @keyframes popupSlideIn {
351
+ from {
352
+ opacity: 0;
353
+ transform: scale(0.85) translateY(20px);
354
+ }
355
+
356
+ to {
357
+ opacity: 1;
358
+ transform: scale(1) translateY(0);
359
+ }
360
+ }
361
+ </style>
362
+
363
+ <!-- Scripts -->
364
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
365
+ <script src="{{ url_for('static', filename='script.js') }}?v=2.0"></script>
366
+ <script>
367
+ // Close popup when clicking outside the card
368
+ document.getElementById('disclaimer-overlay').addEventListener('click', function (e) {
369
+ if (e.target === this) this.style.display = 'none';
370
+ });
371
+ </script>
372
+ </body>
373
+
374
+ </html>