Jump to content
MadAgent

bing-ip2hosts updated

Recommended Posts


#!/bin/bash
#Based on bing-ip2hosts v4 by Andrew Horton aka urbanadventurer, MorningStar Security
#Modified by MadAgent on August 2014, released for RST Forums
#Saves results to 'hosts' file
VERSION=0.5
TMPDIR=./tmp
ANIMATION=0
OUTPUTIP=1
HTTPPREFIX=0
IP=
PREFIX=
DEBUG=0
rm -rf hosts > /dev/null 2>&1
if [ -z "$1" ] || [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
echo -e "
OPTIONS are:
-n\t\tTurn off the progress indicator animation
-t <DIR>\tUse this directory instead of /tmp. The directory must exist.
-i\t\tOptional CSV output. Outputs the IP and hostname on each line, separated by a comma.
-p\t\tOptional http:// prefix output. Useful for right-clicking in the shell.
"
exit 1
fi

while getopts "nipt:" optionName; do
case "$optionName" in
n) ANIMATION=0;;
t) TMPDIR="$OPTARG";;
i) OUTPUTIP=1;;
p) HTTPPREFIX=1;;
[?]) echo "Error"; exit 1;;
esac
done

shift $(($OPTIND -1))

if [ -z "$1" ]; then
echo "need an IP or hostname"
exit 1
fi

animation="/-\|"
page=0
last_page_check=
how_many=1
uniq_hosts=0
single_page=

# if the parameter looks like an IP go ahead, otherwise resolve it
if [ `echo "$1" | egrep "(([0-9]+\.){3}[0-9]+)|\[[a-f0-9:]+\]"` ]; then
IP="$1"
else
# IP=`resolveip -s "$1"`
IP=`nslookup "$1" |egrep "^Address: \w+\.\w+\.\w+\.\w+$"|tail -1|awk '{ print $2 }'`
# dig -t a treshna.com +short
if [ "$IP" == "" ]; then
echo "Error: cannot resolve $1 to an IP"
exit
fi
fi

all_hosts=`mktemp -p $TMPDIR -t bing-ip2hosts.tmp.XXXXXX`

while [ -z "$last_page_check" ] && [ -n "$how_many" ] && [ -z "$single_page" ]; do
if [ $ANIMATION == 1 ]; then
echo -ne "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
echo -en "[ $IP | Scraping $how_many | Found $uniq_hosts | ${animation: $(( $page % 4 )) :1} ]"
fi
url="http://www.bing.com/search?q=ip%3A$IP&go=&qs=n&first=${page}0&FORM=PERE"

out=`mktemp -p "$TMPDIR" -t bing-ip2hosts.tmp.XXXXXX`
wget -q -O "$out" "$url"

last_page_check=`egrep -o '<span class="sb_count" id="count">[0-9]+-([0-9]+) of (\1)' $out`
if [[ "$last_page_check" -eq "" ]]; then
last_page_check=`egrep -o '<span class="sb_count">[0-9]+-([0-9]+) of (\1)' $out`
fi
if [ "$DEBUG" -eq 1 ]; then
echo "Last Page Check: $last_page_check"
fi

# if no results are found, how_many is empty and the loop will exit
how_many=`egrep -o '<span class="sb_count" id="count">[^<]+' $out|cut -d '>' -f 2|cut -d ' ' -f 1-3`
if [[ "$how_many" -eq "" ]]; then
how_many=`egrep -o '<span class="sb_count">[^<]+' $out|cut -d '>' -f 2|cut -d ' ' -f 1-3`
fi
# check for a single page of results
single_page=`egrep -o '<span class="sb_count" id="count">[0-9] results' $out`
if [[ "$single_page" -eq "" ]]; then
single_page=`egrep -o '<span class="sb_count">[0-9] ' $out`
fi
if [ $DEBUG -eq 1 ];then
echo "Single Page: $single_page"
fi

# no captcha support or detection
# pages will contain "Typing the characters in the picture above helps us ensure that a person, not a program, is performing a search"

vhosts=`cat "$out"| egrep -o "<h3><a href=\"[^\"]+" $out |cut -d '"' -f 2`
if [[ "$vhosts" -eq "" ]]; then
vhosts=`cat "$out"| egrep -o "<h2><a href=\"[^\"]+" $out |cut -d '"' -f 2`
fi
echo -e "$vhosts" >> "$all_hosts"

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

if [ $DEBUG -eq 0 ]; then
rm -f "$out"
fi

