diff --git a/Linux/pii.sh b/Linux/pii.sh index b8aba87..4eaf46c 100644 --- a/Linux/pii.sh +++ b/Linux/pii.sh @@ -1,11 +1,22 @@ -#!/bin/sh +!/bin/sh rootdir="/home/" - ssn_pattern='[0-9]\{3\}-[0-9]\{2\}-[0-9]\{4\}' - -find "$rootdir" -type f \( -name "*.txt" -o -name "*.csv" \) -exec sh -c ' +# Search for SSNs in various file types +find "$rootdir" -type f \( -name "*.jpg" -o -name "*.txt" -o -name "*.csv" -o -name "*.xlsx" -o -name "*.pdf" -o -name "*.docx" \) -exec sh -c ' file="$1" - grep -Hn "$2" "$file" | while read -r line; do echo "$file:SSN:$line"; done + if [ "${file##*.}" = "jpg" ]; then + echo "$file is a JPG file. Skipping SSN search for image files." + else + grep -Hn "$2" "$file" | while read -r line; do echo "$file:SSN:$line"; done + fi ' sh '{}' "$ssn_pattern" \; + +# Summarize +echo "Summary:" +total_files=$(find "$rootdir" -type f \( -name "*.jpg" -o -name "*.txt" -o -name "*.csv" -o -name "*.xlsx" -o -name "*.pdf" -o -name "*.docx" \) | wc -l) +total_ssns=$(grep -r -E "$ssn_pattern" "$rootdir" | grep -v '\.jpg$' | wc -l) + +echo "Total SSNs found: $total_ssns" +echo "Total files searched: $total_files" diff --git a/Windows/PII.ps1 b/Windows/PII.ps1 new file mode 100644 index 0000000..b53c710 --- /dev/null +++ b/Windows/PII.ps1 @@ -0,0 +1,7 @@ +#BECAUSE DEFAULT SETTINGS RESTRICT PS1 EXECUTION COPY PASTE LINES INTO POWERSHELL + +#specifies PII file extensions to search for +$extensions = @('*.jpg', '*.txt', '*.csv', '*.xlsx', '*.pdf', '*.docx') + +#edit -Path parameter to search the directory and subdirectories make sure directory is reachable from current directory +Get-ChildItem -Path "Desktop" -Include $extensions -File -Recurse | Select-Object FullName \ No newline at end of file