-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathflinks.sh
223 lines (212 loc) · 11.3 KB
/
flinks.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
#!/bin/bash
# Define color codes
GREEN='\033[0;32m'
RESET='\033[0m' # Reset color
# Function to display script usage
display_usage() {
echo "Usage: $0 [-k Katana] [-g GAU] [-w Waybackurls] [-s Passive GoSpider] [-r Robifinder] [-u URL] [-l FILE] [-a All] [-o OUTPUT_FILE]"
echo " -u URL: Specify a single URL"
echo " -l FILE: Specify a file containing URLs"
echo " -k: Run katana"
echo " -g: Run gau"
echo " -w: Run waybackurls"
echo " -s: Run passive gospider"
echo " -r: Run robofiner"
echo " -a: Run all"
echo " -o OUTPUT_FILE: Specify an output file to save the results"
echo " Note: Either -u or -l must be provided"
}
# Variables
run_katana=false
run_gau=false
run_waybackurls=false
run_passive_gospider=false
run_robofinder=false
url=""
file=""
output_file=""
# Parse command line arguments
while getopts ":akgwsru:l:o:" option; do
case "${option}" in
a)
run_katana=true
run_gau=true
run_waybackurls=true
run_passive_gospider=true
run_robofinder=true
;;
k)
run_katana=true
;;
g)
run_gau=true
;;
w)
run_waybackurls=true
;;
s)
run_passive_gospider=true
;;
r)
run_robofinder=true
;;
u)
url="${OPTARG}"
;;
l)
file="${OPTARG}"
;;
o)
output_file="${OPTARG}"
;;
*)
display_usage
exit 1
;;
esac
done
# Check if either URL or file is provided
if [[ -z "$url" && -z "$file" ]]; then
echo "Error: Either -u or -l must be provided"
display_usage
exit 1
fi
# Check if at least one tool is selected
if [[ "$run_katana" == false && "$run_gau" == false && "$run_waybackurls" == false && "$run_passive_gospider" == false && "$run_robofinder" == false ]]; then
echo "Error: At least one tool (-k, -g, -w, -s or -r) must be selected"
display_usage
exit 1
fi
# Run katana
if "$run_katana"; then
echo -e "${GREEN}[Katana is running]${RESET}"
if [[ -n "$url" ]]; then
if [[ -n "$output_file" ]]; then
host=$(echo "$url" | unfurl format %d)
echo "$url" | katana -js-crawl -known-files -automatic-form-fill -silent --no-sandbox -headless -crawl-scope "$host" -extension-filter css,jpg,jpeg,png,svg,img,gif,mp4,flv,pdf,doc,ogv,webm,wmv,webp,mov,mp3,m4a,m4p,ppt,pptx,scss,tif,tiff,ttf,otf,woff,woff2,bmp,ico,eot,htc,swf,rtf,image | sort -u | anew "$output_file"
else
host=$(echo "$url" | unfurl format %d)
echo "$url" | katana -js-crawl -known-files -automatic-form-fill -silent --no-sandbox -headless -crawl-scope "$host" -extension-filter css,jpg,jpeg,png,svg,img,gif,mp4,flv,pdf,doc,ogv,webm,wmv,webp,mov,mp3,m4a,m4p,ppt,pptx,scss,tif,tiff,ttf,otf,woff,woff2,bmp,ico,eot,htc,swf,rtf,image | sort -u
fi
else
if [[ -n "$output_file" ]]; then
while IFS= read -r line; do
host=$(echo "$line" | unfurl format %d)
echo "$line" | katana -js-crawl -known-files -automatic-form-fill -silent --no-sandbox -headless -extension-filter css,jpg,jpeg,png,svg,img,gif,mp4,flv,pdf,doc,ogv,webm,wmv,webp,mov,mp3,m4a,m4p,ppt,pptx,scss,tif,tiff,ttf,otf,woff,woff2,bmp,ico,eot,htc,swf,rtf,image | sort -u
done < "$file" | anew "$output_file"
else
while IFS= read -r line; do
host=$(echo "$line" | unfurl format %d)
echo "$line" | katana -js-crawl -known-files -automatic-form-fill -silent --no-sandbox -headless -extension-filter css,jpg,jpeg,png,svg,img,gif,mp4,flv,pdf,doc,ogv,webm,wmv,webp,mov,mp3,m4a,m4p,ppt,pptx,scss,tif,tiff,ttf,otf,woff,woff2,bmp,ico,eot,htc,swf,rtf,image | sort -u
done < "$file"
fi
fi
fi
# Run gau
if "$run_gau"; then
echo -e "${GREEN}[GAU is running]${RESET}"
if [[ -n "$url" ]]; then
if [[ -n "$output_file" ]]; then
echo "$url" | gau | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | anew "$output_file"
else
echo "$url" | gau | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u
fi
else
if [[ -n "$output_file" ]]; then
cat "$file" | gau | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | anew "$output_file"
else
cat "$file" | gau | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u
fi
fi
fi
# Run waybackurls
if "$run_waybackurls"; then
echo -e "${GREEN}[Waybackurls is running]${RESET}"
if [[ -n "$url" ]]; then
if [[ -n "$output_file" ]]; then
echo "$url" | waybackurls | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | anew "$output_file"
else
echo "$url" | waybackurls | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u
fi
else
if [[ -n "$output_file" ]]; then
cat "$file" | waybackurls | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | anew "$output_file"
else
cat "$file" | waybackurls | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u
fi
fi
fi
# Run passive gospider
if "$run_passive_gospider"; then
echo -e "${GREEN}[Passive GoSpider is running]${RESET}"
if [[ -n "$url" ]]; then
if [[ -n "$output_file" ]]; then
sudo -- sh -c "echo '127.0.0.1 "$url"' >> /etc/hosts"
echo https://"$url" | gospider --other-source --include-subs --subs --quiet | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | grep -Eo 'https?://[^ ]+' | sed 's/]$//' | anew "$output_file"
sudo -- sh -c "sed -i '/127.0.0.1 "$url"/d' /etc/hosts"
else
sudo -- sh -c "echo '127.0.0.1 "$url"' >> /etc/hosts"
echo https://"$url" | gospider --other-source --include-subs --subs --quiet | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | grep -Eo 'https?://[^ ]+' | sed 's/]$//'
sudo -- sh -c "sed -i '/127.0.0.1 "$url"/d' /etc/hosts"
fi
else
if [[ -n "$output_file" ]]; then
while IFS= read -r line; do
sudo -- sh -c "echo '127.0.0.1 $line' >> /etc/hosts"
echo "https://$line" | gospider --other-source --include-subs --subs --quiet | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | grep -Eo 'https?://[^ ]+' | sed 's/]$//' | anew "$output_file"
sudo -- sh -c "sed -i '/127.0.0.1 $line/d' /etc/hosts"
done < "$file"
else
while IFS= read -r line; do
sudo -- sh -c "echo '127.0.0.1 $line' >> /etc/hosts"
echo "https://$line" | gospider --other-source --include-subs --subs --quiet | grep -Eiv '\.(css|jpg|jpeg|png|svg|img|gif|exe|mp4|flv|pdf|doc|ogv|webm|wmv|webp|mov|mp3|m4a|m4p|ppt|pptx|scss|tif|tiff|ttf|otf|woff|woff2|bmp|ico|eot|htc|swf|rtf|image|rf)' | sort -u | grep -Eo 'https?://[^ ]+' | sed 's/]$//'
sudo -- sh -c "sed -i '/127.0.0.1 $line/d' /etc/hosts"
done < "$file"
fi
fi
fi
# Run robofinder
if "$run_robofinder"; then
echo -e "${GREEN}[Robifinder is running]${RESET}"
if [[ -n "$url" ]]; then
if [[ -n "$output_file" ]]; then
url="$url"
timestamps=$(curl -s "https://web.archive.org/cdx/search/cdx?url=$url/robots.txt&filter=statuscode:200&fl=timestamp,original&collapse=digest" | awk '{print $1}' | sort -r)
for timestamp in $(echo $timestamps)
do
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Allow:|^Disallow:/ {print $2}' | sed "s|^|https://$url|" | anew
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Sitemap:/ {print $2}' | anew
done | sort -u | tee -a "$output_file"
else
url="$url"
timestamps=$(curl -s "https://web.archive.org/cdx/search/cdx?url=$url/robots.txt&filter=statuscode:200&fl=timestamp,original&collapse=digest" | awk '{print $1}' | sort -r)
for timestamp in $(echo $timestamps)
do
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Allow:|^Disallow:/ {print $2}' | sed "s|^|https://$url|" | anew
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Sitemap:/ {print $2}' | anew
done | anew
fi
else
if [[ -n "$output_file" ]]; then
while IFS= read -r line; do
url=$line
timestamps=$(curl -s "https://web.archive.org/cdx/search/cdx?url=$url/robots.txt&filter=statuscode:200&fl=timestamp,original&collapse=digest" | awk '{print $1}' | sort -r)
for timestamp in $(echo $timestamps)
do
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Allow:|^Disallow:/ {print $2}' | sed "s|^|https://$url|" | anew
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Sitemap:/ {print $2}' | anew
done
done < "$file" | sort -u | tee -a "$output_file"
else
while IFS= read -r line; do
url=$line
timestamps=$(curl -s "https://web.archive.org/cdx/search/cdx?url=$url/robots.txt&filter=statuscode:200&fl=timestamp,original&collapse=digest" | awk '{print $1}' | sort -r)
for timestamp in $(echo $timestamps)
do
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Allow:|^Disallow:/ {print $2}' | sed "s|^|https://$url|" | anew
curl -sk "https://web.archive.org/web/$(echo $timestamp)if_/$url/robots.txt" | awk '/^Sitemap:/ {print $2}' | anew
done | anew
done < "$file"
fi
fi
fi