├── LICENSE
├── README.md
└── leakscanner.sh
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Aziz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | LeakScanner
4 |
5 |
6 |
7 | Scan All GitHub Repositories at Once: Effortless Leak Detection
8 |
9 |
10 | LeakScanner is a Bash script inspired by Gitleaks, that allows you to scan multiple GitHub repositories at once for sensitive information leaks like passwords, api keys, and tokens. It automates the process of running the Gitleaks tool to detect potential leaks in each repository.
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | ## Table of Contents
20 |
21 | - [Features](#features)
22 | - [Prerequisites](#prerequisites)
23 | - [Usage](#usage)
24 | - [Configuration](#configuration)
25 | - [Contributing](#contributing)
26 | - [License](#license)
27 |
28 | ## Features
29 |
30 | - Scan both GitHub user profiles and organizations.
31 | - Fetch up to 1000 repositories per scan (GitHub API limitation).
32 | - Automatically clone all repositories and run Gitleaks to detect potential leaks.
33 |
34 |
35 | ## Prerequisites
36 |
37 | To perform leak detection, you need to Install [GitLeaks](https://github.com/gitleaks/gitleaks#installing) first. In order to Install this:
38 | 1. Clone this repository to your local machine
39 | ```bash
40 | git clone https://github.com/gitleaks/gitleaks.git
41 | ```
42 | 2. Navigate to the cloned directory:
43 | ```bash
44 | cd gitleaks
45 | ```
46 | 3. Run this command:
47 | ```bash
48 | make build
49 | ```
50 | Or follow the instructions on the [GitLeaks](https://github.com/gitleaks/gitleaks#installing) GitHub repository for your platform.
51 |
52 | ## Usage
53 |
54 | 1. Clone this repository to your local machine:
55 |
56 | ```bash
57 | git clone https://github.com/nxtexploit/LeakScanner.git
58 | ```
59 | 2. Navigate to the cloned directory:
60 | ```bash
61 | cd LeakScanner
62 | ```
63 | 3. Make the script executable:
64 | ```bash
65 | chmod +x leakscanner.sh
66 | ```
67 | 4. Run the script:
68 | ```bash
69 | ./leakscanner.sh
70 | ```
71 | 5. If you want to scan a **Organization account** then choose 1st options[1] of if want to scan a **Personal account** then choose the 2nd options[2]. Enter the username of your target. It will detect all the sensitive info like passwords, api keys, and tokens and so on.
72 |
73 |
74 | 6. There are plenty of features that you use after the scan over like [Verify Findings](https://github.com/gitleaks/gitleaks#verify-findings) and many more.
75 | ---
76 | ## Configuration
77 |
78 | + The script is interactive and will prompt you for the necessary inputs.
79 | + Review the script's source code to understand its behavior before using it.
80 |
81 | ## Contributing
82 |
83 | Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
84 |
85 | ## License
86 |
87 |
88 | This project is licensed under the [MIT License](LICENSE).
89 |
90 | The MIT License is a permissive open-source license that allows you to do almost anything with the code. It gives you permission to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software.
91 |
92 |
93 |
94 |
--------------------------------------------------------------------------------
/leakscanner.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | display_banner() {
4 | echo -e "\e[33m ○"
5 | echo " │╲"
6 | echo " │ ○ LeakScanner - Inspired by Gitleaks"
7 | echo " ○ ░ Scan all GitHub Repositories at once"
8 | echo " ░ Owner: nxtexploit "
9 | echo " Version: 1.0 "
10 | }
11 |
12 | display_banner
13 |
14 | # Ask the user whether to scan an organization or a profile
15 | read -p $'\e[32m\nScan Organization repositories (1) or User repositories (2)?\e[0m [1/2]: ' CHOICE
16 |
17 | if [[ $CHOICE == "1" ]]; then
18 | # Ask the user to input the GitHub organization name
19 | read -p $'\e[32m\nTarget ORG username:\e[0m ' TARGET_NAME
20 | API_URL="https://api.github.com/orgs/${TARGET_NAME}/repos?per_page=1000"
21 | else
22 | # Ask the user to input the GitHub user profile name
23 | read -p $'\e[32m\nTarget User username:\e[0m ' TARGET_NAME
24 | API_URL="https://api.github.com/users/${TARGET_NAME}/repos?per_page=1000"
25 | fi
26 |
27 | # Fetch repositories using the GitHub REST API
28 | echo "Fetching repositories for ${TARGET_NAME}..."
29 | REPO_URLS=$(curl -s ${API_URL} | grep -o "git://.*\.git" | tr ' ' '\n')
30 |
31 | if [[ -z ${REPO_URLS} ]]; then
32 | echo "No repositories found for ${TARGET_NAME}."
33 | exit 1
34 | fi
35 |
36 | # Loop through the repository URLs and clone each repository
37 | echo "Found $(echo ${REPO_URLS} | tr ' ' '\n' | wc -l) repositories."
38 |
39 | for url in ${REPO_URLS}
40 | do
41 | # Extract the repository name from the URL
42 | REPO_NAME=$(echo ${url} | sed 's#.*/\(.*\)\.git#\1#')
43 |
44 | # Clone the repository into a temporary directory
45 | echo "Cloning repository ${REPO_NAME} please wait..."
46 | git clone https://github.com/${TARGET_NAME}/${REPO_NAME}.git
47 |
48 | # Change directory to the repository
49 | echo "Changing directory to ${REPO_NAME}"
50 | cd ${REPO_NAME}
51 |
52 | # Scan the repository using Gitleaks
53 | echo -e "Scanning repository \e[32m${REPO_NAME}\e[0m using Gitleaks..."
54 | gitleaks detect -v
55 |
56 | # Go back to the previous directory
57 | echo "Going back to the previous directory..."
58 | cd ..
59 |
60 | # Delete the temporary directory
61 | echo "Deleting directory ${REPO_NAME}..."
62 | rm -rf ${REPO_NAME}
63 | done
64 |
--------------------------------------------------------------------------------