initial commit via gitinitshit
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
# packages required: git trufflehog gitsecrets pup
|
||||
|
||||
# todo: make dis an arg
|
||||
github_username='nationalsecurityagency'
|
||||
github_base='https://github.com/'
|
||||
github_repos_page="$github_base/$github_username/"
|
||||
|
||||
# todo: make dis handle pagination
|
||||
repos=$(curl -sS "${github_repos_page}?tab=repositories" | grep 'name codeRepository' | pup 'a attr{href}' | sed 's/\/PrincessPi3\///')
|
||||
|
||||
out_dir="$PWD/$github_username" #todo: make dis an arg
|
||||
mkdir -p "$out_dir"
|
||||
secretsfile="$PWD/secrets_${github_username}.txt"
|
||||
|
||||
nuke_repos_dir() {
|
||||
if [ -d "$out_dir" ]; then
|
||||
printf "deleting existing $out_dir... "
|
||||
rm -rf "$out_dir" > /dev/null 2>&1
|
||||
printf "$?\n"
|
||||
|
||||
printf "remaking $out_dir... "
|
||||
mkdir -p "$out_dir"
|
||||
printf "$?\n"
|
||||
fi
|
||||
}
|
||||
|
||||
clone_repos() {
|
||||
for repo in "${repos[@]}"; do
|
||||
printf "cloning $repo into $out_dir/$repo..."
|
||||
|
||||
git clone --recursive "$github_repos_page/$repo" "$out_dir/$repo" > /dev/null 2>&1
|
||||
|
||||
printf "$?\n"
|
||||
done
|
||||
}
|
||||
|
||||
snoop_repos() {
|
||||
for repo in "${repos[@]}"; do
|
||||
cd "$out_dir/$repo"
|
||||
pwd | tee -a "$secretsfile"
|
||||
trufflehog git file://. | tee -a "$secretsfile"
|
||||
gitleaks detect -v | tee -a "$secretsfile"
|
||||
cd -
|
||||
done
|
||||
}
|
||||
|
||||
# run em ig
|
||||
nuke_repos_dir
|
||||
clone_repos
|
||||
snoop_repos
|
||||
Reference in New Issue
Block a user