-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_fb.sh
executable file
·78 lines (64 loc) · 1.44 KB
/
check_fb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
# Function to display usage
usage() {
echo "Usage: $0 [-h] [-i] <names_file> <leaked_files...>"
echo "Options:"
echo " -h Show this help message"
echo " -i Case insensitive search"
exit 1
}
# Parse arguments
CASE_SENSITIVE=true
while getopts "hi" opt; do
case $opt in
h)
usage
;;
i)
CASE_SENSITIVE=false
;;
\?)
usage
;;
esac
done
shift $((OPTIND-1))
# Check for required arguments
if [ $# -lt 2 ]; then
echo "Error: Missing required arguments"
usage
fi
namesfile=$1
shift
# Validate input file
if [ ! -f "$namesfile" ]; then
echo "Error: Names file '$namesfile' does not exist"
exit 1
fi
# Check if leaked files exist
for file in "$@"; do
if [ ! -f "$file" ]; then
echo "Error: Leaked file '$file' does not exist"
exit 1
fi
done
# Read names into array
mapfile -t names < "$namesfile"
if [ ${#names[@]} -eq 0 ]; then
echo "Error: Names file is empty"
exit 1
fi
echo "Checking ${#names[@]} entries against ${#@} file(s)..."
# Set grep options based on case sensitivity
GREP_OPTS="--color=always"
if [ "$CASE_SENSITIVE" = false ]; then
GREP_OPTS="$GREP_OPTS -i"
fi
# Process each name
for name in "${names[@]}"; do
if [ -n "$name" ]; then
echo "Checking: $name"
cat "$@" | grep $GREP_OPTS "$name" || echo "No matches found"
fi
done
exit 0