Skip to content

reconFTW is a tool designed to perform automated recon on a target domain by running the best set of tools to perform scanning and finding out vulnerabilities

ghleaks

six2dez44b49a71c4cc
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6466741..96f2f8a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -111,6 +111,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `favirecon` as `favirecon_tech` for favicon-based technology reconnaissance.
- `TInjA` as the default `ssti` engine (`SSTI_ENGINE=TInjA`, with legacy fallback).
- `second-order` as default `brokenLinks` engine (`BROKENLINKS_ENGINE=second-order`, with legacy fallback).
+ - `ghleaks` in `github_leaks` for GitHub-wide secret search across all public repositories (combines GitHub Code Search API with gitleaks detection rules). Configurable via `GITHUB_LEAKS`, `GHLEAKS_THREADS`, and `--exhaustive` mode in DEEP.
**Progress and UX**
- Progress/ETA functions (`progress_init()`, `progress_step()`) integrated in recon flows.
diff --git a/install.sh b/install.sh
index 4f8ed74..fccf8c0 100755
--- a/install.sh
+++ b/install.sh
@@ -286,6 +286,7 @@ declare -A repos=(
["Web-Cache-Vulnerability-Scanner"]="Hackmanit/Web-Cache-Vulnerability-Scanner"
["regulator"]="cramppet/regulator"
["gitleaks"]="gitleaks/gitleaks"
+ ["ghleaks"]="dinosn/ghleaks"
["trufflehog"]="trufflesecurity/trufflehog"
["nomore403"]="devploit/nomore403"
["SwaggerSpy"]="UndeadSec/SwaggerSpy"
@@ -497,6 +498,9 @@ function install_tools() {
"gitleaks")
make build &>/dev/null && $SUDO cp ./gitleaks /usr/local/bin/ &>/dev/null
;;
+ "ghleaks")
+ go build -o ghleaks . &>/dev/null && chmod +x ./ghleaks
+ ;;
"nomore403")
go get &>/dev/null
go build &>/dev/null
diff --git a/modules/core.sh b/modules/core.sh
index 7d5fa89..550eac9 100644
--- a/modules/core.sh
+++ b/modules/core.sh
@@ -208,7 +208,6 @@ function tools_installed() {
["spoofy_python"]="${tools}/Spoofy/venv/bin/python3"
["swaggerspy"]="${tools}/SwaggerSpy/swaggerspy.py"
["swaggerspy_python"]="${tools}/SwaggerSpy/venv/bin/python3"
- ["postleaksNg"]="postleaksNg"
["LeakSearch"]="${tools}/LeakSearch/LeakSearch.py"
["LeakSearch_python"]="${tools}/LeakSearch/venv/bin/python3"
["msftrecon"]="${tools}/msftrecon/msftrecon/msftrecon.py"
@@ -221,6 +220,7 @@ function tools_installed() {
["metagoofil_python"]="${tools}/metagoofil/venv/bin/python3"
["reconftw_ai"]="${tools}/reconftw_ai/reconftw_ai.py"
["reconftw_ai_python"]="${tools}/reconftw_ai/venv/bin/python3"
+ ["ghleaks"]="${tools}/ghleaks/ghleaks"
)
declare -A tools_folders=(
@@ -251,6 +251,7 @@ function tools_installed() {
["gotator"]="gotator"
["Nuclei"]="nuclei"
["gf"]="gf"
+ ["postleaksNg"]="postleaksNg"
["Gxss"]="Gxss"
["subjs"]="subjs"
["ffuf"]="ffuf"
@@ -271,9 +272,9 @@ function tools_installed() {
["interactsh-client"]="interactsh-client"
["tlsx"]="tlsx"
["smap"]="smap"
- ["gitdorks_go"]="gitdorks_go"
- ["smugglex"]="smugglex"
- ["dsieve"]="dsieve"
+ ["gitdorks_go"]="gitdorks_go"
+ ["smugglex"]="smugglex"
+ ["dsieve"]="dsieve"
["inscope"]="inscope"
["enumerepo"]="enumerepo"
["Web-Cache-Vulnerability-Scanner"]="Web-Cache-Vulnerability-Scanner"
@@ -286,9 +287,9 @@ function tools_installed() {
["s3scanner"]="s3scanner"
["mantra"]="mantra"
["nmapurls"]="nmapurls"
- ["naabu"]="naabu"
- ["porch-pirate"]="porch-pirate"
- ["shortscan"]="shortscan"
+ ["naabu"]="naabu"
+ ["porch-pirate"]="porch-pirate"
+ ["shortscan"]="shortscan"
["cewler"]="cewler"
["hakoriginfinder"]="hakoriginfinder"
["sourcemapper"]="sourcemapper"
diff --git a/modules/modes.sh b/modules/modes.sh
index 9533a85..0f57677 100644
--- a/modules/modes.sh
+++ b/modules/modes.sh
@@ -420,6 +420,7 @@ function passive() {
google_dorks
#github_dorks
github_repos
+ github_leaks
metadata
apileaks
third_party_misconfigs
@@ -478,6 +479,7 @@ function osint() {
google_dorks
#github_dorks
github_repos
+ github_leaks
metadata
apileaks
third_party_misconfigs
@@ -613,6 +615,7 @@ function multi_osint() {
google_dorks
#github_dorks
github_repos
+ github_leaks
metadata
apileaks
third_party_misconfigs
@@ -646,7 +649,7 @@ function recon() {
RECON_OSINT_PARALLEL_FAILURES=$((RECON_OSINT_PARALLEL_FAILURES + osint_g1_rc))
fi
# Group 2: remaining OSINT + zonetransfer
- parallel_funcs "${PAR_OSINT_GROUP2_SIZE:-4}" github_repos metadata apileaks zonetransfer
+ parallel_funcs "${PAR_OSINT_GROUP2_SIZE:-4}" github_repos github_leaks metadata apileaks zonetransfer
local osint_g2_rc=$?
if ((osint_g2_rc > 0)); then
RECON_PARTIAL_RUN=true
@@ -659,6 +662,7 @@ function recon() {
google_dorks
#github_dorks
github_repos
+ github_leaks
metadata
apileaks
third_party_misconfigs
@@ -842,6 +846,7 @@ function multi_recon() {
google_dorks
#github_dorks
github_repos
+ github_leaks
metadata
apileaks
third_party_misconfigs
diff --git a/modules/osint.sh b/modules/osint.sh
index 60da53c..58f6c5d 100644
--- a/modules/osint.sh
+++ b/modules/osint.sh
@@ -1,9 +1,9 @@
#!/bin/bash
# shellcheck disable=SC2154 # Variables defined in reconftw.cfg
# reconFTW - OSINT module
-# Contains: google_dorks, github_dorks, github_repos, metadata, apileaks,
-# emails, domain_info, third_party_misconfigs, spoof, mail_hygiene,
-# cloud_enum_scan, ip_info
+# Contains: google_dorks, github_dorks, github_repos, github_leaks, metadata,
+# apileaks, emails, domain_info, third_party_misconfigs, spoof,
+# mail_hygiene, cloud_enum_scan, ip_info
# This file is sourced by reconftw.sh - do not execute directly
[[ -z "${SCRIPTPATH:-}" ]] && {
echo "Error: This module must be sourced by reconftw.sh" >&2
@@ -150,6 +150,46 @@ function github_repos() {
fi
}
+function github_leaks() {
+ ensure_dirs osint
+
+ if { [[ ! -f "$called_fn_dir/.${FUNCNAME[0]}" ]] || [[ $DIFF == true ]]; } \
+ && [[ $GITHUB_LEAKS == true ]] && [[ $OSINT == true ]] \
+ && ! [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+
+ start_func "${FUNCNAME[0]}" "Running: GitHub-wide secret search with ghleaks"
+
+ if [[ -s $GITHUB_TOKENS ]]; then
+ GH_TOKEN=$(head -n 1 "$GITHUB_TOKENS")
+ local -a ghleaks_cmd=(
+ "${tools}/ghleaks/ghleaks"
+ -q "$domain"
+ --token "$GH_TOKEN"
+ --threads "${GHLEAKS_THREADS:-5}"
+ --report "${dir}/osint/github_leaks.json"
+ --no-banner
+ )
+ [[ $DEEP == true ]] && ghleaks_cmd+=(--exhaustive)
+
+ if ! run_command "${ghleaks_cmd[@]}" 2>>"$LOGFILE" >/dev/null; then
+ _print_error "ghleaks command failed"
+ fi
+ else
+ _print_error "Required file ${GITHUB_TOKENS} does not exist or is empty"
+ return 1
+ fi
+ end_func "Results are saved in $domain/osint/github_leaks.json" "${FUNCNAME[0]}"
+ else
+ if [[ $GITHUB_LEAKS == false ]] || [[ $OSINT == false ]]; then
+ skip_notification "disabled"
+ elif [[ $domain =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
+ return
+ else
+ skip_notification "processed"
+ fi
+ fi
+}
+
function metadata() {
ensure_dirs osint
diff --git a/reconftw.cfg b/reconftw.cfg
index 7301d57..7c3cd01 100644
--- a/reconftw.cfg
+++ b/reconftw.cfg
@@ -124,6 +124,8 @@ SPOOF=true # Check spoofable domains
METAFINDER_LIMIT=20 # Max 250
MAIL_HYGIENE=true # Check DMARC/SPF records
CLOUD_ENUM=true # Enumerate cloud storage across providers with cloud_enum
+GITHUB_LEAKS=true # Search for leaked secrets across all of GitHub with ghleaks
+GHLEAKS_THREADS=5 # Concurrent download threads for ghleaks
# Subdomains
SUBDOMAINS_GENERAL=true # Enable or disable the whole Subdomains module
diff --git a/tests/unit/test_new_tool_integrations.bats b/tests/unit/test_new_tool_integrations.bats
index 0a36e5f..a4c71f7 100644
--- a/tests/unit/test_new_tool_integrations.bats
+++ b/tests/unit/test_new_tool_integrations.bats
@@ -230,3 +230,86 @@ SH
[ -s "vulns/nuclei_dast.txt" ]
grep -q "mock-dast" "vulns/nuclei_dast.txt"
}
+
+@test "github_leaks searches GitHub-wide secrets with ghleaks" {
+ mkdir -p osint
+ export tools="$TEST_DIR/tools"
+ mkdir -p "$tools/ghleaks"
+
+ # Create mock ghleaks binary
+ cat > "$tools/ghleaks/ghleaks" <<'SH'
+#!/usr/bin/env bash
+report=""
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --report)
+ report="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+done
+if [[ -n "$report" ]]; then
+ printf '%s\n' '{"RuleID":"generic-api-key","Match":"AKIA1234567890ABCDEF","File":"config.yml","URL":"https://github.com/example/repo/blob/main/config.yml"}' > "$report"
+fi
+SH
+ chmod +x "$tools/ghleaks/ghleaks"
+
+ # Create GitHub tokens file
+ printf '%s\n' 'ghp_mock_token_12345' > "$TEST_DIR/.github_tokens"
+ export GITHUB_TOKENS="$TEST_DIR/.github_tokens"
+
+ export GITHUB_LEAKS=true
+ export OSINT=true
+ export DEEP=false
+ export GHLEAKS_THREADS=2
+
+ run github_leaks
+ [ "$status" -eq 0 ]
+ [ -s "osint/github_leaks.json" ]
+ grep -q "generic-api-key" "osint/github_leaks.json"
+}
+
+@test "github_leaks adds --exhaustive flag in DEEP mode" {
+ mkdir -p osint
+ export tools="$TEST_DIR/tools"
+ mkdir -p "$tools/ghleaks"
+
+ # Create mock ghleaks that records its arguments
+ cat > "$tools/ghleaks/ghleaks" <<'SH'
+#!/usr/bin/env bash
+printf '%s\n' "$@" > /tmp/ghleaks_args.txt
+report=""
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --report)
+ report="$2"
+ shift 2
+ ;;
+ *)
+ shift
+ ;;
+ esac
+done
+if [[ -n "$report" ]]; then
+ printf '%s\n' '{}' > "$report"
+fi
+SH
+ chmod +x "$tools/ghleaks/ghleaks"
+
+ printf '%s\n' 'ghp_mock_token_12345' > "$TEST_DIR/.github_tokens"
+ export GITHUB_TOKENS="$TEST_DIR/.github_tokens"
+
+ export GITHUB_LEAKS=true
+ export OSINT=true
+ export DEEP=true
+ export GHLEAKS_THREADS=2
+
+ run github_leaks
+ [ "$status" -eq 0 ]
+ grep -q "\-\-exhaustive" /tmp/ghleaks_args.txt
+ rm -f /tmp/ghleaks_args.txt
+}
+