let page=$page+1
if [ $DEBUG -eq 1 ]; then
echo "Page: $page"
fi
done

if [ $ANIMATION == 1 ]; then
echo
fi
__NSLOOKUP="$(which nslookup)"
__HOST="$(which host)"
if [[ "$__NSLOOKUP" != "" ]]; then
echo -e "$($__NSLOOKUP $IP | grep name | awk '{ print $NF }' | sed 's/\.$//' | sed 's/ //g')" >> "$all_hosts"
fi
if [[ "$__HOST" != "" ]]; then
echo -e "$($__HOST $IP | grep -v 'not found' | grep name | awk '{ print $NF }' | sed 's/\.$//' | sed 's/ //g')" >> "$all_hosts"
fi
echo -e "$(host $IP | grep -v 'not found' | awk '{ print $NF }' | sed 's/\.$//' | sed 's/ //g')" >> "$all_hosts"
uniq_hosts=`cat "$all_hosts" | cut -d '/' -f 3 | tr '[:upper:]' '[:lower:]' | sort | uniq`

if [ $DEBUG -eq 0 ]; then
rm -f "$all_hosts"
fi

if [ $OUTPUTIP == 1 ]; then
PREFIX="$IP,"
fi
if [ $HTTPPREFIX == 1 ]; then
PREFIX="$PREFIX""http://"
fi

for h in `echo "$uniq_hosts"`
do
echo "$PREFIX$h" >> hosts
done

Link to comment
Share on other sites

Trebuia doar modificat din <h3> in <h2> la linia 99...

Daca te uitai in temp files de la bing iti dadeai seama din prima...

Pai, cam asta e, dar din teste am vazut ca pe anumite geo locatii ale serverului pune tot h3, restul de modificari sunt facute dupa nevoile mele...

Link to comment
Share on other sites

Salutare!am si eu o problema cu bing :) daca doriti sa ma ajutati sau sa ma lamuriti .. deci am scanu asta .. cand dau ./ bing-ip2hosts ex Google nu imi gaseste nimic .

raping 1 | Found 0 | / ]-ip2hosts-0.4# ./bing-ip2hosts Google

trebuie instalat ceva pe srv ? am incercat pe vre-o 10 servere si aceiasi problema am.As fi recunoscator daca m-ar ajuta cineva.

Link to comment
Share on other sites

ba nu mai merge cam de 1 an :) are careva varianta noua? daca o are rog sa posteze aici

normal ca nu merge daca te uiti in sursa si te uiti la regex folosita in acel script e diferit si normal ca nu prinde nimic.... doar un singur parametru trebuie schimabt si apoi merge .........


vhosts=`cat "$out"| egrep -o "<h3><a href=\"[^\"]+" $out |cut -d '"' -f 2`
if [[ "$vhosts" -eq "" ]]; then
vhosts=`cat "$out"| egrep -o "<h2><a href=\"[^\"]+" $out |cut -d '"' -f 2`
fi

in sfarsit!!!!

Link to comment
Share on other sites

am incercat si nu merge nu rezolva nimic. normal era sa schimbi h3 cu h2 si mergea, dar nu mai merge acum. cand facem temp ul la pagina e gol nu mai ia pagina, asa ca degeaba ii pui h2 in lic de h3 daca pagina de o ia e goala.

e de la altceva, oricum pe mine nu ma duce capul mai mult, ca atunci daca stiam o faceam si nu mai intrebam :))

Link to comment
Share on other sites


root@localhost:~/Downloads/php# ./bing 80
./bing: 16: ./bing: +: not found
\e[0m-e \e[1;37;1m[\e[1;32;1m+\e[1;37;1m]BING: 0 of 9125370 @ip2host\e[0m./bing: 16: ./bing: +: not found
\e[0m-e \e[1;37;1m[\e[1;32;1m+\e[1;37;1m]BING: 0 of 9125370 @ip2host\e[0m./bing: 1
root@localhost:~/Downloads/php# ./clean urls.txt
root@localhost:~/Downloads/php# cat www
av.cookchildrens.org
cookiris.cookchildrens.org
credapply.cookchildrens.org
ess.cookchildrens.org
secure.cookchildrens.org
www.berkeley-public.org
www.campsanguinity.org
www.centerforchildrenshealth.org
www.cookchildrenshomehealth.com
www.cookchp.com
www.cookchp.org
www.pedspal.org

La mine merge! cine il vrea sami dea pm ca vil dau al toti care imi dau pm

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...