shark-files/usr/bin/SWITCH

31 lines
577 B
Plaintext
Raw Permalink Normal View History

Housekeeping (#7) * fix LED killing * do not autostart unneeded services ntp: we don't want to leak in attack mode and arming mode doesn't even have internet. user's who want this can start it themselves dnsmasq: we should start this when needed rather than killing it when not needed, speed boot by not starting then killing * NETMODE: use dnsmasq netmode was improperly calling odhcpd when we use dnsmasq, just call dnsmasq * start dnsmasq when needed have shark service start dnsmasq in arming mode and stop it in attack and off mode * randomize mac with macchanger currently mac is randomized because it is unable to read the actual mac. If there gets fixed then the mac won't be randomized. Let's intentionally randomize the mac to be sure we are random enough * ensure netmode dhcp_server provides default gateway * prototype out switching between gateway and no gateway * actually disable gateway in arming mode * disable openvpn I don't know why this is trying to start, but let's not * better LED anti-suicide * permissions count * execute_payload: fix shellcheck warnings * convert BATTERY to posix runtime cut from 0.051s to 0.021s on average * shellcheck cleanup simplify script while doing it, use faster sh instead of bash * DO_A_BARREL_ROOL: this was posix anyway, so use posix * execute_payload: mostly posix, consider refactor * cleanup LED a bit partially elminate bashisms when possible to do cleanly shellcheck fixes for anti-hari kari (and it's faster) * POSIX NETMODE this was already posix except for function definitions * POSIX shark_framework fix minor logic error and posixify * shark_framework: save an awk * SWITCH: posix * LED: fix logic for SC2015 warnings * move wait_for_link and add wait_for_no_link a few additional fixes based on testing * fix macchanger and wait_for_link * remove unneeded note * This is where you change the mac address * We do not need network in off mode, no services anyway * ensure no dhcp during attack mode until requested * bash or python, but not php * The function is simple enough to not need a comment --Foxtrot
2020-01-24 02:44:17 +00:00
#!/bin/sh
2019-12-11 21:11:53 +00:00
2023-08-03 18:11:48 +00:00
OFFSET=480
GPIO0=$(($OFFSET))
GPIO2=$((2 + $OFFSET))
Housekeeping (#7) * fix LED killing * do not autostart unneeded services ntp: we don't want to leak in attack mode and arming mode doesn't even have internet. user's who want this can start it themselves dnsmasq: we should start this when needed rather than killing it when not needed, speed boot by not starting then killing * NETMODE: use dnsmasq netmode was improperly calling odhcpd when we use dnsmasq, just call dnsmasq * start dnsmasq when needed have shark service start dnsmasq in arming mode and stop it in attack and off mode * randomize mac with macchanger currently mac is randomized because it is unable to read the actual mac. If there gets fixed then the mac won't be randomized. Let's intentionally randomize the mac to be sure we are random enough * ensure netmode dhcp_server provides default gateway * prototype out switching between gateway and no gateway * actually disable gateway in arming mode * disable openvpn I don't know why this is trying to start, but let's not * better LED anti-suicide * permissions count * execute_payload: fix shellcheck warnings * convert BATTERY to posix runtime cut from 0.051s to 0.021s on average * shellcheck cleanup simplify script while doing it, use faster sh instead of bash * DO_A_BARREL_ROOL: this was posix anyway, so use posix * execute_payload: mostly posix, consider refactor * cleanup LED a bit partially elminate bashisms when possible to do cleanly shellcheck fixes for anti-hari kari (and it's faster) * POSIX NETMODE this was already posix except for function definitions * POSIX shark_framework fix minor logic error and posixify * shark_framework: save an awk * SWITCH: posix * LED: fix logic for SC2015 warnings * move wait_for_link and add wait_for_no_link a few additional fixes based on testing * fix macchanger and wait_for_link * remove unneeded note * This is where you change the mac address * We do not need network in off mode, no services anyway * ensure no dhcp during attack mode until requested * bash or python, but not php * The function is simple enough to not need a comment --Foxtrot
2020-01-24 02:44:17 +00:00
setup() {
2019-12-13 02:53:50 +00:00
echo "${1}" > /sys/class/gpio/export
echo in > "/sys/class/gpio/gpio${1}/direction"
2019-12-11 21:11:53 +00:00
}
Housekeeping (#7) * fix LED killing * do not autostart unneeded services ntp: we don't want to leak in attack mode and arming mode doesn't even have internet. user's who want this can start it themselves dnsmasq: we should start this when needed rather than killing it when not needed, speed boot by not starting then killing * NETMODE: use dnsmasq netmode was improperly calling odhcpd when we use dnsmasq, just call dnsmasq * start dnsmasq when needed have shark service start dnsmasq in arming mode and stop it in attack and off mode * randomize mac with macchanger currently mac is randomized because it is unable to read the actual mac. If there gets fixed then the mac won't be randomized. Let's intentionally randomize the mac to be sure we are random enough * ensure netmode dhcp_server provides default gateway * prototype out switching between gateway and no gateway * actually disable gateway in arming mode * disable openvpn I don't know why this is trying to start, but let's not * better LED anti-suicide * permissions count * execute_payload: fix shellcheck warnings * convert BATTERY to posix runtime cut from 0.051s to 0.021s on average * shellcheck cleanup simplify script while doing it, use faster sh instead of bash * DO_A_BARREL_ROOL: this was posix anyway, so use posix * execute_payload: mostly posix, consider refactor * cleanup LED a bit partially elminate bashisms when possible to do cleanly shellcheck fixes for anti-hari kari (and it's faster) * POSIX NETMODE this was already posix except for function definitions * POSIX shark_framework fix minor logic error and posixify * shark_framework: save an awk * SWITCH: posix * LED: fix logic for SC2015 warnings * move wait_for_link and add wait_for_no_link a few additional fixes based on testing * fix macchanger and wait_for_link * remove unneeded note * This is where you change the mac address * We do not need network in off mode, no services anyway * ensure no dhcp during attack mode until requested * bash or python, but not php * The function is simple enough to not need a comment --Foxtrot
2020-01-24 02:44:17 +00:00
check_gpio() {
2019-12-13 02:53:50 +00:00
if [ ! -d "/sys/class/gpio/gpio${1}" ]; then
setup "${1}"
2019-12-11 21:11:53 +00:00
fi
2019-12-13 02:53:50 +00:00
state=$(cat "/sys/class/gpio/gpio${1}/value")
echo "${state}"
2019-12-11 21:11:53 +00:00
}
gpio0=$(check_gpio $GPIO0)
gpio2=$(check_gpio $GPIO2)
2019-12-11 21:11:53 +00:00
2019-12-13 18:48:50 +00:00
if [ "${gpio0}" -eq "0" ] && [ "${gpio2}" -eq "0" ]; then
2019-12-11 21:11:53 +00:00
echo "switch1"
2019-12-13 18:48:50 +00:00
elif [ "${gpio0}" -eq "0" ]; then
2019-12-11 21:11:53 +00:00
echo "switch3"
2019-12-13 18:48:50 +00:00
elif [ "${gpio2}" -eq "0" ]; then
2019-12-11 21:11:53 +00:00
echo "switch2"
fi