moriarty-project 0.1.19__py3-none-any.whl → 0.1.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
moriarty/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  __all__ = ["__version__"]
4
- __version__ = "0.1.19"
4
+ __version__ = "0.1.21"
@@ -3,6 +3,13 @@ WifiPPLER - Ferramenta Avançada de Análise de Segurança WiFi
3
3
 
4
4
  Uma ferramenta abrangente de auditoria de segurança WiFi que combina os melhores
5
5
  recursos de ferramentas existentes com técnicas modernas e uma interface limpa.
6
+
7
+ Módulos principais:
8
+ - scanner: Escaneamento de redes WiFi
9
+ - attacks: Implementações de ataques de segurança
10
+ - models: Modelos de dados
11
+ - utils: Funções utilitárias
12
+ - cli: Interface de linha de comando
6
13
  """
7
14
 
8
15
  __version__ = "1.0.0"
@@ -11,6 +18,14 @@ __license__ = "MIT"
11
18
 
12
19
  # Importações principais
13
20
  from .core.scanner import WiFiScanner
21
+ from .core.attacks import (
22
+ Attack, # Interface base para ataques
23
+ register_attack, # Decorador para registrar novos ataques
24
+ get_attack, # Obter um ataque pelo nome
25
+ list_attacks, # Listar todos os ataques disponíveis
26
+ )
27
+
28
+ # Importar ataques padrão para registro
14
29
  from .core.attacks import (
15
30
  WPSAttack,
16
31
  WPAHandshakeAttack,
@@ -20,26 +35,36 @@ from .core.attacks import (
20
35
  HandshakeCapture
21
36
  )
22
37
 
23
- # Utilitários
38
+ # Utilitários comuns
24
39
  from .core.utils import (
25
40
  is_root,
26
41
  check_dependencies,
27
42
  get_network_interfaces,
43
+ get_wireless_interfaces,
28
44
  set_monitor_mode,
29
45
  restore_network_interface,
30
- get_monitor_interfaces,
31
46
  start_monitor_mode,
32
- stop_monitor_mode
47
+ stop_monitor_mode,
48
+ get_monitor_interfaces,
33
49
  )
34
50
 
35
51
  # Modelos de dados
36
52
  from .core.models.network import WiFiNetwork, WiFiClient
37
53
 
54
+ # Interface CLI
55
+ from .cli.commands import app as cli_app
56
+
38
57
  __all__ = [
39
58
  # Classes principais
40
59
  'WiFiScanner',
41
60
 
42
- # Ataques
61
+ # Sistema de ataques
62
+ 'Attack',
63
+ 'register_attack',
64
+ 'get_attack',
65
+ 'list_attacks',
66
+
67
+ # Ataques específicos
43
68
  'WPSAttack',
44
69
  'WPAHandshakeAttack',
45
70
  'PMKIDAttack',
@@ -51,13 +76,17 @@ __all__ = [
51
76
  'is_root',
52
77
  'check_dependencies',
53
78
  'get_network_interfaces',
79
+ 'get_wireless_interfaces',
54
80
  'set_monitor_mode',
55
81
  'restore_network_interface',
56
- 'get_monitor_interfaces',
57
82
  'start_monitor_mode',
58
83
  'stop_monitor_mode',
84
+ 'get_monitor_interfaces',
59
85
 
60
86
  # Modelos
61
87
  'WiFiNetwork',
62
- 'WiFiClient'
88
+ 'WiFiClient',
89
+
90
+ # CLI
91
+ 'cli_app'
63
92
  ]
@@ -0,0 +1,8 @@
1
+ """
2
+ Módulo CLI do WiFiPPLER.
3
+
4
+ Fornece a interface de linha de comando para interagir com as funcionalidades do WiFiPPLER.
5
+ """
6
+
7
+ # Este arquivo é deixado intencionalmente vazio para marcar o diretório como um pacote Python.
8
+ # A implementação da CLI está em commands.py
@@ -0,0 +1,123 @@
1
+ """
2
+ Interface de linha de comando (CLI) para o WiFiPPLER.
3
+
4
+ Utiliza Typer para criar uma interface de linha de comando amigável.
5
+ """
6
+ import typer
7
+ from typing import Optional, List
8
+ from rich.console import Console
9
+ from rich.table import Table
10
+
11
+ # Importa o scanner e o registro de ataques
12
+ from ..core.scanner import WiFiScanner
13
+ from ..core.attacks import list_attacks, get_attack, Attack
14
+
15
+ # Cria a aplicação Typer
16
+ app = typer.Typer(help="WiFiPPLER - Ferramenta Avançada de Análise de Segurança WiFi")
17
+ console = Console()
18
+
19
+ # Instância do scanner
20
+ scanner = WiFiScanner()
21
+
22
+ @app.command()
23
+ def list_attacks():
24
+ """Lista todos os ataques disponíveis."""
25
+ attacks = scanner.list_attacks()
26
+
27
+ if not attacks:
28
+ console.print("[yellow]Nenhum ataque registrado.[/yellow]")
29
+ return
30
+
31
+ table = Table(show_header=True, header_style="bold magenta")
32
+ table.add_column("Nome", style="cyan")
33
+ table.add_column("Descrição")
34
+
35
+ for name, attack_cls in attacks.items():
36
+ table.add_row(name, attack_cls.description)
37
+
38
+ console.print("\n[bold]Ataques disponíveis:[/bold]")
39
+ console.print(table)
40
+
41
+ @app.command()
42
+ def scan(iface: str = typer.Option(..., "--iface", "-i", help="Interface de rede a ser usada")):
43
+ """Escaneia redes WiFi próximas."""
44
+ try:
45
+ console.print(f"[bold]Escaneando redes na interface {iface}...[/bold]")
46
+ # Implementar lógica de escaneamento aqui
47
+ networks = scanner.scan(iface=iface)
48
+
49
+ if not networks:
50
+ console.print("[yellow]Nenhuma rede encontrada.[/yellow]")
51
+ return
52
+
53
+ table = Table(show_header=True, header_style="bold green")
54
+ table.add_column("BSSID", style="cyan")
55
+ table.add_column("SSID", style="green")
56
+ table.add_column("Canal")
57
+ table.add_column("Sinal")
58
+ table.add_column("Segurança")
59
+
60
+ for net in networks:
61
+ table.add_row(
62
+ net.bssid,
63
+ net.ssid or "[dim](oculto)[/dim]",
64
+ str(net.channel),
65
+ f"{net.signal} dBm",
66
+ ", ".join(net.security) if net.security else "Aberta"
67
+ )
68
+
69
+ console.print("\n[bold]Redes encontradas:[/bold]")
70
+ console.print(table)
71
+
72
+ except Exception as e:
73
+ console.print(f"[red]Erro ao escanear redes: {e}[/red]")
74
+ raise typer.Exit(1)
75
+
76
+ @app.command()
77
+ def run(
78
+ attack: str = typer.Argument(..., help="Nome do ataque a ser executado"),
79
+ iface: str = typer.Option(..., "--iface", "-i", help="Interface de rede a ser usada"),
80
+ target: Optional[str] = typer.Option(None, "--target", "-t", help="Alvo do ataque (opcional)"),
81
+ channel: Optional[int] = typer.Option(None, "--channel", "-c", help="Canal a ser monitorado (opcional)"),
82
+ ):
83
+ """Executa um ataque específico."""
84
+ try:
85
+ console.print(f"[bold]Preparando para executar o ataque: {attack}[/bold]")
86
+
87
+ # Verifica se o ataque existe
88
+ attack_cls = get_attack(attack)
89
+ if not attack_cls:
90
+ available = ", ".join(scanner.list_attacks().keys())
91
+ console.print(f"[red]Ataque '{attack}' não encontrado. Ataques disponíveis: {available}[/red]")
92
+ raise typer.Exit(1)
93
+
94
+ # Cria e executa o ataque
95
+ attack_instance = attack_cls()
96
+
97
+ # Configura parâmetros comuns
98
+ params = {
99
+ 'iface': iface,
100
+ 'target': target
101
+ }
102
+
103
+ if channel is not None:
104
+ params['channel'] = channel
105
+
106
+ console.print(f"[bold]Iniciando ataque {attack}...[/]")
107
+ console.print("[yellow]Pressione Ctrl+C para interromper[/yellow]")
108
+
109
+ # Executa o ataque
110
+ attack_instance.run(**params)
111
+
112
+ except KeyboardInterrupt:
113
+ console.print("\n[yellow]Ataque interrompido pelo usuário.[/yellow]")
114
+ raise typer.Exit(0)
115
+ except Exception as e:
116
+ console.print(f"[red]Erro ao executar o ataque: {e}[/red]")
117
+ if typer.get_app_dir("wifippler").startswith("DEBUG"):
118
+ import traceback
119
+ console.print(traceback.format_exc())
120
+ raise typer.Exit(1)
121
+
122
+ if __name__ == "__main__":
123
+ app()
@@ -1,12 +1,21 @@
1
1
  """
