Instalando aimsniff no Debian / Ubuntu

De Enciclopédia do leleobhz

Conteúdo

[editar] Instalando aimsniff no Debian/Ubuntu

[editar] Prefácio

Vou assumir que já se tenha o mysql e o apache instalado e configurado. Gostaria o leitor NÃO EXECUTASSE o artigo sem antes lê-lo.

[editar] Pacotaiada

Sem mistério! é só executar o que está abaixo:
  • Shell - root
INTERFACE_A_OUVIR=eth2

cd /usr/src
wget http://aimsniff.com/releases/aimsniff-0.9d.tar.gz
tar -xvzf aimsniff-0.9d.tar.gz
cd /usr/src/aimsniff-0.9d
aptitude install -y libnet-pcap-perl libunicode-string-perl libdbi0 libdbd-mysql libproc-daemon-perl\
 libfilehandle-unget-perl liburi-perl libio-tty-perl libxml-dom-perl libxml-parser-perl libhtml-tagset-perl\
 libhtml-parser-perl libdate-manip-perl libparse-yapp-perl liblwp2 liblwp-protocol-http-socketunix-perl libunix-syslog-perl
cpan -i NetPacket::Ethernet NetPacket::IP NetPacket::TCP Proc::Simple

cat <<AIMSNIFF.CONF > /etc/aimsniff.conf
packetCount=10
dev=$INTERFACE_A_OUVIR
filter='tcp and port 5190'
promisc=1
timeout=1000
SMB=1
daemon=1
#nodb=0
#quiet=1
##Database information
host=localhost
user=aimsniff
password=$(/root/bin/gera_senha 16)
AIMSNIFF.CONF

mysqladmin -p create aimsniff
mysql -p -D aimsniff < table.struct
mysql -p <<DATABASE_CONF
GRANT ALL ON aimsniff.* TO aimsniff@localhost IDENTIFIED BY '$(cat /etc/aimsniff.conf | grep password | cut -d "=" -f 2)';
DATABASE_CONF

[editar] Incialização

Crie o seguinte arquivo:
  • /etc/init.d/aimsniff
#! /bin/sh

. /lib/lsb/init-functions

case "$1" in
	start)
		log_daemon_msg "Starting aimSniff..."
		if ! start-stop-daemon --start --quiet --oknodo --exec /usr/src/aimsniff-0.9d/aimSniff.pl -- -C=/etc/aimsniff.conf; then
			log_end_msg 1
			exit 1
		fi
		echo "."
        ;;

	stop)
		log_daemon_msg "Stopping aimSniff..."
		if [[ -n `ps axo pid,comm | grep aimSniff.pl | cut -d " " -f 1` ]]; then
			for i in `ps axo pid,comm | grep aimSniff.pl | cut -d " " -f 1`; do
				kill $i
			done
		log_end_msg 0
		fi
	;;

	*)
		echo "Usage: $0 {start|stop}"
		exit 1
esac

exit 0

E depois execute:
  • Shell - root
chmod a+x /etc/init.d/aimsniff
update-rc.d aimsniff defaults
Para iniciar na hora:
  • Shell - root
invoke-rc.d aimsniff start

[editar] WAS

O WAS é a interface web (php) que lê os dados da base mysql. Devo salientar que apache + php + php-mysql + mysql server TEM que estar configurados! Segue o procedimento de instalação do mesmo:
  • Shell - root
cd /usr/src
wget http://aimsniff.com/releases/was-0.1.2b.tar.gz
tar -xvzf was-0.1.2b.tar.gz
cp -Rf was-0.1.2b /var/www/was
cd /var/www/was

cat <<CONFIG_PHP>.config.php
<?
\$VERSION="0.1.2";
\$dbserver="localhost";
\$dbuser="aimsniff";
\$dbpwd="$(cat /etc/aimsniff.conf | grep password | cut -d "=" -f 2)";
\$dbname="aimsniff";
\$limit="55";
\$refreshRate="60";
\$usageChart="on";
\$mostTalkChart="on";
\$mostPopChart="on";
\$outPerH="on";
\$inPerH="on";
\$inoutPerH="on";
\$outPerDOW="on";
\$inPerDOW="on";
\$inoutPerDOW="on";
\$outPerDOM="on";
\$inPerDOM="on";
\$inoutPerDOM="on";
?>
CONFIG_PHP

[editar] Anexos

[editar] Gerador de senha

Pequeno script para criar senhas. Usado acima.
  • /root/bin/gera_senha
#!/bin/bash
pwdlen=$1

char=(0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ! @ \# $ % ^ \&)

max=${#char[*]}

for i in `seq 1 $pwdlen`
do
	let rand=${RANDOM}%${max}
	str="${str}${char[$rand]}"
done
echo $str
Ferramentas pessoais