Skip to content

Instantly share code, notes, and snippets.

@stpf99
Last active January 4, 2024 19:36
Show Gist options
  • Save stpf99/a9960bb1c1f21558bab78d71c1e25bda to your computer and use it in GitHub Desktop.
Save stpf99/a9960bb1c1f21558bab78d71c1e25bda to your computer and use it in GitHub Desktop.
#!/bin/ash
(
sleep 20
[[ -f /storage/.cache/btmac ]] || echo `printf '43:34:1b:%02x:%02x:%02x\n' $(( $RANDOM % 256 )) $(( $RANDOM % 256 )) $(( $RANDOM % 256 ))` > /storage/.cache/btmac
/usr/bin/btmgmt -i hci0 public-addr `cat /storage/.cache/btmac`
)&
#!/bin/ash
firmware=("BCM43341B0" "BCM2045A")
[[ -f autostart.sh ]] || touch autostart.sh
if (cat autostart.sh |grep "btmgmt" >> /dev/null); then
echo "Nothing todo with autostart.sh"
else
for str in ${firmware[@]}; do
if (dmesg | grep $str >> /dev/null); then
echo '#!/bin/bash
[[ -f btmac ]] || echo `printf 43:34:1b:%02x:%02x:%02x $[RANDOM%256] $[RANDOM%256] $[RANDOM%256]` > btmac
/usr/bin/btmgmt -i hci0 public-addr `cat btmac`
echo "new btmac setup success"' >> autostart.sh
echo autostart.sh customized to new random nonstatic mac for Bluetooth device $str ;
else
echo Nothing todo with mac change device not detected $firmware ;
fi
done
fi
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ ls <<ls dir
bash_enable_bt.sh <<ls output
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ chmod +x bash_enable_bt.sh <<set chmod +x for main script
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ sudo ./bash_enable_bt.sh <<1st run
[sudo] hasło użytkownika ts: <<pswd
Nothing todo with mac change device not detected BCM43341B0 <<1st defined device not detected
autostart.sh customized to new random nonstatic mac for Bluetooth device BCM2045A <<2nd dev detected OK
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ sudo ./bash_enable_bt.sh <<2nd run
Nothing todo with autostart.sh <<already modified
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ ls <<ls dir
autostart.sh bash_enable_bt.sh <<new script in dir
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ sudo chmod +x autostart.sh <<set chmod +x for produced script
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ sudo ./autostart.sh <<1st run for produced script
Set Public Address for hci0 failed with status 0x11 (Invalid Index) <<(on system i have another buggy adapter)
new btmac setup success <<info
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$ ls <<ls dir
autostart.sh bash_enable_bt.sh btmac <<new "btmac" file in dir
ts@ts-HP-t620-Quad-Core-TC:~/patches/bt_mac_changer/1$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment