#!/usr/bin/perl use DBI; use IO::Socket; ################################################################### my $myName="acid.rizon.net"; my $myPass="fupass"; my $mySID="01S"; my $myTagline="(H) Rizon Network Service"; my $remoteIP="127.0.0.1"; my $remotePort=27888; my $mysqlHost="localhost"; my $mysqlUser="me"; my $mysqlPass="fucker"; my $mysqlDB="acidtwo"; my $log="/usr/home/rizon/acid/active.log"; my $rawlog="/usr/home/rizon/acid/raw.log"; my %masters; my %nickmap; my %cnickmap; my $mynick; my $synced; ################################################################### my $tmp=fork; if($tmp) { exit; } #my $db=DBI->connect("DBI:mysql:$mysqlDB:$mysqlHost",$mysqlUser,$mysqlPass); my $irc=new IO::Socket::INET(PeerAddr=>$remoteIP,PeerPort=>$remotePort,Proto=>"tcp"); local $SIG{HUP} = sub { &rehash }; ################################################################### if(!$irc) { print "Couldn't connect to $remoteIP:$remotePort\n"; exit; } &out("PASS $myPass TS :$mySID"); &out("CAPAB :EX IE HOPS HUB AOPS KLN GLN"); &out("SERVER $myName 1 :$myTagline"); &out("SVINFO 6 5 0 :"); &do_startup; while($irc) { $dat=<$irc> || exit; $dat=~s/[\n,\t,\r]//g; &raw_log($dat); # $debugOut=console; if($debugOut eq "console") { print "DEBUG: [$dat]\n"; } elsif(defined($debugOut)) { print $irc ":".$cnickmap{$mynick}." PRIVMSG $debugOut :$dat\n"; } my @s=split(/ /,$dat); $s[0]=~s/^://; $s[10]=~s/^://; $command=lc($s[1]); if(lc($s[0]) eq "ping") { &out("PONG :$mySID"); } if(lc($s[1]) eq "uid" && defined($s[9])) { # new nick joined # :01H UID "nick" 1 1222590308 +i "ident" god 0 01HAAAAAB 0 god :root # print "New nick\n"; } } sub do_startup { #### pull settings from mysql db #### $mynick = 'RootServ'; &createuser("RootServ","+iorSN","root","acid.rizon.net","0.0.0.0","Strangely Addictive..."); &joinchan("RootServ", "#debug"); } sub createuser { my $inick = $_[0]; my $imode = $_[1]; my $iident = $_[2]; my $ihost = $_[3]; my $iip = $_[4]; my $igecos = $_[5]; #name my @chars = ("A".."Z"); my @nums = (0..9); my $crands = $chars[rand(26)] . $chars[rand(26)]; my $nrands = $nums[rand(10)] . $nums[rand(10)] . $nums[rand(10)] . $nums[rand(10)]; my $uid = $mySID . $crands . $nrands; #not going to check for the nick already being in use on another server AND the uid... while ((my $k, my $v) = each(%cnickmap)) { if($nickmap{$k}) { #user nick already exists on another server... &out("KILL $v \"You shouldn't be using this nick...\" :$mySID"); &createuser($_[0],$_[1],$_[2],$_[3],$_[4],$_[5]); return; } elsif($v eq $uid) { #uid is already assigned to one of my nicks... &createuser($_[0],$_[1],$_[2],$_[3],$_[4],$_[5]); return; } } &out(":$mySID UID $inick 1 $imode $iident $ihost 0 $uid 0 $iip :$igecos"); $cnickmap{$uid} = $inick; } sub joinchan { my $jnick = $_[0]; my $jchan = $_[1]; my $juid; while ((my $k, my $v) = each(%cnickmap)) { if(lc($v) eq lc($jnick)) { $juid = $v } } &out(":$mySID SJOIN $jchan +nt :$juid"); } sub log { open(LOG,">>".$log); print LOG "[".localtime()."] $_[0]\n"; close(LOG); } sub raw_log { open(RAWLOG,">>".$rawlog); print RAWLOG "[".localtime()."] $_[0]\n"; close(RAWLOG); } sub irc_send { my $data = $_[0]; $data .= "\n\n"; } sub rehash { #### repull settings from mysql db and clear vars #### } sub out { $line=$_[0]; $t=time(); $line=~s//$t/ig; print $irc $line."\n"; if($debugOut eq "console") { print "DEBUG: [$dat]\n"; } elsif(defined($debugOut)) { print $irc ":".$nickType{main}." PRIVMSG $debugOut :$line\n"; } }