VHost listing script

From ProjectWiki
(Difference between revisions)
Jump to: navigation, search
(KbSwR6 <a href="http://lgkyspfsttfs.com/">lgkyspfsttfs</a>, [url=http://grvhhbezilnt.com/]grvhhbezilnt[/url], [link=http://phljkypftubp.com/]phljkypftubp[/link], http://vybxflcqxjsx.com/)
m (Reverted edits by 24.130.4.250 (Talk); changed back to last version by 89.28.28.22)
Line 4: Line 4:
 
rwxvTk  <a href="http://rmweoezmwiqj.com/">rmweoezmwiqj</a>, [url=http://xnpeegbqxass.com/]xnpeegbqxass[/url], [link=http://nuwmoiugpkon.com/]nuwmoiugpkon[/link], http://ikqxdotbydja.com/
 
rwxvTk  <a href="http://rmweoezmwiqj.com/">rmweoezmwiqj</a>, [url=http://xnpeegbqxass.com/]xnpeegbqxass[/url], [link=http://nuwmoiugpkon.com/]nuwmoiugpkon[/link], http://ikqxdotbydja.com/
  
KbSwR6  <a href="http://lgkyspfsttfs.com/">lgkyspfsttfs</a>, [url=http://grvhhbezilnt.com/]grvhhbezilnt[/url], [link=http://phljkypftubp.com/]phljkypftubp[/link], http://vybxflcqxjsx.com/
+
==How to use it?==
 +
Copy paste the code below into a text edit, change the IPSEARCH param, save as something like 'vhosts', change flags to executable and then type ./vhosts, iotw:
 +
<source lang="bash">
 +
emacs vhosts
 +
</source>
 +
copy/pasta the bash source code from below, edit the IPSEARCH parameter, and save here... for instance if your first IP on box was 241.12.191.18 you'd use:<bR>
 +
IPSEARCH="241"
 +
 
 +
You may also want to change the FOOTER that is displayed at bottom, or modify the colors.
 +
 
 +
Next make it executable, then run it:<br>
 +
<source lang="bash">
 +
chmod 755 vhosts
 +
./vhosts
 +
</source>
 +
 
 +
If the script is placed in the shell's search path such as /usr/local/bin/ directory the script will be available to all users.
  
 
==Bash Source Code (bsd)==
 
==Bash Source Code (bsd)==

Revision as of 06:46, 8 April 2010

vhosts - vhost listing script

Contents

rwxvTk <a href="http://rmweoezmwiqj.com/">rmweoezmwiqj</a>, [url=http://xnpeegbqxass.com/]xnpeegbqxass[/url], [link=http://nuwmoiugpkon.com/]nuwmoiugpkon[/link], http://ikqxdotbydja.com/

How to use it?

Copy paste the code below into a text edit, change the IPSEARCH param, save as something like 'vhosts', change flags to executable and then type ./vhosts, iotw:

emacs vhosts

copy/pasta the bash source code from below, edit the IPSEARCH parameter, and save here... for instance if your first IP on box was 241.12.191.18 you'd use:
IPSEARCH="241"

You may also want to change the FOOTER that is displayed at bottom, or modify the colors.

Next make it executable, then run it:

chmod 755 vhosts
./vhosts

If the script is placed in the shell's search path such as /usr/local/bin/ directory the script will be available to all users.

Bash Source Code (bsd)

#!/usr/local/bin/bash
 
#####################
# Settings
#####################
 
### regexp for IP search (first octect of IP addresses should be sufficient) ###
### to search multiple subnets use the infix operator |  such as:
#IPSEARCH="147|64"
IPSEARCH="204";
#IPv6 use the first few digits like so...
#IPSEARCH="2001:5c0";
 
### colors ###
#title color
COL1="\x1b[0;31;40m";
#ip color
COL2="\x1b[0;32;40m";
#'=' color
COL3="\x1b[0;34;40m";
#domain color
COL4="\x1b[0;33;40m";
#error color
COL5="\x1b[0;31;40m";
#colors off (back to natural terminal colors)
COLOFF="\x1b[0;37;00m";
 
### footer (Displayed at end of list) ###
FOOTER="Type v6hosts for ipv6 hosts"
 
### Command paths ###
IFCONFIG="/sbin/ifconfig";
GREP="/usr/bin/grep";
AWK="/usr/bin/awk";
HOST="/usr/bin/host";
 
##################
#Code goes here
##################
 
HOSTNAME=`hostname`;
echo -en "$COL1 Hostnames for $HOSTNAME\n";
for ip in `$IFCONFIG | $GREP inet | $AWK '{print $2}' | $GREP -E "$IPSEARCH"`; 
do
  echo -ne "$COL2$ip $COL3=";
  if hostreply=`$HOST $ip`; then
    domain=`echo $hostreply | $GREP domain | $AWK '{print $5}'`; 
    if fwdreply=`$HOST -t A $domain`; then
      forward=`echo "$fwdreply" | $AWK '{print $4}'`;
      if [ "$forward" = "$ip" ]; then
        error="";
      else
        error="$COL5(Forward lookup mismatch: $forward)";   
      fi
    else
      error="$COL5(forward does not resolve)";
    fi
    echo -ne "$COL4 $domain $error\n";
  else
    echo -ne "$COL5 reverse lookup failed ._.\n";
  fi
done
 
echo -ne "$COLOFF\n";
if [ -n "$FOOTER" ]; then 
  echo $FOOTER
fi
 
## erisu, 2009
#######################

Bash Source Code (Linux)

Decided to post another version after fixing some issues with some Linuxs printing "addr:XXX.XXX.XXX.XXX" from ifconfig. Also made the command paths Linux friendly. ^_^

#!/bin/bash
 
#####################
# Settings
#####################
 
### regexp for IP search (first octect of IP addresses should be sufficient) ###
### to search multiple subnets use the infix operator |  such as:
#IPSEARCH="147|64"
IPSEARCH="190|200";
#IPv6 use the first few digits like so...
#IPSEARCH="2001:5c0";
 
### colors ###
#title color
COL1="\x1b[0;31;40m";
#ip color
COL2="\x1b[0;32;40m";
#'=' color
COL3="\x1b[0;34;40m";
#domain color
COL4="\x1b[0;33;40m";
#error color
COL5="\x1b[0;31;40m";
#colors off (back to natural terminal colors)
COLOFF="\x1b[0;37;00m";
 
### footer (Displayed at end of list) ###
FOOTER="Enjoy!"
 
### Command paths ###
IFCONFIG="/sbin/ifconfig";
GREP="/bin/grep";
AWK="/usr/bin/awk";
HOST="/usr/bin/host";
 
##################
#Code goes here
##################
 
HOSTNAME=`hostname`;
echo -en "$COL1 Hostnames for $HOSTNAME\n";
for tip in `$IFCONFIG | $GREP inet | $AWK '{print $2}' | $GREP -E "$IPSEARCH"`;
do
  IFS=":"
  zip=($tip);
  ip=${zip[1]};
  echo -ne "$COL2$ip $COL3=";
  if hostreply=`$HOST $ip`; then
    domain=`echo $hostreply | $GREP domain | $AWK '{print $5}'`;
    if fwdreply=`$HOST -t A $domain`; then
      forward=`echo "$fwdreply" | $AWK '{print $4}'`;
      if [ "$forward" = "$ip" ]; then
        error="";
      else
        error="$COL5(Forward lookup mismatch: $forward)";
      fi
    else
      error="$COL5(forward does not resolve)";
    fi
    echo -ne "$COL4 $domain $error\n";
  else
    echo -ne "$COL5 reverse lookup failed ._.\n";
  fi
done
 
echo -ne "$COLOFF\n";
if [ -n "$FOOTER" ]; then
  echo $FOOTER
fi
 
## erisu, 2009
#######################
Personal tools
irssi scripts
eggdrop scripts