mirror of
https://github.com/hak5/bashbunny-payloads.git
synced 2025-10-29 16:58:25 +00:00
41 lines
1.0 KiB
Bash
41 lines
1.0 KiB
Bash
#!/bin/bash
|
|
|
|
################################################################################
|
|
# Allow Debugging messages written to: "/root/udisk/debug/[session].txt"
|
|
# on the BashBunny
|
|
#
|
|
# How this works?
|
|
# 1) Example Command: DEBUG "switch-1-debug" "Hello from debug extension!"
|
|
# 2) After bashing, text can be read at: "/root/udisk/debug/[session].txt"
|
|
# on the BashBunny
|
|
################################################################################
|
|
|
|
function DEBUG() {
|
|
session = $1
|
|
message = $2
|
|
|
|
init_debug
|
|
debug_log
|
|
|
|
timestamp () {
|
|
echo "$(date +"%Y-%m-%d_%H-%M-%S")"
|
|
}
|
|
|
|
init_debug () {
|
|
DEBUG_FILE="/root/udisk/debug/$(session).txt"
|
|
if [ ! -d "/root/udisk/debug/" ]; then
|
|
mkdir /root/udisk/debug/
|
|
fi
|
|
if [ ! -f "/root/udisk/debug/${DEBUG_FILE}" ]; then
|
|
touch "${DEBUG_FILE}"
|
|
echo "$(timestamp): DEBUG STARTED" >> "${DEBUG_FILE}"
|
|
fi
|
|
}
|
|
|
|
debug_log () {
|
|
echo "$(timestamp): $(message)" >> "${DEBUG_FILE}"
|
|
}
|
|
}
|
|
|
|
export -f DEBUG
|