-
Notifications
You must be signed in to change notification settings - Fork 1
/
blue_msg.py
executable file
·188 lines (139 loc) · 6.1 KB
/
blue_msg.py
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
#!/usr/bin/python3
import re
import argparse
import os
#import bluetooth
import sys
import time
import tempfile
import time
# Temp directory for output
temp_dir = tempfile.mkdtemp()
counter = 0
send_counter = 0 #counter for numbers of times you want to pair with the targer (for flood)
scan_duration = 5
ble_list_name = []
ble_list_addr = []
# Setting the color combinations
RED = "\033[1;31m"
BLUE = "\033[1;34m"
BOLD_BLUE = "\033[2;34m"
CYAN = "\033[1;36m"
GREEN = "\033[0;32m"
RESET = "\033[0;0m"
BOLD = "\033[;1m"
REVERSE = "\033[;7m"
def main():
print(
f"""
{BLUE}@@@@@@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@@@@ @@@@@@@@ @@@@@@ @@@@@@ @@@@@@@@ @@@ @@@ @@@@@@@@ @@@@@@@@ @@@@@@@
@@@@@@@@ @@@ @@@ @@@ @@@@@@@@ @@@@@@@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@ @@@@@@@@ @@@@ @@@ @@@@@@@@@ @@@@@@@@ @@@@@@@@
@@! @@@ @@! @@! @@@ @@! @@! @@! @@! @@! !@@ !@@ @@! @@!@!@@@ !@@ @@! @@! @@@
!@ @!@ !@! !@! @!@ !@! !@! !@! !@! !@! !@! !@! !@! !@!!@!@! !@! !@! !@! @!@
{RESET}{BOLD_BLUE}@!@!@!@ @!! @!@ !@! @!!!:! @!! !!@ @!@ @!!!:! !!@@!! !!@@!! @!!!:! @!@ !!@! !@! @!@!@ @!!!:! @!@!!@!
!!!@!!!! !!! !@! !!! !!!!!: !@! ! !@! !!!!!: !!@!!! !!@!!! !!!!!: !@! !!! !!! !!@!! !!!!!: !!@!@!
!!: !!! !!: !!: !!! !!: !!: !!: !!: !:! !:! !!: !!: !!! :!! !!: !!: !!: :!!
:!: !:! :!: :!: !:! :!: :!: :!: :!: !:! !:! :!: :!: !:! :!: !:: :!: :!: !:!
:: :::: :: :::: ::::: :: :: :::: ::::::::::::: ::: :: :: :::: :::: :: :::: :: :: :::: :: :: ::: :::: :: :::: :: :::
:: : :: : :: : : : : : : :: :: ::::::::::::: : : : :: :: :: : : :: : : : :: :: :: : :: :: : : :: :: : : :
{RESET}
""")
# for the --help
parser = argparse.ArgumentParser(description='Bluetooth Messenger script for send a message to anyone with Bluetooth !')
args = parser.parse_args()
#sudo verification
if not os.geteuid() == 0:
print(BOLD, RED,f"[!] SUDO requied, please make a sudo command",RESET)
sys.exit()
else:
global new_name
global spam_counter
message_input = f"{BOLD}{BLUE}[?] Choose your message : {RESET}"
spam_counter_msg = f"{BOLD}{BLUE}[?] How often do I hit the target ? [1 for Normal, >1 for Spam] : {RESET}"
new_name = input(message_input)
spam_counter = int(input(spam_counter_msg))
#start bluetooth service
os.system("systemctl start bluetooth")
pass
main()
def filter_lines_with_new(output):
lines = output.split('\n')
new_lines = [line for line in lines if "NEW" in line]
#avoir une liste avec numéro
tmp_list = [f'{num + 1} {line}' for num, line in enumerate(new_lines)]
numbered_output = '\n'.join(tmp_list)
#var pour la selection de la MAC en fonction du choix user
listes = [line.split() for line in new_lines]
print(numbered_output) #tmp_list
while True:
try:
message_num = f"{BOLD}{BLUE},[?] Choose the number of the target (1 to {format(len(listes))}): {RESET}"
numero_ligne = int(input(message_num))
if 1 <= numero_ligne <= len(listes):
break
else:
print(BOLD, RED,f"[!] Wrong number, please retry",RESET)
except ValueError:
print(BOLD, RED,f"[!] Please insert a valid number",RESET)
# Afficher la liste correspondant à la ligne demandée par l'utilisateur
ligne_demandee = listes[numero_ligne - 1]
return ligne_demandee
def detecter_adresse_mac(data):
pattern = r'([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})'
match = re.search(pattern, data)
if match:
return match.group()
else :
print(BOLD, RED,"[!] No match found",RESET)
sys.exit()
# Find MAC address bluetooth
def discover_bluetooth_devices():
global device_name
os.system(f"bluetoothctl --timeout {scan_duration} scan on > {temp_dir}/scan.txt")
#open result file
with open(f"{temp_dir}/scan.txt", "r") as file:
scan_out = file.read()
#For only select lines with "NEW"
data = filter_lines_with_new(scan_out)
# Delete all elements after the 3rd for exclude name in scope result
data = data[:3]
device_name = data[3:]
data = ''.join(str(item) for item in data)
#Filter for MAC address (for detect with the fucking colors flags )
test = detecter_adresse_mac(data)
return test
# Change bluetooth name
def change_computer_name(new_name):
new_name = f'"{new_name}"'
os.system(f"hciconfig hci0 name '{new_name}'")
time.sleep(2)
#Bluetooth pair fonction
def pair_bluetooth(device_address):
counter =+ 1
#obligé de faire os.system en raison des regele de secu de subprocess
os.system(f"bluetoothctl pair {device_address} > {temp_dir}/output.txt")
# Lecture du contenu du fichier de sortie
with open(f"{temp_dir}/output.txt", "r") as file:
output = file.read()
# Vérification de la présence de "not available" dans la sortie
if "not available" in output:
print(counter)
os.system("systemctl force-reload bluetooth")
time.sleep(2)
pair_bluetooth(device_address)
else:
pass
# Find and print bt MAC addresss
print(BOLD, BLUE,"[+] Try to find Bluetooth devices...",RESET)
#MAC address choice
device_address = discover_bluetooth_devices()
# Change bluetooth name
print(BOLD, BLUE,f"[+] Change Bluetooth name to : {new_name}...",RESET)
change_computer_name(new_name)
# Bluetooth pairing
print(BOLD, BLUE,f"[+] Connect to {device_name} MAC : {device_address}",RESET)
while send_counter < spam_counter:
send_counter += 1
pair_bluetooth(device_address)
#start bluetooth service
os.system("bluetoothctl scan off && systemctl stop bluetooth")