5
5
# By Andrew Horton aka urbanadventurer, MorningStar Security
6
6
# Homepage: http://www.morningstarsecurity.com/research/bing-ip2hosts
7
7
#
8
+ # Version 0.4 Released December 19th, 2013. Updated to use nslookup, new usage, fixed tmp file issue
8
9
# Version 0.3 Released September 21st, 2012. Updated because Bing mobile search changed.
9
10
# Version 0.2 Released April 2nd, 2010
10
11
# Version 0.1 Released December 2nd, 2009 at Kiwicon III in New Zealand
11
12
#
12
13
# License: GPLv3
13
14
14
- VERSION=0.3
15
+ VERSION=o.4
15
16
TMPDIR=/tmp
16
17
ANIMATION=1
17
18
OUTPUTIP=0
18
19
HTTPPREFIX=0
19
20
IP=
20
21
PREFIX=
22
+ DEBUG=0
21
23
22
24
if [ -z " $1 " ] || [ " $1 " == " -h" ] || [ " $1 " == " --help" ]; then
25
+ echo -en ' \E[31m'
23
26
echo -e " bing-ip2hosts ($VERSION ) by Andrew Horton aka urbanadventurer
24
27
Homepage: http://www.morningstarsecurity.com/research/bing-ip2hosts
28
+ "
29
+ echo -en ' \033[0m'
25
30
26
- Find hostnames that share an IP address with your target which can be a hostname or
27
- an IP address. This makes use of Microsoft Bing.com ability to seach by IP address,
28
- e.g. \" IP:210.48.71.196\" .
31
+ echo -e " Useful for web intelligence and attack surface mapping of vhosts during
32
+ penetration tests. Find hostnames that share an IP address with your target
33
+ which can be a hostname or an IP address. This makes use of Microsoft
34
+ Bing.com ability to seach by IP address, e.g. \" IP:210.48.71.196\" .
29
35
30
36
Usage: $0 [OPTIONS] <IP|hostname>
31
37
@@ -66,8 +72,10 @@ single_page=
66
72
if [ ` echo " $1 " | egrep " (([0-9]+\.){3}[0-9]+)|\[[a-f0-9:]+\]" ` ]; then
67
73
IP=" $1 "
68
74
else
69
- IP=` resolveip -s " $1 " `
70
- if [ " $? " != 0 ]; then
75
+ # IP=`resolveip -s "$1"`
76
+ IP=` nslookup " $1 " | egrep " ^Address: \w+\.\w+\.\w+\.\w+$" | tail -1| awk ' { print $2 }' `
77
+ # dig -t a treshna.com +short
78
+ if [ " $IP " == " " ]; then
71
79
echo " Error: cannot resolve $1 to an IP"
72
80
exit
73
81
fi
@@ -86,12 +94,18 @@ while [ -z "$last_page_check" ] && [ -n "$how_many" ] && [ -z "$single_page" ];
86
94
wget -q -O " $out " " $url "
87
95
88
96
last_page_check=` egrep -o ' <span class="sb_count" id="count">[0-9]+-([0-9]+) of (\1)' $out `
97
+ if [ " $DEBUG " -eq 1 ]; then
98
+ echo " Last Page Check: $last_page_check "
99
+ fi
89
100
90
101
# if no results are found, how_many is empty and the loop will exit
91
102
how_many=` egrep -o ' <span class="sb_count" id="count">[^<]+' $out | cut -d ' >' -f 2| cut -d ' ' -f 1-3`
92
103
93
104
# check for a single page of results
94
105
single_page=` egrep -o ' <span class="sb_count" id="count">[0-9] results' $out `
106
+ if [ $DEBUG -eq 1 ]; then
107
+ echo " Single Page: $single_page "
108
+ fi
95
109
96
110
# no captcha support or detection
97
111
# pages will contain "Typing the characters in the picture above helps us ensure that a person, not a program, is performing a search"
@@ -101,8 +115,14 @@ while [ -z "$last_page_check" ] && [ -n "$how_many" ] && [ -z "$single_page" ];
101
115
102
116
uniq_hosts=` cat " $all_hosts " | cut -d ' /' -f 3 | tr ' [:upper:]' ' [:lower:]' | sort | uniq | wc -l`
103
117
104
- # rm -f "$out"
118
+ if [ $DEBUG -eq 0 ]; then
119
+ rm -f " $out "
120
+ fi
121
+
105
122
let page=$page +1
123
+ if [ $DEBUG -eq 1 ]; then
124
+ echo " Page: $page "
125
+ fi
106
126
done
107
127
108
128
if [ $ANIMATION == 1 ]; then
111
131
112
132
uniq_hosts=` cat " $all_hosts " | cut -d ' /' -f 3 | tr ' [:upper:]' ' [:lower:]' | sort | uniq`
113
133
114
- # rm -f "$all_hosts"
134
+ if [ $DEBUG -eq 0 ]; then
135
+ rm -f " $all_hosts "
136
+ fi
115
137
116
138
if [ $OUTPUTIP == 1 ]; then
117
139
PREFIX=" $IP ,"
0 commit comments