2
- Core functionality for the WifiPPLER module.
2
+ Módulo principal do WiFiPPLER.
3
3
 
4
- This module provides the core functionality for the WifiPPLER tool,
5
- including network scanning, packet analysis, and attack modules.
4
+ Este pacote contém a funcionalidade central da ferramenta WiFiPPLER,
5
+ incluindo escaneamento de rede, análise de pacotes e módulos de ataque.
6
6
  """
7
7
 
8
+ # Importações principais
8
9
  from .scanner import WiFiScanner
10
+
11
+ # Sistema de registro de ataques
9
12
  from .attacks import (
13
+ Attack,
14
+ register_attack,
15
+ get_attack,
16
+ list_attacks,
17
+
18
+ # Ataques padrão
10
19
  WPSAttack,
11
20
  WPAHandshakeAttack,
12
21
  PMKIDAttack,
@@ -15,47 +24,60 @@ from .attacks import (
15
24
  HandshakeCapture
16
25
  )
17
26
 
18
- # Import utility functions
27
+ # Importar apenas o necessário do módulo utils
19
28
  from .utils import (
29
+ # Funções básicas
20
30
  is_root,
21
- get_wireless_interfaces,
22
31
  check_dependencies,
32
+
33
+ # Funções de rede
23
34
  get_network_interfaces,
35
+ get_wireless_interfaces,
24
36
  get_monitor_interfaces,
37
+
38
+ # Controle de modo monitor
25
39
  set_monitor_mode,
26
40
  restore_network_interface,
27
41
  start_monitor_mode,
28
42
  stop_monitor_mode,
29
- run_command_async,
30
- randomize_mac,
43
+
44
+ # Funções de interface
31
45
  get_interface_mac,
32
46
  get_interface_ip,
33
47
  get_interface_netmask,
34
48
  get_interface_gateway,
35
49
  is_wireless_interface,
36
- get_interface_signal,
37
- get_interface_ssid,
38
- get_interface_channel,
39
- get_interface_bitrate,
40
- create_deauth_packet,
41
- parse_airodump_csv,
42
- parse_airodump_stations,
50
+
51
+ # Utilitários de linha de comando
43
52
  run_command,
44
- command_exists
53
+ run_command_async,
54
+ command_exists,
45
55
  )
46
56
 
57
+ # Exportar apenas a API pública
47
58
  __all__ = [
59
+ # Scanner
48
60
  'WiFiScanner',
61
+
62
+ # Sistema de ataques
63
+ 'Attack',
64
+ 'register_attack',
65
+ 'get_attack',
66
+ 'list_attacks',
67
+
68
+ # Ataques
49
69
  'WPSAttack',
50
70
  'WPAHandshakeAttack',
51
71
  'PMKIDAttack',
52
72
  'WEPAttack',
53
73
  'DeauthAttack',
54
74
  'HandshakeCapture',
75
+
76
+ # Funções de utilidade
55
77
  'is_root',
56
78
  'check_dependencies',
57
- 'command_exists',
58
79
  'get_network_interfaces',
80
+ 'get_wireless_interfaces',
59
81
  'get_monitor_interfaces',
60
82
  'set_monitor_mode',
61
83
  'restore_network_interface',
@@ -66,15 +88,7 @@ __all__ = [
66
88
  'get_interface_netmask',
67
89
  'get_interface_gateway',
68
90
  'is_wireless_interface',
69
- 'get_interface_signal',
70
- 'get_interface_ssid',
71
- 'get_interface_channel',
72
- 'get_interface_bitrate',
73
- 'create_deauth_packet',
74
- 'parse_airodump_csv',
75
- 'parse_airodump_stations',
76
91
  'run_command',
77
92
  'run_command_async',
78
- 'randomize_mac',
79
- 'get_wireless_interfaces'
93
+ 'command_exists',
80
94
  ]
@@ -1,19 +1,146 @@
1
1
  """
2
- Attack modules for WifiPPLER.
2
+ Módulo de Ataques do WiFiPPLER.
3
+
4
+ Implementa um sistema de registro de ataques para permitir descoberta dinâmica
5
+ e execução de diferentes tipos de ataques de segurança WiFi.
6
+
7
+ Este módulo utiliza o padrão de registro para permitir que novos ataques sejam
8
+ facilmente adicionados ao sistema sem modificar o código existente.
9
+
10
+ Exemplo de uso:
11
+ >>> # Registrar um novo tipo de ataque
12
+ >>> @register_attack
13
+ >>> class MeuAtaque:
14
+ ... name = "meu_ataque"
15
+ ... description = "Descrição do meu ataque personalizado"
16
+ ...
17
+ ... def run(self, *, iface: str, target: Optional[str] = None, **kwargs):
18
+ ... # Implementação do ataque
19
+ ... pass
20
+
21
+ >>> # Obter um ataque pelo nome
22
+ >>> ataque_cls = get_attack("meu_ataque")
23
+ >>> if ataque_cls:
24
+ ... ataque = ataque_cls()
25
+ ... ataque.run(iface="wlan0", target="00:11:22:33:44:55")
3
26
  """
27
+ from typing import Dict, Type, Protocol, Optional, Any, TypeVar
4
28
 
5
- from .wps import WPSAttack
6
- from .wpa import WPAHandshakeAttack
7
- from .pmkid import PMKIDAttack
8
- from .wep import WEPAttack
29
+ # Tipo genérico para a classe Attack
30
+ T = TypeVar('T', bound='Attack')
31
+
32
+ class Attack(Protocol):
33
+ """Protocolo que define a interface para todos os ataques.
34
+
35
+ Para criar um novo ataque, crie uma classe que implemente este protocolo
36
+ e use o decorador @register_attack para registrá-lo.
37
+ """
38
+ # Nome único do ataque (deve ser um identificador em minúsculas com underscores)
39
+ name: str
40
+
41
+ # Descrição do ataque (aparecerá na lista de ataques disponíveis)
42
+ description: str = ""
43
+
44
+ def run(self, *, iface: str, target: Optional[str] = None, **kwargs: Any) -> None:
45
+ """Executa o ataque.
46
+
47
+ Args:
48
+ iface: Interface de rede a ser usada (ex: 'wlan0')
49
+ target: Alvo do ataque (opcional, pode ser um endereço MAC, BSSID, etc.)
50
+ **kwargs: Argumentos adicionais específicos do ataque
51
+
52
+ Raises:
53
+ Exception: Se ocorrer um erro durante a execução do ataque
54
+ """
55
+ ...
56
+
57
+ # Registro global de ataques
58
+ REGISTRY: Dict[str, Type[Attack]] = {}
59
+
60
+ def register_attack(attack_cls: Type[T]) -> Type[T]:
61
+ """Decorador para registrar uma classe de ataque.
62
+
63
+ Exemplo:
64
+ >>> @register_attack
65
+ >>> class MeuAtaque:
66
+ ... name = "meu_ataque"
67
+ ... description = "Descrição do meu ataque"
68
+ ... def run(self, *, iface: str, **kwargs):
69
+ ... pass
70
+
71
+ Args:
72
+ attack_cls: Classe de ataque a ser registrada. Deve implementar o protocolo Attack.
73
+
74
+ Returns:
75
+ A própria classe de ataque, permitindo uso como decorador
76
+
77
+ Raises:
78
+ ValueError: Se o nome do ataque já estiver registrado
79
+ """
80
+ if not hasattr(attack_cls, 'name') or not attack_cls.name:
81
+ raise ValueError(f"A classe {attack_cls.__name__} deve definir um atributo 'name'")
82
+
83
+ if attack_cls.name in REGISTRY:
84
+ raise ValueError(f"Já existe um ataque registrado com o nome '{attack_cls.name}'")
85
+
86
+ REGISTRY[attack_cls.name] = attack_cls
87
+ return attack_cls
88
+
89
+ def get_attack(name: str) -> Optional[Type[Attack]]:
90
+ """Obtém uma classe de ataque pelo nome.
91
+
92
+ Args:
93
+ name: Nome do ataque a ser recuperado (case-sensitive)
94
+
95
+ Returns:
96
+ A classe de ataque correspondente ou None se não encontrado
97
+
98
+ Example:
99
+ >>> ataque_cls = get_attack("deauth")
100
+ >>> if ataque_cls:
101
+ ... ataque = ataque_cls()
102
+ ... ataque.run(iface="wlan0", target="00:11:22:33:44:55")
103
+ """
104
+ return REGISTRY.get(name)
105
+
106
+ def list_attacks() -> Dict[str, str]:
107
+ """Lista todos os ataques registrados.
108
+
109
+ Returns:
110
+ Dicionário onde as chaves são os nomes dos ataques e os valores são suas descrições
111
+
112
+ Example:
113
+ >>> for nome, descricao in list_attacks().items():
114
+ ... print(f"{nome}: {descricao}")
115
+ """
116
+ return {name: cls.description for name, cls in REGISTRY.items()}
117
+
118
+ # Importa os módulos de ataque para registrar as classes automaticamente
119
+ # A ordem de importação é importante para evitar importações circulares
9
120
  from .deauth import DeauthAttack
10
121
  from .handshake import HandshakeCapture
122
+ from .pmkid import PMKIDAttack
123
+ from .wep import WEPAttack
124
+ from .wpa import WPAHandshakeAttack
125
+ from .wps import WPSAttack
11
126
 
127
+ # Exporta a API pública
12
128
  __all__ = [
13
- 'WPSAttack',
14
- 'WPAHandshakeAttack',
129
+ # Interface e registro
130
+ 'Attack',
131
+ 'register_attack', # Alias para register para melhor clareza
132
+ 'get_attack',
133
+ 'list_attacks',
134
+ 'register', # Mantido para compatibilidade
135
+
136
+ # Ataques específicos
137
+ 'DeauthAttack',
138
+ 'HandshakeCapture',
15
139
  'PMKIDAttack',
16
140
  'WEPAttack',
17
- 'DeauthAttack',
18
- 'HandshakeCapture'
141
+ 'WPAHandshakeAttack',
142
+ 'WPSAttack',
143
+
144
+ # Registro interno (exposto apenas para testes)
145
+ 'REGISTRY',
19
146
  ]