 
#!/bin/bash
#
# execount by Murple (murple@clark.net)
# version 0.0.0
#
# I dont care what you do with this.
#
# Based on elfcount by Brandon (photon@nol.net)
#
# Counts up the executables on your system, and reports back
# on what kind of format they are. Keeps a log of your ELF
# conversion percent. Run it as root.

echo "Scanning executable directories. This may take a minute..."
echo " "

file `find /bin /usr/bin /usr/local/bin /usr/sbin /sbin /usr/X11/bin -perm +111` > /tmp/checkbin.$$

EXEX=`cat /tmp/checkbin.$$ | wc -l`
ELFC=`grep ELF /tmp/checkbin.$$ | wc -l`
AOUTC=`grep Linux/i386 /tmp/checkbin.$$ | wc -l`
ZMAGIC=`grep ZMAGIC /tmp/checkbin.$$ | wc -l`
QMAGIC=`grep QMAGIC /tmp/checkbin.$$ | wc -l`
LINKS=`grep symbolic /tmp/checkbin.$$ | wc -l`
SH=`grep Bourne /tmp/checkbin.$$ | wc -l`
BASH=`grep Bourne-Again /tmp/checkbin.$$ | wc -l`
CSH=`grep "C Shell" /tmp/checkbin.$$ | wc -l`
ENG=`grep English /tmp/checkbin.$$ | wc -l`
ASCII=`grep ascii /tmp/checkbin.$$ | wc -l`
DIR=`grep Directory /tmp/checkbin.$$ | wc -l`
SCRIPTS=$[($SH+$BASH+$CSH)]
BINZ=$[($AOUTC+$ELFC)]

clear

echo "Number of a.out binaries:      $AOUTC"
echo "   QMAGIC Demand Paged:        $QMAGIC"
echo "   ZMAGIC Demand Paged:        $ZMAGIC"
echo "Number of ELF binaries:        $ELFC"
echo "Scripts:                            $[($SH+$BASH+$CSH+$KSH)]"
echo "   sh:                         $SH"
echo "   bash:                       $BASH"
echo "   csh/tcsh:                   $CSH"
echo "ASCII (could be ksh or perl):  $ASCII"
echo "English text:                  $ENG"
echo "Symbolic links:                $LINKS"
echo "------------------------------ -----------"
echo "Total executable count:        $EXEX"
echo " "
echo "Approximate ELF percentage:    $[($ELFC*100)/($EXEX)]%"
echo "Approximate a.out percentage:  $[($AOUTC*100)/($EXEX)]%"
echo "Approximate script percentage: $[($SCRIPTS*100)/($EXEX)]%"
echo "Approximate other percentage:  $[((($EXEX-$BINZ)-($SCRIPTS))*100)/($EXEX)]%"
echo " "
echo "ELF conversion percent:        $[($ELFC*100)/($BINZ)]%"

echo "Updating /root/execount.log..."
echo "`date`" >> /root/execount.log
echo "Number of a.out: $AOUTC" >> /root/execount.log
echo "Number of ELF: $ELFC" >> /root/execount.log
echo "Total binaries: $[($AOUTC+$ELFC)]" >> /root/execount.log
echo "ELF conversion percent: $[($ELFC*100)/($BINZ)]%" >> /root/execount.log
echo "=================================================" >> /root/execount.log

if [ "$[($ELFC*100)/($BINZ)]" = "100" ]; then
   echo "YOU ARE SUPER-K00L K-RAD ELYTE! You are 100% ELFed!"
   echo "YOU ARE SUPER-K00L K-RAD ELYTE! You are 100% ELFed!" >> /root/execount.log
fi

rm /tmp/checkbin.$$
