Skip to content

Commit 771e397

Browse files
author
Andrew Horton
committed
Version 0.4 Released December 19th, 2013. Updated to use nslookup, new usage, fixed tmp file issue
* Updated usage * Fixed tmp file issue where files weren't being deleted * Resolves hostnames using nslookup instead of resolveip. Thanks Xavier Mertens
1 parent e4fd5e5 commit 771e397

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Version 0.4
2+
* Updated usage
3+
* Fixed tmp file issue where files weren't being deleted
4+
* Resolves hostnames using nslookup instead of resolveip. Thanks Xavier Mertens
5+
16
Version 0.3
27
* Updated the progress animation with results found, and the current page being searched
38
* Updated scraper to use the main bing.com site as the mobile bing site changed how it showed results

README

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ HELP
88
-------
99
Use the following command for usage information.
1010

11-
bing-ip2hosts (0.3) by Andrew Horton aka urbanadventurer
11+
bing-ip2hosts (o.4) by Andrew Horton aka urbanadventurer
1212
Homepage: http://www.morningstarsecurity.com/research/bing-ip2hosts
1313

14-
Find hostnames that share an IP address with your target which can be a hostname or
15-
an IP address. This makes use of Microsoft Bing.com ability to seach by IP address,
16-
e.g. "IP:210.48.71.196".
14+
Useful for web intelligence and attack surface mapping of vhosts during
15+
penetration tests. Find hostnames that share an IP address with your target
16+
which can be a hostname or an IP address. This makes use of Microsoft
17+
Bing.com ability to seach by IP address, e.g. "IP:210.48.71.196".
1718

1819
Usage: ./bing-ip2hosts [OPTIONS] <IP|hostname>
1920

bing-ip2hosts

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,33 @@
55
# By Andrew Horton aka urbanadventurer, MorningStar Security
66
# Homepage: http://www.morningstarsecurity.com/research/bing-ip2hosts
77
#
8+
# Version 0.4 Released December 19th, 2013. Updated to use nslookup, new usage, fixed tmp file issue
89
# Version 0.3 Released September 21st, 2012. Updated because Bing mobile search changed.
910
# Version 0.2 Released April 2nd, 2010
1011
# Version 0.1 Released December 2nd, 2009 at Kiwicon III in New Zealand
1112
#
1213
# License: GPLv3
1314

14-
VERSION=0.3
15+
VERSION=o.4
1516
TMPDIR=/tmp
1617
ANIMATION=1
1718
OUTPUTIP=0
1819
HTTPPREFIX=0
1920
IP=
2021
PREFIX=
22+
DEBUG=0
2123

2224
if [ -z "$1" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
25+
echo -en '\E[31m'
2326
echo -e "bing-ip2hosts ($VERSION) by Andrew Horton aka urbanadventurer
2427
Homepage: http://www.morningstarsecurity.com/research/bing-ip2hosts
28+
"
29+
echo -en '\033[0m'
2530

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\".
2935
3036
Usage: $0 [OPTIONS] <IP|hostname>
3137
@@ -66,8 +72,10 @@ single_page=
6672
if [ `echo "$1" | egrep "(([0-9]+\.){3}[0-9]+)|\[[a-f0-9:]+\]"` ]; then
6773
IP="$1"
6874
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
7179
echo "Error: cannot resolve $1 to an IP"
7280
exit
7381
fi
@@ -86,12 +94,18 @@ while [ -z "$last_page_check" ] && [ -n "$how_many" ] && [ -z "$single_page" ];
8694
wget -q -O "$out" "$url"
8795

8896
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
89100

90101
# if no results are found, how_many is empty and the loop will exit
91102
how_many=`egrep -o '<span class="sb_count" id="count">[^<]+' $out|cut -d '>' -f 2|cut -d ' ' -f 1-3`
92103

93104
# check for a single page of results
94105
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
95109

96110
# no captcha support or detection
97111
# 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" ];
101115

102116
uniq_hosts=`cat "$all_hosts" | cut -d '/' -f 3 | tr '[:upper:]' '[:lower:]' | sort | uniq | wc -l`
103117

104-
# rm -f "$out"
118+
if [ $DEBUG -eq 0 ]; then
119+
rm -f "$out"
120+
fi
121+
105122
let page=$page+1
123+
if [ $DEBUG -eq 1 ]; then
124+
echo "Page: $page"
125+
fi
106126
done
107127

108128
if [ $ANIMATION == 1 ]; then
@@ -111,7 +131,9 @@ fi
111131

112132
uniq_hosts=`cat "$all_hosts" | cut -d '/' -f 3 | tr '[:upper:]' '[:lower:]' | sort | uniq`
113133

114-
#rm -f "$all_hosts"
134+
if [ $DEBUG -eq 0 ]; then
135+
rm -f "$all_hosts"
136+
fi
115137

116138
if [ $OUTPUTIP == 1 ]; then
117139
PREFIX="$IP,"

0 commit comments

Comments
 (0)