Get-keys.bat ⭐ 📢

REM findstr in Windows supports limited regex; some syntax above may not be portable. REM We'll use simpler multiple findstr searches per pattern below.

:: -------------------------- :: Defaults and arguments :: -------------------------- set "ROOT=%~1" if "%ROOT%"=="" set "ROOT=%CD%"

setlocal ENABLEDELAYEDEXPANSION

:: -------------------------- :: Patterns to look for :: As batch lacks regex, we use findstr with /r and some heuristics :: -------------------------- REM Common patterns (simplified): REM - AWS Access Key ID: AKIA followed by 16 alphanumerics REM - AWS Secret Access Key: 40 base64-like chars (heuristic) REM - Google API key: "AIza" followed by 35 chars REM - JWT-like: three base64url segments separated by dots, present in a line REM - UUIDs: 8-4-4-4-12 hex pattern REM - Generic tokens: long alphanumeric strings >= 20 chars REM - Private key headers: -----BEGIN PRIVATE KEY-----

popd

:: Convert extensions list into a findstr include filter set "EXT_FILTER=" for %%E in (%EXTS:,= %) do ( if defined EXT_FILTER (set "EXT_FILTER=!EXT_FILTER! *.%%E") else set "EXT_FILTER=*.%%E" )

:: Write CSV header set "CSV_HDR=File,LineNumber,Context,MatchType,MatchValue" if "%DRY%"=="0" ( echo %CSV_HDR%> "%OUTFILE%" ) get-keys.bat

echo Scanning root: %ROOT% echo Extensions: %EXTS% echo Excludes: %EXCLUDE% if "%MASK%"=="1" echo Masking enabled if "%DRY%"=="1" echo Dry-run (no report written)

Scroll to Top