Last active
July 29, 2025 02:07
-
-
Save anecdata/69c44f20bac2b55546e4438a01af283c to your computer and use it in GitHub Desktop.
SSIDNet™️
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: 2025 anecdata | |
# SPDX-License-Identifier: MIT | |
# SSIDNet™️ message sender | |
import time | |
import random | |
import math | |
import binascii | |
import traceback | |
import wifi | |
CHANNEL = 9 | |
def random_local_mac(): | |
mac = bytearray() | |
for _ in range(0, 6): | |
mac.append(random.randrange(0, 256)) | |
mac[0] = mac[0] | 0b00000010 # local | |
mac[0] = mac[0] & 0b11111110 # multicast not supported | |
return mac | |
def random_ascii_printable(length=17): | |
rap = bytearray() | |
for _ in range(0, length): | |
rap.append(random.randrange(0x20, 0x7F)) # 7-bit ASCII printable | |
rap = rap.decode() | |
return rap | |
def obfuscate(imsg): | |
omsg = bytearray() | |
for i in range(0, len(imsg)): | |
omsg.append(imsg[i] ^ 0b01010101) | |
return omsg | |
def deobfuscate(msg): | |
return obfuscate(msg) | |
def start_new_ap(ap_ssid): | |
ap_password = random_ascii_printable(length=17) | |
wifi.radio.start_ap(ap_ssid, ap_password, channel=CHANNEL, authmode=[wifi.AuthMode.WPA2, wifi.AuthMode.PSK], max_connections=0) | |
wifi.radio.mac_address_ap = random_local_mac() | |
wifi.radio.enabled = True | |
def stop_ap(): | |
wifi.radio.stop_ap() | |
wifi.radio.enabled = False | |
messages = [ | |
b"", | |
b"From the ashes a fire shall be woken, A light from the shadows shall spring; Renewed shall be blade that was broken, The crownless again shall be king. ―J.R.R. Tolkien", | |
b"If you can't explain it to a six year old, you don't understand it yourself. ―Albert Einstein", | |
b"I don’t know why people are so keen to put the details of their private life in public; they forget that invisibility is a superpower. —Banksy", | |
b"I’ve learned that people will forget what you said, people will forget what you did, but people will never forget how you made them feel. —Maya Angelou", | |
b"There is more to life than increasing its speed. —Mohandas K. Gandhi", | |
b"Each generation imagines itself to be more intelligent than the one that went before it and wiser than the one that comes after it.—George Orwell", | |
b"You cannot do a kindness too soon, for you never know how soon it will be too late. —Ralph Waldo Emerson", | |
] | |
# no 0x0 in SSID (CP terminates buffer?) | |
time.sleep(3) # wait for serial after reset | |
while True: | |
for m in range(1, len(messages)): | |
print(f'✅ {messages[m].decode()}') | |
message = obfuscate(messages[m]) | |
crc = binascii.crc32(message).to_bytes(4) | |
num_frames = int(math.ceil((len(message) + 4) / 28)) | |
for f in range(1, num_frames + 1): | |
try: | |
ssid = bytearray(4) | |
ssid[0] = 0x01 # ␁ [0] ProtoID | |
ssid[1] = m # [1] MsgID | |
ssid[2] = f # [2] frame# | |
ssid[3] = num_frames # [3] #frames | |
if f < num_frames: | |
ssid.extend(message[28*(f-1):28*(f-1)+28]) | |
else: | |
ssid.extend(message[28*(f-1):]) | |
ssid.extend(crc) | |
print(f'🛜 Starting AP... {bytes(ssid)}') | |
start_new_ap(ssid) | |
time.sleep(0.75) # | |
except Exception as ex: | |
traceback.print_exception(ex, ex, ex.__traceback__) | |
finally: | |
stop_ap() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://fosstodon.org/@anecdata/114915140350494065