-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathadmin-finder.sh
executable file
·165 lines (144 loc) · 4.15 KB
/
admin-finder.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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/usr/bin/env bash
#
# admin-finder: A script used to find the admin login page of a website.
# https://github.com/wannabewastaken/admin-finder
version=1.1
# Speed up script by not using unicode
LC_ALL=C
LANG=C
# Color definition
: "${aqua:=\e[38;5;023m}"
: "${red:=\e[38;5;160m}"
: "${reset:=\e[m}"
# Checking dependecies
command -v curl &> /dev/null || { printf "%b\n" \
"${red}curl ${reset}not installed."; exit 1; }
command -v cut &> /dev/null || { printf "%b\n" \
"${red}cut ${reset}not installed."; exit 1; }
# Trap (ctrl + c)
# \e[K Erase from cursor position to end of line.
# \r is a carriage return which often means that the cursor should move to the leftmost column.
trap "printf '\e[K\r[$(date +%H:%M:%S)] ctrl+c detected, exit\n\n'; exit" INT
banner() { printf "%b" "\
${aqua}▄▀█ ${reset}admin-finder
${aqua}█▀█ ${reset}version (${aqua}v${version}${reset})\n\n"
}
usage() { printf "%s" "\
Usage:
$0 [option] [value]
Options:
-h, --help Show this help message and exit
-u, --url <url> Target url (e.g. 'www.example.com' or 'example.com')
-t, --thread <thread> Set thread number (default: 100)
-w, --wordlist <file> Use custom wordlist
"
exit 1
}
scan_protocol() {
if [[ $(curl -s "https://${1}" \
-w "%{http_code}" \
-o /dev/null) =~ 200 ]]; then
protocol="https://"
else
if [[ $(curl -s "http://${1}" \
-w "%{http_code}" \
-o /dev/null) =~ 200 ]]; then
protocol="http://"
else
printf "%b\n" \
"[$(date +%H:%M:%S)] Connection failed, aborted"
printf "%b\n\n" \
"[$(date +%H:%M:%S)] Please check your internet connection or maybe website is down"
exit 1
fi
fi
}
scan_robots() {
for robotPath in "robot.txt" "robots.txt"; do
if [[ $(curl -s "${1}${2}/${robotPath}" \
-w "%{http_code}" \
--connect-timeout 1 \
-o /dev/null) =~ 200 ]]; then
printf "%s\n" \
" |-- robots.txt -> ${1}${2}/${robotPath}"
isFound=true
break
fi
done
[[ ${isFound} ]] && return || {
printf "%s\n" \
" |-- robots.txt -> not found"
}
}
scan_path() {
if [[ $(curl -s "${1}${2}/${3}" -w "%{http_code}" -o /dev/null) -eq 200 ]]; then
printf "%b" \
"\e[K |-- (200) -> ${1}${2}/${3}\n"
else
printf "%b" \
"\e[K |-- (${aqua}#${reset}) -> ${1}${2}/${3}${reset}\r"
fi
}
main() {
if [[ -z $@ ]]; then
usage
fi
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help)
usage
shift
;;
-u|--url)
url="$2"
shift
;;
-t|--thread)
thread="$2"
shift
;;
-w|--wordlist)
wordlist="$2"
shift
;;
*)
printf "%s\n%s\n" "admin-finder: unrecognize option '$1'" \
"See the output of $0 -h for summary options."
exit 1
;;
esac
shift
done
if [[ "$url" =~ [^http[s]?:\/\/].* ]]; then
url=$(printf ${BASH_REMATCH} | cut -d "/" -f 3)
fi
if [[ -z "$thread" ]]; then
thread=100
fi
if [[ -z "$wordlist" ]]; then
wordlist="./wordlist.txt"
fi
clear
banner
printf "%s\n" \
"[$(date +%H:%M:%S)] Starting connection to ${url}"
scan_protocol ${url}
printf "%s\n" \
"[$(date +%H:%M:%S)] Connection successful"
printf "%s\n" \
"[$(date +%H:%M:%S)] Using protocol (${protocol})"
printf "%s\n" \
"[$(date +%H:%M:%S)] Scanning..."
scan_robots ${protocol} ${url}
while read -r path; do
((x=x%${thread})); ((x++==0)) && wait
scan_path ${protocol} ${url} ${path} &
done < <(grep "" ${wordlist})
wait
printf "%b\n" \
"\e[K[$(date +%H:%M:%S)] Disconnect from ${url}"
printf "%s\n\n" \
"[$(date +%H:%M:%S)] Scanning done, exit"
}
main "$@"
wait