add extension support

pull/3/head
Rick Farina (Zero_Chaos) 2019-12-12 13:46:46 -05:00
parent 3f7825b03a
commit 93a23d1eb9
No known key found for this signature in database
GPG Key ID: A29433C0AA431DDC
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,11 @@
## Extensions folder
#
# This files in this folder are sourced just before payload execution.
# Users can add helper functions in here and use those functions in their payloads if desired.
# Example which allows you to call "example" from payload script:
#
# function example() {
# printf 'I am an example!\n'
# }
#
# export -f example

View File

@ -106,6 +106,14 @@ function wait_for_link() {
LED SETUP
}
function source_extensions() {
if [ -d "/root/payload/extensions" ] && [ -n "$(ls -A /root/payload/extensions/)" ]; then
for extension in /root/payloads/extensions/*; do
source "${extension}"
done
fi
}
function execute_payload() {
$LOG "Executing PAYLOAD"
@ -116,6 +124,7 @@ function execute_payload() {
payload_path="/root/payload"
payload=$(ls $payload_path/payload* 2>/dev/null | tail -n1)
source_extensions
case $(basename $payload) in
"payload.py")
echo "python $payload &> /dev/null" | at now
@ -134,7 +143,7 @@ function execute_payload() {
}
function configure_network() {
cp /usr/lib/hak5/shark/config/${SWITCH_POSITION}/network /etc/config/network
cp "/usr/lib/hak5/shark/config/${SWITCH_POSITION}/network" /etc/config/network
/etc/init.d/network restart
}