diff --git a/payloads/library/remote-access/openvpn/payload.sh b/payloads/library/remote-access/openvpn/payload.sh index 37bf7b3..4a8734a 100755 --- a/payloads/library/remote-access/openvpn/payload.sh +++ b/payloads/library/remote-access/openvpn/payload.sh @@ -1,12 +1,13 @@ #!/bin/bash -# -# Title: OpenVPN -# Description: Create a connection to a VPN-connection to an OpenVPN-server. Optionally: Send traffic from the clients through said tunnel. -# Author: Hak5 -# Version: 1.0 -# Category: remote-access -# Target: Any -# Net Mode: BRIDGE, VPN +# +# Title: OpenVPN +# Description: Create a VPN connection to an OpenVPN server. Optionally, send +# traffic from the clients through said tunnel. +# Author: Hak5 +# Version: 1.1 +# Category: remote-access +# Target: Any +# Net Mode: BRIDGE, VPN # Set to 1 to allow clients to use the VPN FOR_CLIENTS=0 @@ -29,12 +30,7 @@ function start() { DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) - # Update factory default payload - cp ${DIR}/payload.sh /root/payloads/switch3/payload.sh - - # Set NETMODE to BRIDGE and wait 3 seconds - # to ensure that things can settle - + # Set NETMODE to BRIDGE and wait 3 seconds to ensure that things can settle [[ "$FOR_CLIENTS" == "1" ]] && { /usr/bin/NETMODE VPN } || { @@ -56,6 +52,37 @@ function start() { setdns & LED ATTACK + + # Cycle between VPN configs when the button is pressed. The default + # "config.ovpn" will be loaded on startup, and pressing the button will + # cycle through all numbered VPN configs. To use this, add additional VPN + # configs named "config1.ovpn", "config2.ovpn", etc. + # + # If no numbered configs exist, the button functions as a way to reset the + # VPN connection. + next=1 + while true; do + NO_LED=true BUTTON + + # Stop openvpn and update the LED + LED SETUP + /etc/init.d/openvpn stop + + # Determine which config to load next + if [ -f "${DIR}/config${next}.ovpn" ]; then + uci set openvpn.vpn.config="${DIR}/config${next}.ovpn" + uci commit + next=$(($next + 1)) + elif [ -f "${DIR}/config1.ovpn" ]; then + uci set openvpn.vpn.config="${DIR}/config1.ovpn" + uci commit + next=1 + fi + + # Start openvpn and update the LED + /etc/init.d/openvpn start + LED ATTACK + done } # Start the payload