-
Notifications
You must be signed in to change notification settings - Fork 29
/
search.sh
127 lines (117 loc) · 5.41 KB
/
search.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
#Author Github: https://github.com/g666gle
#Author Twitter: https://twitter.com/g666gle1
#Date: 1/29/2019
#Usage: N/A <Helper File for Query>
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
if [ "${PWD##*/}" == "BaseQuery" ];then
# Grab everything before the @ sign
user_name=$(echo "$1" | cut -d @ -f 1 | awk '{print tolower($0)}')
email=$(echo "$1" | cut -d : -f 1 | awk '{print tolower($0)}')
# Check to make sure the user name is at least 4 and the email has a @
if [ ${#user_name} -ge 4 ] && [[ $email == *"@"* ]];then
# Grab each individual character
first_char=${user_name:0:1} # {variable name: starting position : how many letters}
second_char=${user_name:1:1}
third_char=${user_name:2:1}
fourth_char=${user_name:3:1}
# Check the first directory
if [ -d ./data/"$first_char" ];then
# Check the second directory
if [ -d ./data/"$first_char"/"$second_char" ];then
# Check the third directory
if [ -d ./data/"$first_char"/"$second_char"/"$third_char" ];then
printf "${GREEN}Email Address: $email${NC}\n"
# Check to see if the file exists
if [ -e ./data/"$first_char"/"$second_char"/"$third_char"/"$fourth_char".txt ];then
# Open the file and search for the email address then only keep the passwords, iterate through the passwords and echo then
cat ./data/"$first_char"/"$second_char"/"$third_char"/"$fourth_char".txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
else
printf "${GREEN}Email Address: $email${NC}\n"
# The file does not exists
# Check to make sure the directory exists and the file exists for 0UTLIERS
if [[ -d ./data/$first_char/$second_char/$third_char/0UTLIERS && -e ./data/$first_char/$second_char/$third_char/0UTLIERS/0utliers.txt ]];then
cat ./data/"$first_char"/"$second_char"/"$third_char"/0UTLIERS/0utliers.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
fi
else
printf "${GREEN}Email Address: $email${NC}\n"
# The third letter directory does not exists
if [[ -d ./data/$first_char/$second_char/0UTLIERS && -e ./data/$first_char/$second_char/0UTLIERS/0utliers.txt ]];then
cat ./data/"$first_char"/"$second_char"/0UTLIERS/0utliers.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
fi
else
printf "${GREEN}Email Address: $email${NC}\n"
# The second letter directory does not exists
if [[ -d ./data/$first_char/0UTLIERS && -e ./data/$first_char/0UTLIERS/0utliers.txt ]];then
cat ./data/"$first_char"/0UTLIERS/0utliers.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
fi
else
printf "${GREEN}Email Address: $email${NC}\n"
# The first letter directory does not exists
if [[ -d ./data/0UTLIERS && -e ./data/0UTLIERS/0utliers.txt ]];then
cat ./data/0UTLIERS/0utliers.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
fi
else
printf "${GREEN}Email Address: $email${NC}\n"
if [[ $email == *"@"* ]];then
# The username is either not >= 4 or the email doesn't contain an @
# Check to see if the email is in the NOT VALID file
if [[ -d ./data/NOTVALID && -e ./data/NOTVALID/FAILED_TEST.txt ]];then
cat ./data/NOTVALID/FAILED_TEST.txt | grep -i "^$email" | cut -d : -f 2- | while read -r Password;do
printf "Password: ${RED}$Password${NC}\n"
done
fi
else
printf "${YELLOW}[!]${NC} Please enter one email address or a file with one email address per line\n"
fi
fi
else
printf "${RED}ERROR: Please change directories to the BaseQuery root directory${NC}\n"
fi