forked from daverstephens/The-SOC-Shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhois.sh
77 lines (58 loc) · 2.52 KB
/
whois.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
#!/bin/bash
#Simple script used to look up via whois and host commands
#a series of domains.
#Writen by Sheldon Johnson 24/02/2014
################################################################################
#User Defined Constants
################################################################################
#Change the values of the variables below to suit your requirments.
PROJECTNAME="PROJECTNAMEHERE"
OUTDIR="$HOME/tmp/""$PROJECTNAME"
TLD[${#TLD[@]}]="tld1"
TLD[${#TLD[@]}]="tld2"
URI[${#URI[@]}]="domain1"
URI[${#URI[@]}]="domain2"
################################################################################
#Constants
################################################################################
OUTNAME="$OUTDIR/""$PROJECTNAME""."
HOSTDIR="$OUTDIR/hosts/"
WHOISDIR="$OUTDIR/whois/"
HOSTTEMP="$HOSTDIR""hosts.tmp"
HOSTIPV4="$HOSTDIR""hosts.ipv4.txt"
HOSTIPV6="$HOSTDIR""hosts.ipv6.txt"
NOREG="$WHOISDIR""not_registered"
################################################################################
#Setup
################################################################################
mkdir -p $OUTDIR
mkdir $HOSTDIR
mkdir $WHOISDIR
mdkir $NOREG
cd $OUTDIR
################################################################################
#Content
################################################################################
for j in ${URI[@]}; do
for i in ${TLD[@]}; do
URL=$j"."$i
host $URL | grep "has" > "$HOSTTEMP"
grep "has address" "$HOSTTEMP" >> "$HOSTIPV4"
grep "has IPv6 address" "$HOSTTEMP" >> "$HOSTIPV6"
whois $URL > "$WHOISDIR""$URL"".whois.txt"
done
done
rm "$HOSTTEMP"
################################################################################
#Final Output Notes
################################################################################
echo "Just a few tips..."
echo "The following lines will extract all the ipv4/6 addresses from your outputs:"
echo "cut -d \" \" -f 4 $HOSTIPV4 | sort -u"
echo "cut -d \" \" -f 5 $HOSTIPV6 | sort -u"
echo "The following line will simplify the outputs to make it more readable:"
echo "cut -d \" \" -f 1,4 $HOSTIPV4 | sort -u\""
echo "The following command will strip out all of the empty whois records:"
echo "find $WHOISDIR -type f -size -51c -exec rm {} $NOREG \;"
echo "This will remove all of the entries which returned the value \"This domain name has not been registered\":"
echo "for i in \$(find $WHOISDIR -maxdepth 1 -type f -exec ls {} \;); do grep \"This domain name has not been registered\" \$i > /dev/null; if [ $? == 0 ]; then mv \$i $NOREG; fi; done"