Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions Linux/pii.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
#!/bin/sh
!/bin/sh
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll wanna leave the # in

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you sir 🙏


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"
7 changes: 7 additions & 0 deletions Windows/PII.ps1
Original file line number Diff line number Diff line change
@@ -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