-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvhfinder
52 lines (41 loc) · 1022 Bytes
/
vhfinder
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
#!/bin/bash
bold=$(tput bold)
norm=$(tput sgr0)
GREEN='\033[0;32m'
RED='\033[0;31m'
BROWN='\033[0;33m'
NC='\033[0m' # no color
[ $# -ge 1 -a -f "$1" ] && input="$1" || input="-"
raw=$(cat $input)
raw=$(printf "$raw" | sed -E -e "s/https?:\/\///g" | xargs -n1 | sort -u | xargs)
IFS=$' ' read -rd '' -a hosts <<<"$raw"
declare -A ips
for host in "${hosts[@]}"; do
host=$(printf "$host" | tr -d '\n')
echo -n -e "${BROWN}[+]${NC} $host"
if [[ $host != "" ]]; then
raw_ip=$(dig +short "${host}")
if [[ $raw_ip != "" ]]; then
printf "\n"
IFS=$'\n' read -rd '' -a ip <<<"$raw_ip"
fip=${ip[-1]}
isset=${ips[$fip]}
if [[ $isset != "" ]]; then
ips[$fip]+=",$host"
else
ips[$fip]=$host
fi
else
echo -e " ${RED}${bold}[IP Not Found]${norm}${NC}"
fi
fi
done
printf "\nRESULTS:\n"
for ip in "${!ips[@]}"; do
echo -e "${GREEN}${bold}[+]${NC} $ip${norm}"
IFS=$',' read -rd '' -a _hosts <<<"${ips[$ip]}"
for host in "${_hosts[@]}"; do
printf "\t"
echo "|_ $host"
done
done