开发者

CC and SSN File Search on Network Drives

I am working on a project where we need to search a set of our network drives to examine each file and look for credit card numbers and social security numbers. I have been trying to use the Cornell Spider program without success sin开发者_开发技巧ce it seems to crash every time I use it.

I would like to know if there is a way to use Powershell, or a scripting language available on Windows, to perform an analysis (I am assuming a strings match) that would match the patterns for credit card numbers and social security numbers (probably a regex). If there is a way, and since I am not a programmer, I was curious if there was some code that I could use to do this with. Also, the ability to save/dump the results of what is found out to a file (text or CSV) would be very helpful as well.

Any ideas or help that you can provide would be greatly appreciated.

=======================================================

Okay, I have been working on a test script and have come up with the following:

$spath = "C:\Users\name\Desktop\"
$opath = "C:\Users\name\Desktop\Results.txt"

$Old_SSN_Regex = "[0-9]{3}[-| ][0-9]{2}[-| ][0-9]{4}"
$SSN_Regex = "^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$"
$CC_Regex = "^((?:4\d{3})|(?:5[1-5]\d{2})|(?:6011)|(?:3[68]\d{2})|(?:30[012345]\d))[ -]?(\d{4})[ -]?(\d{4})[ -]?(\d{4}|3[4,7]\d{13})$"
$CC_2_Regex = "^(\d{4}-){3}\d{4}$|^(\d{4} ){3}\d{4}$|^\d{16}$"

Get-ChildItem $spath -Include *.txt -Recurse | Select-String -Pattern $SSN_Regex | Select-Object Path,Filename,Matches | Out-File $opath
Get-ChildItem $spath -Include *.txt -Recurse | Select-String -Pattern $CC_Regex | Select-Object Path,Filename,Matches | Out-File $opath -Append
Get-ChildItem $spath -Include *.txt -Recurse | Select-String -Pattern $CC_2_Regex | Select-Object Path,Filename,Matches | Out-File $opath -Append

This seems to be working well, the problem is that if there is a space before or after the item to be matched, the regexs listed do not catch it. Is there something that I can do differently so that it will catch the item if it has a space before or after the pattern to be matched within a file?


See this PowerGUI.org thread for the solution: PowerShell Script to locate Social Security Numbers (SSN) and Credit Card numbers in files across the network.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