From 751c84834f628189f8e41a666d331486cc20b7aa Mon Sep 17 00:00:00 2001 From: thehermit Date: Sat, 4 Mar 2017 18:56:22 +0000 Subject: [PATCH 1/2] Allows you to use $switchposition in payloads. Useful for building paths relative to payload/ --- payloads/library/bunny_helpers.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/payloads/library/bunny_helpers.sh b/payloads/library/bunny_helpers.sh index 110c3ca3..4b157bc9 100644 --- a/payloads/library/bunny_helpers.sh +++ b/payloads/library/bunny_helpers.sh @@ -17,3 +17,25 @@ export TARGET_HOSTNAME=$(cat $leasefile | grep hostname | awk '{print $2 }' \ | sort | uniq | tail -n1 | sed "s/^[ \t]*//" | sed 's/\"//g' | sed 's/;//') export HOST_IP=$(cat /etc/network/interfaces.d/usb0 | grep address | awk {'print $2'}) +################################################################################ +# Get switch position +# Taken from bash_bunny.sh +################################################################################ + +check_switch() { + switch1=`cat /sys/class/gpio_sw/PA8/data` + switch2=`cat /sys/class/gpio_sw/PL4/data` + switch3=`cat /sys/class/gpio_sw/PL3/data` + echo "--- switch1 = $switch1, switch2 = $switch2, switch3 = $switch3" + if [ "x$switch1" = "x0" ] && [ "x$switch2" = "x1" ] && [ "x$switch3" = "x1" ]; then + switchposition="switch1" + elif [ "x$switch1" = "x1" ] && [ "x$switch2" = "x0" ] && [ "x$switch3" = "x1" ]; then + switchposition="switch2" + elif [ "x$switch1" = "x1" ] && [ "x$switch2" = "x1" ] && [ "x$switch3" = "x0" ]; then + switchposition="switch3" + else + switchposition="invalid" + fi +} + +check_switch \ No newline at end of file From 1642cf2142f3628aefd56bdf11ee0c0678fdc043 Mon Sep 17 00:00:00 2001 From: thehermit Date: Sat, 4 Mar 2017 20:22:32 +0000 Subject: [PATCH 2/2] Change Case and add export --- payloads/library/bunny_helpers.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/payloads/library/bunny_helpers.sh b/payloads/library/bunny_helpers.sh index 4b157bc9..acb2f9c3 100644 --- a/payloads/library/bunny_helpers.sh +++ b/payloads/library/bunny_helpers.sh @@ -28,14 +28,15 @@ check_switch() { switch3=`cat /sys/class/gpio_sw/PL3/data` echo "--- switch1 = $switch1, switch2 = $switch2, switch3 = $switch3" if [ "x$switch1" = "x0" ] && [ "x$switch2" = "x1" ] && [ "x$switch3" = "x1" ]; then - switchposition="switch1" + SWITCH_POSITION="switch1" elif [ "x$switch1" = "x1" ] && [ "x$switch2" = "x0" ] && [ "x$switch3" = "x1" ]; then - switchposition="switch2" + SWITCH_POSITION="switch2" elif [ "x$switch1" = "x1" ] && [ "x$switch2" = "x1" ] && [ "x$switch3" = "x0" ]; then - switchposition="switch3" + SWITCH_POSITION="switch3" else - switchposition="invalid" + SWITCH_POSITION="invalid" fi } -check_switch \ No newline at end of file +check_switch +export SWITCH_POSITION \ No newline at end of file