Merge pull request #3 from ZeroChaos-/extensions

add extension support
dev
Marc 2020-01-07 20:14:03 +00:00 committed by GitHub
commit 6cb3073db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 29 deletions

View File

@ -0,0 +1,11 @@
## Extensions folder
#
# The 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

34
usr/bin/execute_payload Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
LOG="logger -t Shark [*]"
$LOG "Executing PAYLOAD"
if [ ! -d /root/loot ]; then
mkdir -p /root/loot;
fi
payload_path="/root/payload"
payload=$(ls $payload_path/payload* 2>/dev/null | tail -n1)
extension_path="/root/payload/extensions/"
if [ -d "${extension_path}" ] && [ -n "$(ls -A ${extension_path})" ]; then
for extension in ${extension_path}*; do
source "${extension}"
done
eval "$(declare -F | sed -e 's/-f /-fx /')"
fi
case $(basename "${payload}") in
"payload.py")
python "${payload}" &> /dev/null
;;
"payload.php")
php-cli "${payload}" &> /dev/null
;;
"payload" | "payload.sh" | "payload.txt")
sed -i 's/\r//g' $payload
bash -C "${payload}" &> /dev/null
;;
*)
/usr/bin/LED FAIL
;;
esac

View File

@ -106,35 +106,8 @@ function wait_for_link() {
LED SETUP
}
function execute_payload() {
$LOG "Executing PAYLOAD"
if [ ! -d /root/loot ]; then
mkdir -p /root/loot;
fi
payload_path="/root/payload"
payload=$(ls $payload_path/payload* 2>/dev/null | tail -n1)
case $(basename $payload) in
"payload.py")
echo "python $payload &> /dev/null" | at now
;;
"payload.php")
echo "php-cli $payload &> /dev/null" | at now
;;
"payload" | "payload.sh" | "payload.txt")
sed -i 's/\r//g' $payload
echo "bash -C '$payload'" | at now
;;
*)
/usr/bin/LED FAIL
;;
esac
}
function configure_network() {
cp /usr/lib/config/${SWITCH_POSITION}/network /etc/config/network
cp "/usr/lib/hak5/shark/config/${SWITCH_POSITION}/network" /etc/config/network
/etc/init.d/network restart
}
@ -164,7 +137,7 @@ function enter_attack_mode() {
stop_ssh
wait_for_link
execute_payload
echo "execute_payload" | at now
enter_idle_mode
}