Updated and coverted my fork from evilsocket/pwnagotchi master branch to aluminum-ice/pwnagotchi master branch removed hannadiamond repository changed pwnagotchi community plugin repository to my pwnagotchi community plugin repository removed mastodon plugin removed screenrc configuration cloned pwnagotchi community plugin repository only once removed configure pwnagotchi for the custom plugin directory from builder/pwnagotchi.yml reconfigured auto-update to point to the scifijunkie repo edited main.custom_plugins to point to /usr/local/share/pwnagotchi/custom-plugins in pwnagotchi/defaults.toml removed mastodon configuration from defaults.toml removed ntfy configuration from defaults.toml removed handshakes-m.py from default plugin removed mastodon.py from default plugin removed ntfy.py from default plugin addressed [ERROR] [update] 'tag_name' addressed rate limit exceeded addressed TypeError: Descriptors cannot not be created directly. Reran pip-compile
214 lines
5.0 KiB
Bash
Executable File
214 lines
5.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# well ... it blinks the led
|
|
blink_led() {
|
|
for i in $(seq 1 "$1"); do
|
|
if [ -d /sys/class/leds/led0 ]
|
|
then
|
|
echo 0 | tee /sys/class/leds/led0/brightness
|
|
else
|
|
echo 0 | tee /sys/class/leds/ACT/brightness
|
|
fi
|
|
sleep 0.3
|
|
|
|
if [ -d /sys/class/leds/led0 ]
|
|
then
|
|
echo 1 | tee /sys/class/leds/led0/brightness
|
|
else
|
|
echo 1 | tee /sys/class/leds/ACT/brightness
|
|
fi
|
|
sleep 0.3
|
|
|
|
done
|
|
|
|
if [ -d /sys/class/leds/led0 ]
|
|
then
|
|
echo 0 | tee /sys/class/leds/led0/brightness
|
|
else
|
|
echo 0 | tee /sys/class/leds/ACT/brightness
|
|
fi
|
|
sleep 0.3
|
|
}
|
|
|
|
# check if brcm is stuck
|
|
check_brcm() {
|
|
if [[ "$(journalctl -n10 -k --since -5m | grep -c 'brcmf_cfg80211_nexmon_set_channel.*Set Channel failed')" -ge 5 ]]; then
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# reload mod
|
|
reload_brcm() {
|
|
if ! modprobe -r brcmfmac; then
|
|
return 1
|
|
fi
|
|
if ! modprobe brcmfmac; then
|
|
return 1
|
|
fi
|
|
return 0
|
|
}
|
|
|
|
# starts mon0
|
|
start_monitor_interface() {
|
|
rfkill unblock all
|
|
iw dev wlan0 set power_save off
|
|
|
|
ifconfig wlan0 up
|
|
|
|
iw phy "$(iw phy | head -1 | cut -d" " -f2)" interface add mon0 type monitor && ifconfig mon0 up
|
|
|
|
# If wlan0 is NOT taken down after bringing up mon0, then when switching to AUTO you will get:
|
|
# error 400: error while initializing mon0 to channel 1: iw: out=command failed: Device or resource busy (-16) err=exit status 240
|
|
ifconfig wlan0 down
|
|
}
|
|
|
|
# stops mon0
|
|
stop_monitor_interface() {
|
|
ifconfig mon0 down && iw dev mon0 del
|
|
ifconfig wlan0 up
|
|
}
|
|
|
|
# returns 0 if the specificed network interface is up
|
|
is_interface_up() {
|
|
if grep -qi 'up' /sys/class/net/$1/operstate; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# returns 0 if conditions for AUTO mode are met
|
|
is_auto_mode() {
|
|
# check override file first
|
|
if [ -f /root/.pwnagotchi-manual ]; then
|
|
# remove the override file if found
|
|
rm -rf /root/.pwnagotchi-manual
|
|
return 1
|
|
fi
|
|
|
|
# check override file first
|
|
if [ -f /root/.pwnagotchi-auto ]; then
|
|
# remove the override file if found
|
|
rm -rf /root/.pwnagotchi-auto
|
|
return 0
|
|
fi
|
|
|
|
# if usb0 is up, we're in MANU
|
|
if is_interface_up usb0; then
|
|
return 1
|
|
fi
|
|
|
|
# if eth0 is up (for other boards), we're in MANU
|
|
if is_interface_up eth0; then
|
|
return 1
|
|
fi
|
|
|
|
# no override, but none of the interfaces is up -> AUTO
|
|
return 0
|
|
}
|
|
|
|
# returns 0 if conditions for AUTO mode are met
|
|
is_auto_mode_no_delete() {
|
|
# check override file first
|
|
if [ -f /root/.pwnagotchi-manual ]; then
|
|
return 1
|
|
fi
|
|
|
|
# check override file first
|
|
if [ -f /root/.pwnagotchi-auto ]; then
|
|
return 0
|
|
fi
|
|
|
|
# if usb0 is up, we're in MANU
|
|
if is_interface_up usb0; then
|
|
return 1
|
|
fi
|
|
|
|
# if eth0 is up (for other boards), we're in MANU
|
|
if is_interface_up eth0; then
|
|
return 1
|
|
fi
|
|
|
|
# no override, but none of the interfaces is up -> AUTO
|
|
return 0
|
|
}
|
|
|
|
# check if we need to decrypt something
|
|
is_crypted_mode() {
|
|
if [ -f /root/.pwnagotchi-crypted ]; then
|
|
return 0
|
|
fi
|
|
return 1
|
|
}
|
|
|
|
# decryption loop
|
|
is_decrypted() {
|
|
while read -r mapping container mount; do
|
|
# mapping = name the device or file will be mapped to
|
|
# container = the luks encrypted device or file
|
|
# mount = the mountpoint
|
|
|
|
# fail if not mounted
|
|
if ! mountpoint -q "$mount" >/dev/null 2>&1; then
|
|
if [ -f /tmp/.pwnagotchi-secret-"$mapping" ]; then
|
|
</tmp/.pwnagotchi-secret-"$mapping" read -r SECRET
|
|
if ! test -b /dev/disk/by-id/dm-uuid-*"$(cryptsetup luksUUID "$container" | tr -d -)"*; then
|
|
if echo -n "$SECRET" | cryptsetup luksOpen -d- "$container" "$mapping" >/dev/null 2>&1; then
|
|
echo "Container decrypted!"
|
|
fi
|
|
fi
|
|
|
|
if mount /dev/mapper/"$mapping" "$mount" >/dev/null 2>&1; then
|
|
echo "Mounted /dev/mapper/$mapping to $mount"
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
if ! ip -4 addr show wlan0 | grep inet >/dev/null 2>&1; then
|
|
>/dev/null 2>&1 ip addr add 192.168.0.10/24 dev wlan0
|
|
fi
|
|
|
|
if ! pgrep -f decryption-webserver >/dev/null 2>&1; then
|
|
>/dev/null 2>&1 decryption-webserver &
|
|
fi
|
|
|
|
if ! pgrep wpa_supplicant >/dev/null 2>&1; then
|
|
>/tmp/wpa_supplicant.conf cat <<EOF
|
|
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
|
|
update_config=1
|
|
ap_scan=2
|
|
|
|
network={
|
|
ssid="DECRYPT-ME"
|
|
mode=2
|
|
key_mgmt=WPA-PSK
|
|
psk="pwnagotchi"
|
|
frequency=2437
|
|
}
|
|
EOF
|
|
>/dev/null 2>&1 wpa_supplicant -u -s -O -D nl80211 -i wlan0 -c /tmp/wpa_supplicant.conf &
|
|
fi
|
|
|
|
if ! pgrep dnsmasq >/dev/null 2>&1; then
|
|
>/dev/null 2>&1 dnsmasq -k -p 53 -h -O "6,192.168.0.10" -A "/#/192.168.0.10" -i wlan0 -K -F 192.168.0.50,192.168.0.60,255.255.255.0,24h &
|
|
fi
|
|
|
|
return 1
|
|
fi
|
|
done </root/.pwnagotchi-crypted
|
|
|
|
# overwrite passwords
|
|
python3 -c 'print("A"*4096)' | tee /tmp/.pwnagotchi-secret-* >/dev/null
|
|
# delete
|
|
rm /tmp/.pwnagotchi-secret-*
|
|
sync # flush
|
|
|
|
pkill wpa_supplicant
|
|
pkill dnsmasq
|
|
pid="$(pgrep -f "decryption-webserver")"
|
|
[[ -n "$pid" ]] && kill "$pid"
|
|
|
|
return 0
|
|
}
|