-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
73 lines (61 loc) · 3.29 KB
/
main.py
File metadata and controls
73 lines (61 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import subprocess
from colorama import Fore, init
import os
init()
check = False
def get_network_adapters() -> list:
try:
result = subprocess.run(['ls', '/sys/class/net/'], capture_output=True, text=True, check=True)
return result.stdout.strip().split('\n')
except subprocess.CalledProcessError as e:
print(f"{Fore.RED}Ошибка при получении списка сетевых адаптеров: {e}{Fore.RESET}")
return []
def display_adapters(adapters) -> None:
for i, adapter in enumerate(adapters):
print(f"[{Fore.GREEN}{i}{Fore.RESET}] {Fore.CYAN}{adapter}{Fore.RESET}")
def get_user_choice(adapters) -> str:
try:
while True:
choice = input(f"{Fore.LIGHTRED_EX}Выберите один из адаптеров: {Fore.RESET}")
if choice.isdigit() and 0 <= int(choice) < len(adapters):
return adapters[int(choice)]
elif choice in adapters:
return choice
else:
print(f"{Fore.RED}\n\nЭтого адаптера нет в списке!\n\n{Fore.RESET}")
except KeyboardInterrupt:
print(f"\n\n{Fore.RED}[CTRL+C detected]{Fore.RESET}")
def main():
global check
try:
if os.getuid() == 0:
adapters = get_network_adapters()
if not adapters:
print(f"{Fore.RED}Нет доступных сетевых адаптеров.{Fore.RESET}")
return
display_adapters(adapters)
chosen_adapter = get_user_choice(adapters)
if chosen_adapter != None:
print(f"Выбранный адаптер: {Fore.CYAN}{chosen_adapter}{Fore.RESET}")
print(f"Перевод адаптера в режим монитора...")
subprocess.run(['airmon-ng','start', chosen_adapter], capture_output=True, text=True, check=True)
check = True
path_to_file = input("Введите пожалуйста полный путь до словаря с названиями WiFi: ")
if os.path.isfile(path_to_file):
print(f"{Fore.RED}Точки WiFi успешно созданы! Для выхода удаления нажмите CTRL+C{Fore.RESET}")
subprocess.run(['mdk3', f'{chosen_adapter}mon','b','-c','1','-f', path_to_file], capture_output=True, text=True, check=True)
else:
print('\n\nТакого файла не существует!\n\n')
subprocess.run(['airmon-ng','stop',f'{chosen_adapter}mon'], capture_output=True, text=True, check=True)
main()
else:
print("Пожалуйста, запустите программу с правами супер пользователя!")
return 0
except KeyboardInterrupt:
if check and chosen_adapter[-3::] != 'mon':
subprocess.run(['airmon-ng','stop',f'{chosen_adapter}mon'], capture_output=True, text=True, check=True)
else:
subprocess.run(['airmon-ng','stop',f'{chosen_adapter}'], capture_output=True, text=True, check=True)
print(f"\n\n{Fore.RED}[CTRL+C detected]{Fore.RESET}")
if __name__ == "__main__":
main()