A Powershell script for discovering clear text credit cards on a Windows machine. The script has the following features:
- It searches all files recursively in the provided path in a memory efficient way
- Credit card numbers are validated using the Luhn algorithm to reduce false positives
- The script reads files upto 25mb in size to minimise its usage of system resources. Larger files are reported in the output for manual review.
- File formats tested and supported:
- Text files
- PDF documents (text is parsed using the awesome iTextSharp, no OCR is performed)
- Excel worksheets (requires Excel to be installed on the system)
- File formats expected to be supported in the future:
- Zipped archives
- Office documents
- Note: Warning is thrown when these documents are encountered
- Open a Powershell commandlet
- Clone the repository using
git clone https://github.com/jksdua/credit-card-finder
- Enter the directory using
cd credit-card-finder
- Ensure you have execution permissions by running
Get-ExecutionPolicy
. It should beUnrestricted
. See Execution Policy for more details. - Execute the script using
.\credit-card-finder.ps1 -path C:\path\to\dir
. Path can be relative or absolute.
Run the script with Administrator privileges for best results.
The script requires your user account to have execution permissions. This can be checked by running Get-ExecutionPolicy
.
If this value is not set to Unrestricted
, you will see an error similar to below:
Change this setting temporarily to Unrestricted
by running Set-ExecutionPolicy Unrestricted -Scope CurrentUser
. You will need administrative privileges on the machine to do this.
Once the script has finished, make sure to run Set-ExecutionPolicy <original value>
to reset it to its original state, otherwise you'll be lowering the security of your machine.
This script is currently in alpha stage.
- It uses
Write-Host
to output colored console output. Unfortunately, this breaks file output using redirection. This will be fixed in a future release.
- It would be great to port this to other platforms such as Linux and OSX.
- Added note on Windows execution policy
- Added support for relative directories (better usability)
- Made PDF and Excel dlls optional so the script does not fail if these cannot be loaded. Prints a warning if these cannot be found on the system.
- In this case, these files are marked for manual review.
- Removed recursive function making the library stable enough to be used on larger systems without much memory usage
- To stabilise the library, file size is now restricted to 25mb.
- Initial commit
- Basic support for common file types