-
Notifications
You must be signed in to change notification settings - Fork 1
/
leakscanner.sh
63 lines (50 loc) · 2.09 KB
/
leakscanner.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
display_banner() {
echo -e "\e[33m ○"
echo " │╲"
echo " │ ○ LeakScanner - Inspired by Gitleaks"
echo " ○ ░ Scan all GitHub Repositories at once"
echo " ░ Owner: nxtexploit "
echo " Version: 1.0 "
}
display_banner
# Ask the user whether to scan an organization or a profile
read -p $'\e[32m\nScan Organization repositories (1) or User repositories (2)?\e[0m [1/2]: ' CHOICE
if [[ $CHOICE == "1" ]]; then
# Ask the user to input the GitHub organization name
read -p $'\e[32m\nTarget ORG username:\e[0m ' TARGET_NAME
API_URL="https://api.github.com/orgs/${TARGET_NAME}/repos?per_page=1000"
else
# Ask the user to input the GitHub user profile name
read -p $'\e[32m\nTarget User username:\e[0m ' TARGET_NAME
API_URL="https://api.github.com/users/${TARGET_NAME}/repos?per_page=1000"
fi
# Fetch repositories using the GitHub REST API
echo "Fetching repositories for ${TARGET_NAME}..."
REPO_URLS=$(curl -s ${API_URL} | grep -o "git://.*\.git" | tr ' ' '\n')
if [[ -z ${REPO_URLS} ]]; then
echo "No repositories found for ${TARGET_NAME}."
exit 1
fi
# Loop through the repository URLs and clone each repository
echo "Found $(echo ${REPO_URLS} | tr ' ' '\n' | wc -l) repositories."
for url in ${REPO_URLS}
do
# Extract the repository name from the URL
REPO_NAME=$(echo ${url} | sed 's#.*/\(.*\)\.git#\1#')
# Clone the repository into a temporary directory
echo "Cloning repository ${REPO_NAME} please wait..."
git clone https://github.com/${TARGET_NAME}/${REPO_NAME}.git
# Change directory to the repository
echo "Changing directory to ${REPO_NAME}"
cd ${REPO_NAME}
# Scan the repository using Gitleaks
echo -e "Scanning repository \e[32m${REPO_NAME}\e[0m using Gitleaks..."
gitleaks detect -v
# Go back to the previous directory
echo "Going back to the previous directory..."
cd ..
# Delete the temporary directory
echo "Deleting directory ${REPO_NAME}..."
rm -rf ${REPO_NAME}
done