-
Notifications
You must be signed in to change notification settings - Fork 5
/
goback.sh
65 lines (55 loc) · 1.4 KB
/
goback.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
#!/bin/bash
keybackdoor="lib/keybackdoor.txt"
folder="/"
output="output/$(date +%Y-%m-%d)/possiblebackdoor.txt"
# Parse command-line arguments
while [[ $# -gt 1 ]]; do
key="$1"
case $key in
-kb|--keybackdoor)
keybackdoor="$2"
shift
;;
-fo|--folder)
folder="$2"
shift
;;
-o|--output)
output="$2"
shift
;;
*)
;;
esac
shift
done
# Set default key backdoor file if not provided
if [ -z "$keybackdoor" ]; then
keybackdoor="lib/keybackdoor.txt"
fi
# Set default folder if not provided
if [ -z "$folder" ]; then
folder="/"
fi
# Set default output file if not provided
if [ -z "$output" ]; then
output="output/$(date +%Y-%m-%d)/possiblebackdoor.txt"
fi
# Check if key backdoor file exists
if [ ! -f "$keybackdoor" ]; then
echo "Key backdoor file not found: $keybackdoor"
exit 1
fi
# Check if folder exists
if [ ! -d "$folder" ]; then
echo "Folder not found: $folder"
exit 1
fi
# Create output directory if it doesn't exist
mkdir -p "$(dirname "$output")"
# Perform the search for backdoors
while IFS= read -r backdoor; do
grep -rlI "$backdoor" "$folder" | while IFS= read -r file; do
echo "Found backdoor/malicious file: $file ($(stat -c '%y' "$file"))"
done
done < "$keybackdoor" >> "$output"