Added better logging for debugging and updated read-me

This commit is contained in:
Mathew Fleisch 2017-03-16 10:29:11 -07:00
parent 00a365a706
commit a1fcf6d584
2 changed files with 18 additions and 7 deletions

View File

@ -13,7 +13,7 @@ Configured for nix by default. Swap RNDIS_ETHERNET with ECM_ETHERNET on Windows
## Requirements
Target must be sharing internet.
Target must be sharing internet and have git installed.
1. Run bb.sh (pause at main menu)
2. Plug in da bunny
@ -26,6 +26,7 @@ Target must be sharing internet.
| ---------------- | ------------------------------------- |
| White | Ready (to share internet connection) |
| Red | Failed (no internet) |
| Red (blinking) | Failed (could not mount filesystem) |
| Amber | Running |
| Purple | Cleaning Up |
| Green (blinking) | Finished (git pull) |

View File

@ -24,13 +24,13 @@ git_branch="master"
payloads_dir="/root/udisk"
log_file="/root/udisk/git.log"
echo "Git Bunny Git" >> $log_file
echo " --------- Git Bunny Git [started] -----------" >> $log_file
[[ ! -d "$payloads_dir/payloads" ]] && { LED R; echo "Could not mount filesystem" >> $log_file; exit 1; }
[[ ! -d "$payloads_dir/payloads" ]] && { LED R 200; echo "Could not mount filesystem" >> $log_file; exit 1; }
# Test for internet connection
wget -q --tries=15 --timeout=5 --spider http://example.com
[[ "$?" -ne 0 ]] && { LED R; exit 1; }
[[ "$?" -ne 0 ]] && { LED R; echo "Could not connect to the internet" >> $log_file; exit 1; }
# Let's go
LED R G
@ -41,27 +41,36 @@ export GIT_SSL_NO_VERIFY=1
if [ -d ".git" ]; then
# Get the newest payloads
git pull origin $git_branch &>> $log_file
echo "Git repository updated." >> $log_file
LED G 200
exit 1
else
# Move the existing payloads directory, in case hackers be hackin'
mv payloads payloads-orig
echo "Existing 'payloads' directory preserved as 'payloads-orig'" >> $log_file
# Initialize Repository
git init &>> $log_file
# Let's pick the hak5 github repo
git remote add origin $git_repo &>> $log_file
echo "Git repository selected: $git_repo" >> $log_file
# Instead of cloning the whole repo,
git config core.sparsecheckout true
echo "Git configuration change: sparse-checkout=true." >> $log_file
# isolate the payloads directory
echo "payloads" >> .git/info/sparse-checkout
echo "Sparse checkout: 'payloads' directory selected" >> $log_file
# "git clone"
git pull origin $git_branch &>> $log_file
echo "Git repository cloned." >> $log_file
# Ignore any existing directories or files, so git status is pretty
# Ignore any existing directories or files, so git status is pretty, and git pull will work after the "clone"
LED R B
for file in $(ls -A); do
[[ "${file}" =~ [^payloads$] ]] && echo "${file}" >> .gitignore
[[ "${file}" =~ [^payloads$] ]] && { echo "${file}" >> .gitignore; echo ".gitignore add: ${file}" >> $log_file; }
done
echo "payloads/switch1" >> .gitignore
echo ".gitignore add: payloads/switch1" >> $log_file;
echo "payloads/switch2" >> .gitignore
echo ".gitignore add: payloads/switch2" >> $log_file;
# Put the existing switch directories back
cp -r payloads-orig/switch* payloads/.
@ -69,3 +78,4 @@ else
# Git 'er done
LED G
fi
echo " --------- Git Bunny Git [finished] ----------" >> $log_file