Get-keys.bat !exclusive! File
get-keys.bat — Comprehensive Script and Explanation
Below is a thorough, extensible Windows batch script named get-keys.bat that demonstrates techniques for securely locating, extracting, and optionally reporting key-like strings (API keys, tokens, secrets) from files on a Windows system. This is intended for legitimate use only — e.g., inventorying your own codebase or configuration files before publishing, or locating secrets accidentally stored in local files so you can rotate them. Do not use this script to access or exfiltrate secrets you are not authorized to access.
Features
- Recursively searches directories for files containing likely secrets.
- Supports configurable file extensions and filename exclusions.
- Uses regular-expression-ish patterns to find typical API key formats (AWS, Google, generic tokens, JWTs, UUIDs, private-key headers).
- Outputs results to console and to a timestamped CSV report.
- Optionally masks or redacts found secrets in the report.
- Includes safety checks and a dry-run mode.
Notes and warnings
- Batch scripting has limited regex; the script uses pattern heuristics and simple string matching. For more robust matching, use PowerShell, Python, or security-specific scanning tools.
- Running this script against systems you don’t own or without permission may be illegal. Use only on systems and data you are authorized to scan.
- The script may produce false positives; treat findings as candidates for manual review.
get-keys.bat (Windows Batch)
@echo off
REM get-keys.bat
REM Recursively search for likely keys/tokens in files and generate a CSV report.
REM Usage:
REM get-keys.bat [root_path] [--extensions=ext1,ext2,...] [--exclude=pattern1;pattern2] [--mask] [--dry-run]
REM Defaults:
REM root_path = current directory
REM extensions = txt,env,conf,config,json,js,py,java,xml,ini,yml,yaml,md,log
REM exclude = .git;.venv;node_modules;venv
REM mask = redact found values in report
REM dry-run = do not write report (only console output)
setlocal ENABLEDELAYEDEXPANSION
:: --------------------------
:: Defaults and arguments
:: --------------------------
set "ROOT=%~1"
if "%ROOT%"=="" set "ROOT=%CD%"
:: parse other args
set "EXTS=txt,env,conf,config,json,js,py,java,xml,ini,yml,yaml,md,log"
set "EXCLUDE=.git;.venv;node_modules;venv"
set "MASK=0"
set "DRY=0"
for %%A in (%*) do (
set "ARG=%%~A"
rem --extensions=
echo "!ARG!" | findstr /i /b "--extensions=" >nul
if !errorlevel! equ 0 (
for /f "tokens=1* delims==" %%K in ("!ARG!") do set "EXTS=%%L"
)
echo "!ARG!" | findstr /i /b "--exclude=" >nul
if !errorlevel! equ 0 (
for /f "tokens=1* delims==" %%K in ("!ARG!") do set "EXCLUDE=%%L"
)
if /i "!ARG!"=="--mask" set "MASK=1"
if /i "!ARG!"=="--dry-run" set "DRY=1"
)
:: Normalize paths and build exclude list for findstr
set "EXCLUDE_FILTER="
for %%E in (%EXCLUDE:;= %) do (
if defined EXCLUDE_FILTER (set "EXCLUDE_FILTER=!EXCLUDE_FILTER!|%%E") else set "EXCLUDE_FILTER=%%E"
)
:: 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"
)
:: Timestamp for report
for /f "tokens=1-6 delims=/:. " %%a in ("%date% %time%") do (
set "DT=%%a-%%b-%%c_%%d-%%e-%%f"
)
if "%DT%"=="" (
REM fallback
set "DT=%DATE%_%TIME%"
set "DT=%DT::=-%"
set "DT=%DT:/=-%"
set "DT=%DT: =_%"
set "DT=%DT:.=-%"
)
set "OUTFILE=%CD%\get-keys_report_%DT%.csv"
:: Write CSV header
set "CSV_HDR=File,LineNumber,Context,MatchType,MatchValue"
if "%DRY%"=="0" (
echo %CSV_HDR%> "%OUTFILE%"
)
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)
:: --------------------------
:: Helper: mask value (simple)
:: --------------------------
:mask_value
REM Input: %1 value, Output: masked in MASKED_VALUE variable
setlocal ENABLEDELAYEDEXPANSION
set "VAL=%~1"
if "%MASK%"=="1" (
set "LEN=0"
for /l %%i in (0,1,200) do (
if "!VAL:~%%i,1!"=="" goto :gotlen
)
:gotlen
set /a KEEP=4
set /a LBOUND=KEEP
if %LEN% LSS %KEEP% set "KEEP=1"
REM show first KEEP chars and mask the rest with *
set "PREFIX=!VAL:~0,%KEEP%!"
set "MASKED_SUFFIX="
for /l %%i in (1,1,60) do set "MASKED_SUFFIX=!MASKED_SUFFIX!*"
set "MASKED_VALUE=!PREFIX!!MASKED_SUFFIX!"
) else (
set "MASKED_VALUE=%VAL%"
)
endlocal & set "MASKED_VALUE=%MASKED_VALUE%"
goto :eof
:: --------------------------
:: 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-----
set "FINDSTR_PATTERNS="
set "FINDSTR_PATTERNS=!FINDSTR_PATTERNS!AKIA[0-9A-Z]\16\|"
set "FINDSTR_PATTERNS=!FINDSTR_PATTERNS!AIza[0-9A-Za-z-_]\35\|"
set "FINDSTR_PATTERNS=!FINDSTR_PATTERNS![0-9A-Fa-f]\8-[0-9A-Fa-f]\4-[0-9A-Fa-f]\4-[0-9A-Fa-f]\4-[0-9A-Fa-f]\12\|"
set "FINDSTR_PATTERNS=!FINDSTR_PATTERNS![A-Za-z0-9\-_]\20,\|"
set "FINDSTR_PATTERNS=!FINDSTR_PATTERNS!-----BEGIN PRIVATE KEY-----"
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.
:: --------------------------
:: Main scan loop
:: --------------------------
pushd "%ROOT%" 2>nul || (echo Cannot access %ROOT% & exit /b 1)
REM build file list using for /R and extension filtering, skipping excludes
for /R "%ROOT%" %%F in (%EXT_FILTER%) do (
set "FILE=%%~fF"
REM check exclude patterns
set "SKIP=0"
for %%X in (%EXCLUDE:;= %) do (
echo "!FILE!" | findstr /i /c:"\\%%X\\" >nul
if !errorlevel! equ 0 set "SKIP=1"
)
if "!SKIP!"=="1" (
REM skip
) else (
REM Read file line by line
set "LN=0"
for /f "usebackq delims=" %%L in ("%%~fF") do (
set /a LN+=1
set "LINE=%%L"
setlocal ENABLEDELAYEDEXPANSION
set "L=!LINE!"
endlocal & set "L=%L%"
REM Quick presence checks for patterns to avoid expensive checks on every line
echo "%L%" | findstr /i "AKIA AIza -----BEGIN PRIVATE KEY-----" >nul
set "P1=%errorlevel%"
echo "%L%" | findstr /r /c:"[A-Fa-f0-9]\8\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\12\" >nul
set "P2=%errorlevel%"
REM Generic long token heuristic: sequences of 20+ alnum or -_ characters
echo "%L%" | findstr /r /c:"[A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-]" >nul
set "P3=%errorlevel%"
if "%P1%"=="0" (set "MATCHFOUND=1") else if "%P2%"=="0" (set "MATCHFOUND=1") else if "%P3%"=="0" (set "MATCHFOUND=1") else set "MATCHFOUND=0"
if "%MATCHFOUND%"=="1" (
REM Determine match types - simple checks
set "MT=Unknown"
echo "%L%" | findstr /i "AKIA" >nul
if %errorlevel% equ 0 set "MT=AWS_Access_Key"
echo "%L%" | findstr /i "AIza" >nul
if %errorlevel% equ 0 set "MT=Google_API_Key"
echo "%L%" | findstr /i "-----BEGIN PRIVATE KEY-----" >nul
if %errorlevel% equ 0 set "MT=Private_Key"
echo "%L%" | findstr /r /c:"[A-Fa-f0-9]\8\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\4\-[A-Fa-f0-9]\12\" >nul
if %errorlevel% equ 0 set "MT=UUID"
if "%MT%"=="Unknown" (
set "MT=Generic_Token"
)
REM Extract a candidate token (best-effort): we will pick the longest contiguous alnum/_/- sequence
for /f "tokens=1-*" %%A in ('echo "%L%" ^| findstr /o /r "[A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-][A-Za-z0-9_-]"') do (
REM findstr /o prints the position of match; we can't easily extract substring in pure batch reliably for arbitrary position, so fallback to output the whole line as context and label the match type
set "MATCHVAL=%L%"
)
call :mask_value "%MATCHVAL%"
set "OUTVAL=%MASKED_VALUE%"
REM Quote fields for CSV, replace quotes inside fields
set "QFILE=%%~fF"
set "QLINE=%LN%"
set "QCTX=%L%"
REM escape double quotes by doubling them
set "QFILE=%QFILE:"=""%"
set "QCTX=%QCTX:"=""%"
if "%DRY%"=="0" (
>>"%OUTFILE%" echo "%QFILE%","%QLINE%","%QCTX%","%MT%","%OUTVAL%"
)
echo Found [%MT%] in %%~fF:%LN% -> %OUTVAL%
)
)
)
)
popd
if "%DRY%"=="0" (
echo Report written to %OUTFILE%
) else (
echo Dry-run complete: no report written.
)
endlocal
Explanation and how to use
- Save the script as get-keys.bat.
- Run from an Administrator or normal shell: get-keys.bat C:\path\to\repo --extensions=py,js,env --exclude=.git;node_modules --mask
- This scans C:\path\to\repo for files with the listed extensions, skipping excluded directories, masks secrets in the CSV, and writes a report file.
- Use --dry-run to suppress file output and only print findings to the console.
Limitations and recommended improvements
- Pattern matching is approximate. For accurate regex and robust parsing, use PowerShell or Python (recommendation: use ripgrep + custom regex, or GitLeaks, trufflehog, or detect-secrets).
- This batch script treats an entire matching line as the candidate value; it does not reliably extract the precise substring at arbitrary positions. Converting to PowerShell would allow rich regex capture groups.
- Consider adding:
- Option to automatically redact in-place files or replace secrets with placeholders (use carefully).
- Exclusion by file size or binary detection.
- Multithreaded scanning (not available in batch).
- Integration with secret rotation APIs when secrets are found.
Short PowerShell alternative (recommended for production use)
- Use a PowerShell one-liner or script with proper regex capture groups and CSV export, e.g.:
- Search with Get-ChildItem -Recurse -Include .py,.js | Select-String -Pattern 'AKIA[0-9A-Z]16|AIza[0-9A-Za-z-]35|-----BEGIN PRIVATE KEY-----|[A-Fa-f0-9]8-...|[A-Za-z0-9-]20,' | Export-Csv report.csv -NoTypeInformation
If you want, I can:
- Provide a PowerShell version that uses precise regex and extracts matched substrings.
- Add automatic Gitignore parsing to avoid scanning excluded paths.
- Create a safer redaction/in-place replacement mode (with backups).
Which of those would you like next?
Feature: get-keys.bat
What the Script Does
| Command | Purpose |
|---------|---------|
| wmic path softwarelicensingproduct | Tries to read the OEM Windows key from BIOS |
| powershell ... OA3xOriginalProductKey | Alternative method for newer Windows versions |
| cscript + VBS | Decodes the registry’s encrypted product key |
| reg query ... Office | Finds Office registration entries |
Unlocking the Secrets of get-keys.bat: A Comprehensive Guide to Windows Product Key Recovery
In the vast ecosystem of Windows system administration, few files are as unassuming yet as powerful as a simple batch script. Among the most legendary of these is get-keys.bat. For IT professionals, seasoned tech enthusiasts, and even casual users who have faced the dreaded "Windows Activation" watermark, this tiny text file represents a lifeline.
But what exactly is get-keys.bat? Is it a native Windows tool? A virus? A magic spell written in 1980s syntax?
This article provides a definitive deep dive into get-keys.bat. We will explore what it does, how to create it safely, where to find legitimate versions, and why it remains one of the most effective tools for recovering lost Windows product keys from the BIOS (UEFI) or Registry.
2. Typical Functionality
While the specific code varies, these scripts generally follow a "living off the land" philosophy, using built-in Windows tools to find data.
Deliverables
- get-keys.bat (batch + PowerShell calls) — basic scanning and display.
- get-keys.ps1 — improved PowerShell implementation with decoding and export options.
- README with usage, security notes, and examples.
Final Tip
Never download random get-keys.bat files from the internet — they could contain malware. Always inspect or write your own script, or use trusted portable tools.
Would you like a version of get-keys.bat that only outputs the Windows key (without VBS or Office scanning)? get-keys.bat
Depending on the context, a batch file with this name usually performs one of the following tasks:
Registry Key Retrieval: Scripts used to query the Windows Registry to confirm software installation or retrieve license information.
Authentication & API Management: In cloud or API-heavy environments, a get-keys.bat might be used to fetch temporary credentials or keys from services like Azure Key Vault or AWS to authenticate local development tools.
Decryption for Emulation: Users of console emulators often use scripts to manage "prod.keys" or title keys required for software decryption.
Input Simulation: Less commonly, "get keys" refers to scripts that capture or simulate keystrokes, though standard .bat files usually require helper scripts (like VBScript) to send complex key commands. Sample Technical Structure
A typical script of this nature might use the REG QUERY command to find specific data:
@echo off :: Example of retrieving a specific registry value set "target_key=HKEY_LOCAL_MACHINE\SOFTWARE\ExampleApp" reg query "%target_key%" /v "LicenseKey" pause Use code with caution. Copied to clipboard Important Considerations
Security Risk: Be cautious when running .bat files from untrusted sources, as they can be used to export sensitive credentials or modify system settings.
Administrative Privileges: Many scripts that "get keys" from the registry or system folders require "Run as Administrator" to function correctly.
Alternative Methods: For modern IT tasks, PowerShell is often preferred over batch scripts due to its superior ability to handle JSON, XML, and secure API requests.
The Ultimate Guide to Get-Keys.bat: Unlocking the Power of Windows Product Keys
Are you tired of dealing with Windows activation issues? Do you struggle to find the product key for your Windows installation? Look no further! In this comprehensive article, we'll explore the world of get-keys.bat, a powerful script that can help you recover your Windows product key and resolve activation issues.
What is Get-Keys.bat?
get-keys.bat is a simple yet powerful batch script that retrieves the product key from a Windows installation. The script uses a combination of Windows API calls and registry queries to extract the product key, which is then displayed on the screen or saved to a file. The script is designed to work on Windows 7, 8, 8.1, and 10 installations, making it a versatile tool for users and administrators alike.
How Does Get-Keys.bat Work?
The get-keys.bat script uses a combination of Windows API calls and registry queries to extract the product key. Here's a step-by-step breakdown of the process:
- Registry Query: The script queries the Windows registry to retrieve the product key. The product key is stored in the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\SoftwareProtectionPlatform. - API Call: The script uses the Windows API to retrieve the product key. Specifically, it uses the
WMI(Windows Management Instrumentation) API to query theSoftwareLicensingServiceclass. - Decryption: The script decrypts the product key using a proprietary algorithm. This ensures that the product key is displayed in a readable format.
Benefits of Using Get-Keys.bat
Using get-keys.bat offers several benefits, including:
- Easy Product Key Recovery: With
get-keys.bat, you can easily recover your Windows product key, eliminating the need to search for it on your installation media or in your email inbox. - Activation Troubleshooting: The script can help you troubleshoot Windows activation issues by providing the product key and other relevant information.
- Convenience: The script is easy to use and requires no technical expertise. Simply download the script, run it, and retrieve your product key.
Common Use Cases for Get-Keys.bat
Here are some common use cases for get-keys.bat:
- Reinstalling Windows: When reinstalling Windows, you may need to enter your product key to activate your installation.
get-keys.batmakes it easy to retrieve your product key and complete the activation process. - Upgrading to a New Version: When upgrading to a new version of Windows, you may need to enter your product key to activate your installation.
get-keys.batcan help you retrieve your product key and complete the activation process. - Troubleshooting Activation Issues: If you're experiencing activation issues,
get-keys.batcan help you troubleshoot the problem by providing the product key and other relevant information.
How to Use Get-Keys.bat
Using get-keys.bat is easy. Here's a step-by-step guide:
- Download the Script: Download the
get-keys.batscript from a reputable source. Make sure to scan the script for viruses or malware before running it. - Run the Script: Run the script by double-clicking on the
get-keys.batfile. - Retrieve Your Product Key: The script will display your product key on the screen. You can also save the product key to a file by modifying the script.
Tips and Tricks
Here are some tips and tricks for using get-keys.bat:
- Run as Administrator: To ensure that the script works correctly, run it as an administrator.
- Save to a File: Consider saving the product key to a file, especially if you're using a new computer or reinstalling Windows.
- Use with Other Tools: You can use
get-keys.batwith other tools, such asslmgr.vbs, to manage your Windows installation and troubleshoot activation issues.
Conclusion
In conclusion, get-keys.bat is a powerful script that can help you retrieve your Windows product key and resolve activation issues. With its ease of use and versatility, get-keys.bat is a valuable tool for users and administrators alike. Whether you're reinstalling Windows, upgrading to a new version, or troubleshooting activation issues, get-keys.bat is a must-have tool in your toolkit.
Frequently Asked Questions
Here are some frequently asked questions about get-keys.bat:
- Q: Is get-keys.bat safe to use?
A: Yes,
get-keys.batis safe to use. However, make sure to download the script from a reputable source and scan it for viruses or malware before running it. - Q: Can I use get-keys.bat on any version of Windows?
A: Yes,
get-keys.batworks on Windows 7, 8, 8.1, and 10 installations. - Q: Can I use get-keys.bat to retrieve my product key if I've lost it?
A: Yes,
get-keys.batcan help you retrieve your product key even if you've lost it. However, make sure to have access to your Windows installation and administrative privileges.
By following this guide, you'll be able to unlock the power of get-keys.bat and manage your Windows product key with ease.
There are a few different ways a file named get-keys.bat is used, though it's most commonly associated with emulation and system automation. 1. PS3 Emulation (RPCS3/PS3Dec) get-keys
In the world of PlayStation 3 emulation, a get-keys.bat (or similarly named script) is often used to automate the decryption of ISO files.
Purpose: It usually triggers ps3dec.exe to take a game’s unique encryption key and "unlock" the ISO so the emulator can read it.
How it works: The script typically contains commands to set paths for the emulator, the decryption tool, and the destination for the decrypted file.
Why use it: Users often set this up within front-ends like LaunchBox to automatically decrypt a game when they click "Play" and delete the temporary files after they quit. 2. Automation & Scripting
If you're looking at a more general script, it likely uses PowerShell or WScript to retrieve or "send" keys:
Keystroke Simulation: Batch files can be used to simulate physical key presses (like ENTER or CTRL+ESC) using SendKeys via a small PowerShell one-liner or VBScript.
Registry/License Retrieval: Some scripts named "get-keys" are designed to pull Windows product keys or other software license keys from the system registry for backup purposes. ⚠️ Security Warning
Because .bat files can execute system-level commands, they are frequently used in malware chains.
Suspicious Behavior: Malicious batch scripts often masquerade as helpful tools (like a "key getter") but actually run hidden PowerShell commands to download "Remote Access Trojans" (RATs) or modify registry keys for persistence.
Best Practice: If you didn't create the script yourself or get it from a highly trusted source (like an official GitHub repo for a tool), do not run it. You can right-click the file and select Edit to view the code in Notepad and see exactly what it’s doing before execution.
Are you trying to create one of these scripts for a specific program, or did you find one on your system that you're curious about?
Mitigating the Axios npm supply chain compromise - Microsoft
Since you did not provide the specific source code or a link to the specific get-keys.bat script you are referring to, I have conducted an analysis based on the most common and widely used iteration of this script found in system administration and security auditing repositories (typically used for retrieving Windows product keys).
Here is an informative review of the standard get-keys.bat utility.