shark-files/usr/bin/LED

267 lines
7.1 KiB
Plaintext
Raw Permalink Normal View History

2019-12-11 21:11:53 +00:00
#!/bin/bash
2023-08-04 22:42:24 +00:00
RED_LED="/sys/class/leds/led_red/brightness"
GREEN_LED="/sys/class/leds/led_green/brightness"
BLUE_LED="/sys/class/leds/led_blue/brightness"
2019-12-11 21:11:53 +00:00
colors=(0 0 0)
pattern=(1 0 0 0 0 0)
function convert() {
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
if [ "${1}" -lt 20 ]; then
echo 0.02
else
echo "${1}" 1000 | awk '{ print $1/$2 }'
fi
2019-12-11 21:11:53 +00:00
}
function parse_color() {
case $1 in
"R")
colors=(1 0 0)
;;
"G")
colors=(0 1 0)
;;
"B")
colors=(0 0 1)
;;
"Y")
colors=(1 1 0)
;;
"C")
colors=(0 1 1)
;;
"M")
colors=(1 0 1)
;;
"W")
colors=(1 1 1)
;;
*)
return 1
;;
esac
}
function parse_pattern() {
local INVERTED="0"
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
[[ "$(echo ${1} | head -c1)" == "I" ]] && {
2019-12-11 21:11:53 +00:00
INVERTED="1"
}
case $1 in
"SLOW")
pattern=(0 0 1 $(convert 1000) $(convert 1000) 1)
;;
"FAST")
pattern=(0 0 1 $(convert 100) $(convert 100) 1)
;;
"VERYFAST")
pattern=(0 0 1 $(convert 10) $(convert 10) 1)
;;
"ISINGLE" | "SINGLE")
pattern=(0 $INVERTED 1 $(convert 100) $(convert 1000) 1)
;;
"IDOUBLE" | "DOUBLE")
pattern=(0 $INVERTED 2 $(convert 100) $(convert 1000) 1)
;;
"ITRIPLE" | "TRIPLE")
pattern=(0 $INVERTED 3 $(convert 100) $(convert 1000) 1)
;;
"IQUAD" | "QUAD")
pattern=(0 $INVERTED 4 $(convert 100) $(convert 1000) 1)
;;
"IQUIN" | "QUIN")
pattern=(0 $INVERTED 5 $(convert 100) $(convert 1000) 1)
;;
"SUCCESS")
pattern=(0 0 1 $(convert 10) $(convert 10) 0)
;;
*)
[[ $1 =~ ^-?[0-9]+$ ]] && pattern=(0 0 1 $(convert $1) $(convert $1) 1) || pattern=(1 0 0 0 0 0)
;;
esac
return 0
}
function parse_state() {
local STATENUM="1"
[[ $1 =~ ^[A-Z]+[1-5]$ ]] && {
STATENUM="${1: -1}"
}
case $1 in
"LINKSETUP")
parse_color "M"
parse_pattern "SLOW"
;;
2019-12-11 21:11:53 +00:00
"SETUP")
parse_color "M"
parse_pattern "SOLID"
;;
"FAIL" | FAIL[1-3])
parse_color "R"
parse_pattern "SLOW"
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
pattern[3]=$(convert "$(echo -n 1000 | head -c $((5-STATENUM)))")
2019-12-11 21:11:53 +00:00
;;
"ATTACK" | STAGE[1-5])
parse_color "Y"
parse_pattern "SINGLE"
pattern[2]=$STATENUM
;;
"SPECIAL" | SPECIAL[1-5])
parse_color "C"
parse_pattern "ISINGLE"
pattern[2]=$STATENUM
;;
"CLEANUP")
parse_color "W"
parse_pattern "FAST"
;;
"FINISH")
parse_color "G"
parse_pattern "SUCCESS"
;;
"OFF")
;;
*)
return 1
;;
esac
return 0
}
function clear_led() {
echo 0 > $RED_LED 2>&1
echo 0 > $GREEN_LED 2>&1
echo 0 > $BLUE_LED 2>&1
}
function light_led() {
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
echo "${colors[0]}" > $RED_LED 2>&1
echo "${colors[1]}" > $GREEN_LED 2>&1
echo "${colors[2]}" > $BLUE_LED 2>&1
2019-12-11 21:11:53 +00:00
}
function blink_loop() {
local sc=1
until [[ "$sc" == "10" ]]; do
for i in $(seq 1 ${pattern[2]}); do
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
if [ "${pattern[1]}" == "0" ];then
light_led
else
clear_led
fi
sleep "${pattern[3]}"
if [ "${pattern[1]}" == "0" ];then
clear_led
else
light_led
fi
sleep "${pattern[3]}"
2019-12-11 21:11:53 +00:00
done
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
sleep "${pattern[4]}"
2019-12-11 21:11:53 +00:00
[[ "${pattern[5]}" == "0" ]] && sc=$((sc+1))
done
[[ "${pattern[5]}" == "0" ]] && light_led
}
function run_led() {
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
parse_state "${1}" || {
parse_color "${1}" || return 1
[[ "$#" == "2" ]] && parse_pattern "${2}"
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
if [ "${pattern[0]}" == "1" ];then
2019-12-11 21:11:53 +00:00
light_led &
return 0
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
else
2019-12-11 21:11:53 +00:00
blink_loop &
return 0
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
fi
2019-12-11 21:11:53 +00:00
return 1
}
function show_usage() {
cat << EOF
Usage: LED [COLOR] [PATTERN] or LED [STATE]
COLORS:
R Red
G Green
B Blue
Y, R G Yellow (Commonly known as Amber)
C, G B Cyan (Commonly known as Light Blue)
M, R B Magenta (Commonly known as Violet or Purple)
W, R G B White (Combination of R + G + B)
PATTERNS:
SOLID *Default. No blink. Used if pattern argument is omitted
SLOW Symmetric 1000ms ON, 1000ms OFF, repeating
FAST Symmetric 100ms ON, 100ms OFF, repeating
VERYFAST Symmetric 10ms ON, 10ms OFF, repeating
SINGLE 1 100ms blink(s) ON followed by 1 second OFF, repeating
DOUBLE 2 100ms blink(s) ON followed by 1 second OFF, repeating
TRIPLE 3 100ms blink(s) ON followed by 1 second OFF, repeating
QUAD 4 100ms blink(s) ON followed by 1 second OFF, repeating
QUIN 5 100ms blink(s) ON followed by 1 second OFF, repeating
ISINGLE 1 100ms blink(s) OFF followed by 1 second ON, repeating
IDOUBLE 2 100ms blink(s) OFF followed by 1 second ON, repeating
ITRIPLE 3 100ms blink(s) OFF followed by 1 second ON, repeating
IQUAD 4 100ms blink(s) OFF followed by 1 second ON, repeating
IQUIN 5 100ms blink(s) OFF followed by 1 second ON, repeating
SUCCESS 1000ms VERYFAST blink followed by SOLID
# Custom value in ms for continuous symmetric blinking
STATES:
In addition to the combinations of COLORS and PATTERNS listed above,
these standardized LED STATES may be used to indicate payload status:
SETUP M SOLID Magenta solid
FAIL R SLOW Red slow blink
FAIL1 R SLOW Red slow blink
FAIL2 R FAST Red fast blink
FAIL3 R VERYFAST Red very fast blink
ATTACK Y SINGLE Yellow single blink
STAGE1 Y SINGLE Yellow single blink
STAGE2 Y DOUBLE Yellow double blink
STAGE3 Y TRIPLE Yellow triple blink
STAGE4 Y QUAD Yellow quadruple blink
STAGE5 Y QUIN Yellow quintuple blink
SPECIAL C ISINGLE Cyan inverted single blink
SPECIAL1 C ISINGLE Cyan inverted single blink
SPECIAL2 C IDOUBLE Cyan inverted double blink
SPECIAL3 C ITRIPLE Cyan inverted triple blink
SPECIAL4 C IQUAD Cyan inverted quadruple blink
SPECIAL5 C IQUIN Cyan inverted quintuple blink
CLEANUP W FAST White fast blink
FINISH G SUCCESS Green very fast blink followed by SOLID
OFF Turns the LED off
Examples:
LED Y SINGLE
LED M 500
LED SETUP
EOF
}
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
#so pgrep/pkill exclude their own pid, but not their parent
#the parent is this script, which we don't want to kill
if pgrep -f LED | grep -qvE "$$|${PPID}"; then
kill "$(pgrep -f LED | grep -vE "$$|${PPID}" | tr '\n' ' ')" > /dev/null 2>&1
fi
if pgrep -f DO_A_BARREL_ROLL | grep -qvE "$$|${PPID}"; then
kill "$(pgrep -f DO_A_BARREL_ROLL | grep -vE "$$|${PPID}" | tr '\n' ' ')" > /dev/null 2>&1
fi
run_led "$@" || show_usage