-
-
Notifications
You must be signed in to change notification settings - Fork 57
/
search.sh
executable file
·96 lines (84 loc) · 2.09 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
#!/bin/bash
BOLD="\e[1m"
NORMAL="\e[0m"
GREEN="\e[32m"
RED="\e[30m"
HELP="
${BOLD}[+]USAGE:${NORMAL} ./search.sh (OPTIONS)
-j (string) - search in javascript files
-x (string) - search in header files
-e (string) - search in html files
-n (string) - search nmap scans
-h - help
"
#writing code to check for expressions in html
searchhtml() {
local WORD="${1}"
for domain in $(ls responsebody)
do
RES=$(cat responsebody/$domain | grep -n --color=always "${WORD}")
if [ $(echo $RES | wc -c) -gt 1 ]
then
echo -e "\n${BOLD}${GREEN}${domain}${NORMAL}"
echo -e $RES
fi
done
}
searchheader() {
local WORD="${1}"
for domain in $(ls headers)
do
RES=$(cat headers/$domain | grep -n --color=always "${WORD}")
if [ $(echo $RES | wc -c) -gt 1 ]
then
echo -e "\n${BOLD}${GREEN}${domain}${NORMAL}"
echo $RES
fi
done
}
searchjs() {
local WORD="${1}"
for domain in $(ls scriptsresponse)
do
for file in $(ls scriptsresponse/$domain)
do
echo -e "\n${BOLD}${GREEN}${domain}/${file}${NORMAL}"
RES=$(grep --color=always -n "${WORD}" scriptsresponse/$domain/$file)
if [ $(echo $RES | wc -c) -gt 1 ]
then
echo -e "\n${BOLD}${GREEN}${domain}${NORMAL}"
echo -e $RES
fi
done
done
}
searchnmap() {
local WORD="${1}"
for domain in $(ls nmapscans)
do
echo -e "\n${BOLD}${GREEN}${domain}${NORMAL}"
RES=$(cat nmapscans/$domain | grep -n --color=always "${WORD}")
if [ $(echo $RES | wc -c) -le 1 ]
then
echo -e "\n${BOLD}${GREEN}${domain}${NORMAL}"
echo -e $RES
fi
done
}
while getopts j:x:e:n:h OPTIONS
do
case "${OPTIONS}" in
j) searchjs "${OPTARG}" ;;
e) searchhtml "${OPTARG}" ;;
x) searchheader "${OPTARG}" ;;
n) searchnmap "${OPTARG}" ;;
h)
echo -e "${HELP}"
;;
*)
echo "[+] Select a valid option.\n"
echo -e "${HELP}"
exit 1
;;
esac
done