From 2821b7e9a1d24ae37898534682a1255d86e45e3e Mon Sep 17 00:00:00 2001 From: Philippe L'Heureux Date: Fri, 22 Dec 2023 22:53:54 -0500 Subject: [PATCH] init --- AGLhosts.file | 57 ++ Gline.file | 2 + HELP | 1 + KillChan.file | 1 + MMGlog | 0 Makefile | 14 + Mhosts.file | 196 +++++ NoChan.file | 1 + NoGline.file | 14 + NoOper.file | 2 + OperChan.file | 12 + README | 66 ++ Shosts.file | 85 +++ admin.list | 11 + banlist.c | 100 +++ checkuworld | 10 + clones.h | 310 ++++++++ config.h | 143 ++++ daemon.c | 148 ++++ debug.h | 64 ++ file.c | 1340 +++++++++++++++++++++++++++++++++++ helpservice.c | 131 ++++ logsrv/Makefile | 13 + logsrv/autostart | 8 + logsrv/client.c | 295 ++++++++ logsrv/com.c | 14 + logsrv/config.h | 26 + logsrv/socket.c | 144 ++++ map.c | 125 ++++ match.c | 41 ++ myfile.h | 49 ++ nicklist.c | 1579 +++++++++++++++++++++++++++++++++++++++++ nicklist.h | 93 +++ nickserv.c | 13 + parse.c | 1768 ++++++++++++++++++++++++++++++++++++++++++++++ servers.admin | 11 + sevnum.c | 253 +++++++ socket.c | 572 +++++++++++++++ user.file | 50 ++ uworld.c | 493 +++++++++++++ uworld.h | 34 + uworld.sh | 7 + uworldhelp | 62 ++ wastedump.c | 61 ++ wastedump.h | 6 + 45 files changed, 8425 insertions(+) create mode 100644 AGLhosts.file create mode 100644 Gline.file create mode 120000 HELP create mode 100644 KillChan.file create mode 100644 MMGlog create mode 100755 Makefile create mode 100644 Mhosts.file create mode 100644 NoChan.file create mode 100644 NoGline.file create mode 100644 NoOper.file create mode 100644 OperChan.file create mode 100644 README create mode 100644 Shosts.file create mode 100644 admin.list create mode 100644 banlist.c create mode 100755 checkuworld create mode 100644 clones.h create mode 100755 config.h create mode 100644 daemon.c create mode 100644 debug.h create mode 100755 file.c create mode 100755 helpservice.c create mode 100755 logsrv/Makefile create mode 100755 logsrv/autostart create mode 100644 logsrv/client.c create mode 100644 logsrv/com.c create mode 100755 logsrv/config.h create mode 100644 logsrv/socket.c create mode 100644 map.c create mode 100755 match.c create mode 100644 myfile.h create mode 100644 nicklist.c create mode 100644 nicklist.h create mode 100755 nickserv.c create mode 100755 parse.c create mode 100644 servers.admin create mode 100755 sevnum.c create mode 100755 socket.c create mode 100755 user.file create mode 100755 uworld.c create mode 100755 uworld.h create mode 100755 uworld.sh create mode 100755 uworldhelp create mode 100644 wastedump.c create mode 100644 wastedump.h diff --git a/AGLhosts.file b/AGLhosts.file new file mode 100644 index 0000000..835822f --- /dev/null +++ b/AGLhosts.file @@ -0,0 +1,57 @@ +*.zianet.net +*.inu.net +*.iamerica.net +*.spidernet.net +*.southeast.net +*modem*.* +*dialin*.* +*dialup*.* +*port*.* +*.mtl.total.net +*.aol.com +*.ccmaresme.es +*.nettipaja.clinet.fi +*.online.no +*.nitco.com +*.acadia.net +*.erols.com +*istk*.jps.net +*lakeheadu.ca +*tm.net.my +*.jaring.my +*.maltanet.net +*.ibm.net +*.cytanet.com.cy +*.mci.net +*.telia.com +*.tor.iSTAR.ca +*.sb.west.net +*.compuserve.com +*.satlink.com +*.mixcom.net +*.gibnet.gi +*.p3.net +*.internet.com.mx +*.lightspeed.net +*.ihug.co.nz +*.earthlink.net +*.softdisk.com +*.pop.tip.nl +*.quebectel.com +*.pacbell.net +*.att.net +*.videotron.net +*.compuserve.com +*ppp*.advantage.ca +*.telepac.pt +*.ms.uu.net +*.telepost.no +*.ix.netcom.com +*.codetel.net.do +*.pacific.net.sg +*cnc*.concentric.net +*-*.concentric.net +*.ppp.sn.no +*.psi.net +*.MIA.Icanect.Net +*.interlinx.qc.ca diff --git a/Gline.file b/Gline.file new file mode 100644 index 0000000..f6a0566 --- /dev/null +++ b/Gline.file @@ -0,0 +1,2 @@ +868971453 *bcoffelt@158.222.1.65 CHANNELBLAST BANNED by Channel Cleanup [1] +869489901 *@*coolio.org ripper_!ripper@grove.ufl.edu Abusive user [1] diff --git a/HELP b/HELP new file mode 120000 index 0000000..2eed8d1 --- /dev/null +++ b/HELP @@ -0,0 +1 @@ +/usr/local/lib/irc/help \ No newline at end of file diff --git a/KillChan.file b/KillChan.file new file mode 100644 index 0000000..c34561f --- /dev/null +++ b/KillChan.file @@ -0,0 +1 @@ +8DffeEddDkeFdckE diff --git a/MMGlog b/MMGlog new file mode 100644 index 0000000..e69de29 diff --git a/Makefile b/Makefile new file mode 100755 index 0000000..da87c70 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ +LIBS = -ltermcap +#CC = /usr/local/bin/alpha-dec-osf4.0-gcc +CC = gcc +CFLAGS = -O2 +OBJECTS = uworld.o socket.o file.o match.o parse.o nickserv.o helpservice.o sevnum.o nicklist.o daemon.o wastedump.o + +SOURCES = uworld.c socket.c file.c match.c parse.c nickserv.c helpservice.c sevnum.c nicklist.c daemon.c wastedump.c + +.c.o: + ${CC} ${CFLAGS} -c $< + +uworld: ${OBJECTS} + ${CC} ${CFLAGS} -o midway ${OBJECTS} ${LIBS} + diff --git a/Mhosts.file b/Mhosts.file new file mode 100644 index 0000000..c394da6 --- /dev/null +++ b/Mhosts.file @@ -0,0 +1,196 @@ +*jungle.org +*theguru.com +*spot.aros.net +*.wildstar.net +*.wildstar.com +*irc.crystalball.com +osf1.gmu.edu +mail1.i1.net +net30.nucleus.com +Securit.nsuok.edu +ibm*.ensicaen.ismra.fr +foonix.foonet.net +zart.spiretech.com +jitter.rahul.net +chat.eskimo.com +phish.nether.net +*pipeline.com +gateway.telecom.ksu.edu +falcon.cc.ukans.edu +falcon.lhup.edu +taisun1.tamuk.edu +*.worldone.com +Serve.org +*.YFN.EDU +*.YSU.EDU +SecurIt.nsuok.edu +undernet.org +bbs.* +freenet.* +*.ksu.ksu.edu +irc.crystalball.com +infinity.c2.org +*.teleport.com +*.cns.hp.com +*.ucdavis.edu +karn.wright.edu +*.hp.com +200.20.157.* +bouncer.gnn.com +user1.iswest.com +ra1.randomc.com +*.sorostm.ro +alioth.pi.net +beatrix.btxgate.de +earth-le1.execpc.com +Bayou.UH.EDU +HOSS.EAC.CC.AZ.US +Kestrel.is.und.ac.za +MarLa.enDirect.qc.ca +Mercury.mcs.com +Mill2.MillComm.COM +Panther.UCIS.Dal.Ca +Pegasus.cc.ucf.edu +TURBO.Kean.EDU +UCS.ORST.EDU +academ01.tam.itesm.mx +aix2.uottawa.ca +alcor.Concordia.CA +alpha2-nf.luton.ac.uk +arad.bgu.ac.il +aristotle.algonet.se +ashur.cc.biu.ac.il +athena.compulink.gr +avalon.sul.com.br +*.u.washington.edu +bengt.algonet.se +*.lm.com +bessel.nando.net +bgsuvax.bgsu.edu +bigtca*.3-cities.com +bluestem.prairienet.org +boardwalk.ecst.csuchico.edu +box.degeer.norrkoping.se +carolina-chat.com +cin*.consumerinfonet.com +citicom.ag1.com +cnct.com +comp.uark.edu +connectnet1.connectnet.com +datastug1.ped.lundbygym.educ.goteborg.se +doorway.evansville.net +dunx1.ocs.drexel.edu +eagle.ais.net +email.california.com +eskimo.com +exec.tscnet.com +expert.cc.purdue.edu +firefly.prairienet.org +grove.ufl.edu +gucis.cit.gu.edu.au +gumby.com +gw.cybalink.com +hasle.sn.no +helios.dmu.ac.uk +huk.a.sn.no +hunker.b4futures.net +hyper.shadow.net +iavbbs.com +ieat3.et.Uni-Magdeburg.DE +igs-gate.cng.on.ca +inde.com +infinity.c2.net +infolink.com.br +io.uwinnipeg.ca +is1.hk.super.net +iserv.datasvar.se +jagor.srce.hr +jove.acs.unt.edu +jupiter.neptune.fr +jupiter.telluric.com +kairos.algonet.se +kirk.dnaco.net +landslide.openix.com +learnet.freenet.hut.fi +legba.unsl.edu.ar +leonis.nus.sg +lnxland1.ccd.cccoes.edu +lux.latrobe.edu.au +mackten.asucla.ucla.edu +mail* +mallard2.duc.auburn.edu +manhattan.thirdwave.net +marikit.iphil.net +mercury.gaianet.net +merlin.si.uqam.ca +miso.wwa.com +msuvx1.memphis.edu +mugca.cc.monash.edu.au +mwr.mwr.is +neptune.uqtr.uquebec.ca +maroon.tc.umn.edu +netcom*.netcom.com +nova.dreamscape.com +novell.capecod.net +ns1.maf.mobile.al.us +ods.ods.net +nkuaxp.nku.edu +olci.com +onyx.valunet.com +orion.it.luc.edu +orion.scasd.k12.pa.us +pacx.com +paul.cclu.lv +piglet.cc.utexas.edu +playpen.com +pluto.njcc.com +prostar.com +diac.com +pulua.hcc.Hawaii.Edu +rainbow.descon.com +ramses.centic.utem.cl +rapidnet.com +real.on.ca +redash.qut.edu.au +rimmer.acs.bolton.ac.uk +sassynet.com +serv1.vossnet.co.uk +shell.flinet.com +shellx.best.com +shrike.depaul.edu +simply.ok.is +sodium.Mlink.NET +soleil.acomp.usf.edu +sophocles.algonet.se +spocyberlink.net +step.mother.com +step.polymtl.ca +storm.stud.ntnu.no +sunspot.tiac.net +talos.spark.net.gr +tao.sans.vuw.ac.nz +terranet.terranet.ab.ca +thetics.europa.com +titan.liunet.edu +twinkle.Generation.NET +unix.gsusa.org +verdi.NMSU.Edu +viper.nauticom.net +vr.virt.net +wally.ipa.net +world-f.std.com +zeus.compulink.gr +*.olinter.com +pewter.ing.unlp.edu.ar +206.116.71.230 +talk.nacs.net +addman.rapid.co.uk +207.102.122.244 +*.cs.vu.nl +199.170.84.240 +200.250.252.191200.250.252.192, +*get-on.net +crash.nildram.co.uk +167.144.36.234 +timberwolf.snip.net +phish.nether.net diff --git a/NoChan.file b/NoChan.file new file mode 100644 index 0000000..1672fd4 --- /dev/null +++ b/NoChan.file @@ -0,0 +1 @@ +#kill 1200 diff --git a/NoGline.file b/NoGline.file new file mode 100644 index 0000000..4fae204 --- /dev/null +++ b/NoGline.file @@ -0,0 +1,14 @@ +*quicklink.com +*mountain.superlink.net +*.a.sol.no +*tanzit.cetlink.net +*uoknor.edu +*chatsystems.com +*channels*.undernet.org +*ns1.qnet.com +*.ucdavis.edu +*.nssl.uoknor.edu +*gateway.telecom.ksu.edu +*.ksu.ksu.edu +*karn.wright.edu +*seminole*.wildstar.net diff --git a/NoOper.file b/NoOper.file new file mode 100644 index 0000000..7cbdc0f --- /dev/null +++ b/NoOper.file @@ -0,0 +1,2 @@ +*.ro 876294105 +freeze@pm2s12.newwave.net 864103174 diff --git a/OperChan.file b/OperChan.file new file mode 100644 index 0000000..2c91a25 --- /dev/null +++ b/OperChan.file @@ -0,0 +1,12 @@ +valhalla +uworld.floods +nazi +enforcers +warez +vacilon +vacilon +NickServ +Êñfð®©ê®§ +Êñfð®©ê®§. +syke +bleat diff --git a/README b/README new file mode 100644 index 0000000..9fed541 --- /dev/null +++ b/README @@ -0,0 +1,66 @@ +UNDERNET version of Uworld (Protocol 9) THE OLD FAITHFUL +Written by danny@chatsystems.com + +UWORLD DISTRIBUTION SITE: www.chatsystems.com/docs/uworld.html + Look at www.chatsystems.com and add a FREE chatroom to your WWW site!!! + + VERY IMPORTANT INFORMATION ABOUT UWORLD READ THIS CAREFULLY!!! + ######################################################################### + +RESTRICTIONS: + This is NOT public domain code. You are not to redistribute this code. + The only approved site to obtain this code from is the site listed above: + www.chatsystems.com/docs/uworld.html ALL code in this distribution is + copyright by Internet Chat Systems, Inc. (even if it is OLD speghetti code) + +NOTE: This code was hacked/thrown together over about 7 years of + tossing ideas around, learning more about C, and is quite honestly + NOT something I would dare to consider professional quality code. This + code was mainly never distributed because I consider it somewhat embarassing + to read through. You are welcome to use this code to help learn things, + and you are welcome to use it on your own IRC network, however please give + credit where credit is due, do not redistribute the code. have your friends + obtain the code from the Uworld distribution site listed above. + +DISCLAIMER: + I make no promises about anything associated with this code, and do not + plan on supporting this in any way. It has been used previously on + OSF1, IRIX4.5, and BSDI. It also atleast compiles under FreeBSD. Quite + simply, no warranties, no garuntees, no support. This is OLD (extremely + old) code. This code is distributed AS IS, with no support what so ever. + I apologize for the lack of documentation or instructions. I had not intended + to actually ever publicize this code, however numerous people have shown lots + of interest in obtaining it, so after recent events, I decided what the heck, + its not doing me any good sitting there doing nothing, if it helps someone + else on the network, then as long as they read the blurb about chatsystems + on our distribution site, why not give it out. + +OFFER: + If you are interested in a more professionally designed version of Uworld +(version 3) which is P10, that has been used on the Undernet IRC network, +please send me a note danny@chatsystems.com and we can discuss licensing a +BINARY version of Uworld.v3 + + ########################################################################## + + This is the original P9 Uworld used by Undernet for several years. Undernet +was the first network to allow operators special abilities to help thier users. +The name Uworld actually came from UnderWorld.uoknor.edu which was the first +version of operator services that was later just called Uworld when we became +what is now called Undernet. There have been numerous immitations on the +network and it is very flattering that my ideas and the ideas of Undernet have +been picked up and such by others to the point that having a Uworld on the +network is almost considered a tradition. + + Feel free to send me email about this or other chat network related services. +Internet Chat Systems (at the time of this writing) currently maintains the +Undernet Channel Services (X/W), the Undernet P10 Uworld (Uworld.v3), and the +RCSD chatserver (which supports HTML, IRC, and direct Telnet connections). We +are about to release the new version of X/W and soon will be looking at adding +new and exciting modules to the RCSD chatserver to improve chat network add on +services. Internet Chat Systems, Chat Network services are professionally +coded top of the line services (NOT like this uworld source that you have here) +Please let us know if we can be of service to you or your chat network. + + + diff --git a/Shosts.file b/Shosts.file new file mode 100644 index 0000000..0c3eec8 --- /dev/null +++ b/Shosts.file @@ -0,0 +1,85 @@ +*dial* +*ppp* +*modem* +antietam.nssl.uoknor.edu +*annex* +port* +pool* +slip* +ip* +max*.com +cust*.max* +*caribe.net +*.necleus.com +pc*.net +pc*.com +*.mwmicro.com +m*.lakeheadu.ca +ts*-*.* +ptp*.pig.net +s*-pm*-* +dyn* +*.boi.micron.net +as*-*.* +access*.abacom.com +*.highnet.co.at +*.onlink.net +node* +engine*.omnes.net +*dcn.davis.ca.us +*.cybernaute.com +eagle*.villagenet.com +d*.sonic.net +dlp*.center.eri.net +vav*.netaccess.on.ca +dol*.dol.net +*.acs.bolton.ac.uk +*.jaring.my +*.jovenet.fr +*.concentric.net +*.sojourn.net +*.compuserve.com +*.cwconnect.ca +*.telepac.pt +*.sat.texas.net +*.pcola.gulf.net +*.pi.net +*.compusmart.ab.ca +*.netvision.net.il +line* +*.accessus.net +xyp*.ltec.net +nts*.calstatela.edu +xy*port*.k12.ca.us +pc-*.ccfne.ns.ca +*.idt.net +dyn*.win.mnsi.net +col-*.erols.com +term*.jamstore.de +eburguser*.ncw.net +pc*.itpoint.org.uk +*max*.earthlink.net +ind*.iquest.net +*.ix.netcom.com +*.wchat.on.ca +caribe*.caribe.net +ivyland*.voicenet.com +*.direct.ca +*.xl.ca +*.li.net +pa*dsp*.orf.infi.net +ip*.interramp.com +usr*ip* +wthf*.gate.net +*gnn.com +*.i-link.net +*.vistech.net +pm* +castles*.castles.com +ras*.stic.net +info*.jet.es +apm*.realtime.net +as*.sci.net.mx +host*.rochelle.net +anc*.artic.net +agtd*.cadvision.com diff --git a/admin.list b/admin.list new file mode 100644 index 0000000..73bf928 --- /dev/null +++ b/admin.list @@ -0,0 +1,11 @@ +Vienna.AT.EU.UnderNet.org lorenz@olymp.wu-wien.ac.at +austin.tx.us.undernet.org zitz@ccwf.cc.utexas.edu +Chicago.IL.US.Undernet.org irc@misha.net +davis.ca.us.undernet.org cmlambertus@ucdavis.edu +washington-1.dc.us.undernet.org enger@seka.reston.ans.net +washington.dc.us.undernet.org irc@aol.net +SanJose.CA.US.Undernet.Org dholmes@rahul.net +Oxford.UK.EU.UnderNet.Org oxowl@owlnest.demon.co.uk +montreal.qu.ca.undernet.org undernet@step.polymtl.ca +Rochester.MI.US.Undernet.org jeff@oakland.edu +Amsterdam.NL.EU.undernet.org cpbaltus@cs.vu.nl diff --git a/banlist.c b/banlist.c new file mode 100644 index 0000000..f0794d5 --- /dev/null +++ b/banlist.c @@ -0,0 +1,100 @@ +#include +#include +#include + +extern int sevsck; + +struct aBan { + struct aBan *next; + char channel[255]; + char mask[150]; + char who[10]; + time_t timeout; +}; + +struct *banlist=NULL; + +int addban(char *who,char *mask,char *channel,time_t timeout) +{ + struct aBan *tmpban; + char outputbuf[512]; + + tmpban=(struct aBan *) malloc(sizeof(struct aBan)); + strcpy(tmpban->mask,mask); + strcpy(tmpban->who,who); + strcpy(tmpban->channel,channel); + tmpban->timeout = timeout; + + tmpban->next=bansist; + banlist=tmpban; + + sprintf(outputbuf,":chansvr MODE %s +b %s\n",tmpban->channel,tmpban->mask); + writeln(sevsck,outputbuf); + + return 1; +} + + + +int remove_ban(char *mask) +{ struct aBan *tmpban,*tmp2ban; + char outputbuf[512]; + + tmp2ban=banlist; + if(tmp2ban == NULL) return; + + if(!strcasecmp(banlist->mask,mask)) + { banlist=banlist->next; + free(tmp2ban); + return 1; + } + tmpban = banlist->next; + while(tmpban != NULL) + { if( !strcasecmp(tmpban->mask,mask)) + { tmp2ban->next=tmpban->next; + sprintf(outputbuf,":Chansvr MODE %s -b %s\n",tmpban->channel, + tmpban->mask); + writeln(sevsck,outputbuf); + free(tmpban); + return 1; + } + tmp2ban=tmpban; + tmpban=tmpban->next; + } +} + +int timeout_ban() +{ struct aBan *tmpban,*tmp2ban; + char outputbuf[512]; + + tmp2ban=banlist; + if((tmp2ban == NULL) || (tmp2ban->next == NULL)) return; + +/* if((banlist->timeout > 0) && (banlist->timeout < NOWTIME)) +** { banlist=banlist->next; +** free(tmp2ban); +** return 1; +** } +*/ + + tmpban = banlist->next; + while(tmpban != NULL) + { if((tmpban->timeout > 0) && (tmpban->timeout < NOWTIME)) + { tmp2ban->next=tmpban->next; + + sprintf(outputbuf,":Chansvr MODE %s -b %s\n",tmpban->channel, + tmpban->mask); + writeln(sevsck,outputbuf); + free(tmpban); + tmpban=tmp2ban->next; + continue; + +/* return 1; +*/ + } + tmp2ban=tmpban; + tmpban=tmpban->next; + } + +} + diff --git a/checkuworld b/checkuworld new file mode 100755 index 0000000..2cad1fd --- /dev/null +++ b/checkuworld @@ -0,0 +1,10 @@ +#!/bin/sh +if (ps augxw | grep -i uworld | grep -v grep > /dev/null) +then +sleep 0 +else +echo "* Uworld server started at" >> /ecn/ecnstf0/danny/dvmitche/uworld/uworldcronlog +date >> /ecn/ecnstf0/danny/dvmitche/uworld/uworldcronlog +/ecn/ecnstf0/danny/dvmitche/uworld/uworld > /dev/null & +exit 0 +fi diff --git a/clones.h b/clones.h new file mode 100644 index 0000000..e9e539f --- /dev/null +++ b/clones.h @@ -0,0 +1,310 @@ +/* this is the configuration file for the TSC/CLN anticlone program. +** Note that it scans multi-hosts FIRST and then goes to scan single hosts +** this is because there are fewer multihosts than there are single hosts. +*/ + + /* ANY host matching a mask listed here will automatically + ** be GLINED if abusing the network. + */ +char *glinehost[]={ + "*.telepac.pt","*.ms.uu.net","*.jaring.my","*.telepost.no", +"" }; + +char *kloneuser[]={"*Jobee","*klone","*kl0ne","*clone","clone*","user", +"*wassupfoo","*Jonnieboy","tORnfLESh","l33t",""}; + + /* Any host in this file will be reported as a CLONE if + ** there are more than 3 connections from this site. + */ +char *singlehost[]={ + "*dial*","*ppp*","*modem*", /* Standard MODEM dialups */ + "antietam.nssl.uoknor.edu", /* TESTING HOST */ + "*annex*", + "port*", + "pool*", + "slip*", + "ip*", + "max*.com", + "cust*.max*", + "*caribe.net", + "*.necleus.com", + "pc*.net", + "pc*.com", + "*.mwmicro.com", + "m*.lakeheadu.ca", + "ts*-*.*", + "ptp*.pig.net", + "s*-pm*-*", + "dyn*", + "*.boi.micron.net", + "as*-*.*", + "access*.abacom.com", + "*.highnet.co.at", + "*.onlink.net", + "node*", + "engine*.omnes.net", + "*dcn.davis.ca.us", + "*.cybernaute.com", + "eagle*.villagenet.com", + "d*.sonic.net", + "dlp*.center.eri.net", + "vav*.netaccess.on.ca", + "dol*.dol.net", + "*.acs.bolton.ac.uk", + "*.jaring.my", + "*.jovenet.fr", + "*.concentric.net", + "*.sojourn.net", + "*.compuserve.com", + "*.cwconnect.ca", + "*.telepac.pt", + "*.sat.texas.net", + "*.pcola.gulf.net", + "*.pi.net", + "*.compusmart.ab.ca", + "*.netvision.net.il", + "line*", + "*.accessus.net", + "xyp*.ltec.net", + "nts*.calstatela.edu", + "xy*port*.k12.ca.us", + "pc-*.ccfne.ns.ca", + "*.idt.net", + "dyn*.win.mnsi.net", + "col-*.erols.com", + "term*.jamstore.de", + "eburguser*.ncw.net", + "pc*.itpoint.org.uk", + "*max*.earthlink.net", + "ind*.iquest.net", + "*.ix.netcom.com", /* Netcom dialup lines */ + "*.wchat.on.ca", + "caribe*.caribe.net", + "ivyland*.voicenet.com", + "*.direct.ca", + "*.xl.ca", + "*.li.net", + "pa*dsp*.orf.infi.net", + "ip*.interramp.com", + "usr*ip*", + "wthf*.gate.net", + "*gnn.com", + "*.i-link.net", + "*.vistech.net", + "pm*", + "castles*.castles.com", + "ras*.stic.net", + "info*.jet.es", + "apm*.realtime.net", + "as*.sci.net.mx", + "host*.rochelle.net", + "anc*.artic.net", + "agtd*.cadvision.com", +"" }; + + + + + + /* Any multiple connections from the below domains will + ** be ignored by the clone scanner + */ +char *multihost[]={ + "*.wildstar.net","*.wildstar.com", + "*irc.crystalball.com", + "osf1.gmu.edu", + "mail1.i1.net", + "net30.nucleus.com", + "Securit.nsuok.edu", + "ibm*.ensicaen.ismra.fr", + "foonix.foonet.net", + "zart.spiretech.com", + "jitter.rahul.net", + "chat.eskimo.com", + "phish.nether.net", + "*pipeline.com", + "gateway.telecom.ksu.edu", + "falcon.cc.ukans.edu", + "falcon.lhup.edu", + "taisun1.tamuk.edu", + "*.worldone.com", + "Serve.org", + "*.YFN.EDU", + "*.YSU.EDU", + "SecurIt.nsuok.edu", + "undernet.org", + "bbs.*", + "freenet.*", + "*.ksu.ksu.edu", + "irc.crystalball.com", + "infinity.c2.org", + "*.teleport.com", + "*.cns.hp.com", + "*.ucdavis.edu", + "karn.wright.edu", + "*.hp.com", + "200.20.157.*", + "bouncer.gnn.com", + "user1.iswest.com", + "ra1.randomc.com", + "*.sorostm.ro", + "alioth.pi.net", + "beatrix.btxgate.de", + "earth-le1.execpc.com", + "Bayou.UH.EDU", + "HOSS.EAC.CC.AZ.US", + "Kestrel.is.und.ac.za", + "MarLa.enDirect.qc.ca", + "Mercury.mcs.com", + "Mill2.MillComm.COM", + "Panther.UCIS.Dal.Ca", + "Pegasus.cc.ucf.edu", + "TURBO.Kean.EDU", + "UCS.ORST.EDU", + "academ01.tam.itesm.mx", + "aix2.uottawa.ca", + "alcor.Concordia.CA", + "alpha2-nf.luton.ac.uk", + "arad.bgu.ac.il", + "aristotle.algonet.se", + "ashur.cc.biu.ac.il", + "athena.compulink.gr", + "avalon.sul.com.br", + "*.u.washington.edu", + "bengt.algonet.se", + "*.lm.com", + "bessel.nando.net", + "bgsuvax.bgsu.edu", + "bigtca*.3-cities.com", + "bluestem.prairienet.org", + "boardwalk.ecst.csuchico.edu", + "box.degeer.norrkoping.se", + "carolina-chat.com", + "cin*.consumerinfonet.com", + "citicom.ag1.com", + "cnct.com", + "comp.uark.edu", + "connectnet1.connectnet.com", + "datastug1.ped.lundbygym.educ.goteborg.se", + "doorway.evansville.net", +/* "drake.cnu.edu", +*/ + "dunx1.ocs.drexel.edu", + "eagle.ais.net", + "email.california.com", + "eskimo.com", + "exec.tscnet.com", + "expert.cc.purdue.edu", + "firefly.prairienet.org", + "grove.ufl.edu", + "gucis.cit.gu.edu.au", + "gumby.com", + "gw.cybalink.com", + "hasle.sn.no", + "helios.dmu.ac.uk", + "huk.a.sn.no", + "hunker.b4futures.net", + "hyper.shadow.net", + "iavbbs.com", + "ieat3.et.Uni-Magdeburg.DE", + "igs-gate.cng.on.ca", + "inde.com", + "infinity.c2.net", + "infolink.com.br", + "io.uwinnipeg.ca", + "is1.hk.super.net", + "iserv.datasvar.se", + "jagor.srce.hr", + "jove.acs.unt.edu", + "jupiter.neptune.fr", + "jupiter.telluric.com", + "kairos.algonet.se", + "kirk.dnaco.net", + "landslide.openix.com", + "learnet.freenet.hut.fi", + "legba.unsl.edu.ar", + "leonis.nus.sg", + "lnxland1.ccd.cccoes.edu", + "lux.latrobe.edu.au", + "mackten.asucla.ucla.edu", + "mail*", + "mallard2.duc.auburn.edu", + "manhattan.thirdwave.net", + "marikit.iphil.net", + "mercury.gaianet.net", + "merlin.si.uqam.ca", + "miso.wwa.com", + "msuvx1.memphis.edu", + "mugca.cc.monash.edu.au", + "mwr.mwr.is", + "neptune.uqtr.uquebec.ca", + "maroon.tc.umn.edu", + "netcom*.netcom.com", + "nova.dreamscape.com", + "novell.capecod.net", + "ns1.maf.mobile.al.us", + "ods.ods.net", + "nkuaxp.nku.edu", + "olci.com", + "onyx.valunet.com", + "orion.it.luc.edu", + "orion.scasd.k12.pa.us", + "pacx.com", + "paul.cclu.lv", + "piglet.cc.utexas.edu", + "playpen.com", + "pluto.njcc.com", + "prostar.com", + "diac.com", + "pulua.hcc.Hawaii.Edu", + "rainbow.descon.com", + "ramses.centic.utem.cl", + "rapidnet.com", + "real.on.ca", + "redash.qut.edu.au", + "rimmer.acs.bolton.ac.uk", + "sassynet.com", + "serv1.vossnet.co.uk", + "shell.flinet.com", + "shellx.best.com", + "shrike.depaul.edu", + "simply.ok.is", + "sodium.Mlink.NET", + "soleil.acomp.usf.edu", + "sophocles.algonet.se", + "spocyberlink.net", + "step.mother.com", + "step.polymtl.ca", + "storm.stud.ntnu.no", + "sunspot.tiac.net", + "talos.spark.net.gr", + "tao.sans.vuw.ac.nz", + "terranet.terranet.ab.ca", + "thetics.europa.com", + "titan.liunet.edu", + "twinkle.Generation.NET", + "unix.gsusa.org", + "verdi.NMSU.Edu", + "viper.nauticom.net", + "vr.virt.net", + "wally.ipa.net", + "world-f.std.com", + "zeus.compulink.gr", + "*.olinter.com", + "pewter.ing.unlp.edu.ar", + "206.116.71.230", + "talk.nacs.net", + "addman.rapid.co.uk", + "207.102.122.244", + "*.cs.vu.nl", + "199.170.84.240", + "200.250.252.191","200.250.252.192", + "*get-on.net", + "crash.nildram.co.uk", + "167.144.36.234", + "timberwolf.snip.net", + "phish.nether.net", +"" }; + + + diff --git a/config.h b/config.h new file mode 100755 index 0000000..08cb355 --- /dev/null +++ b/config.h @@ -0,0 +1,143 @@ +#include + /* USE_TSC enables the code that handles the TSC processing + */ +#define USE_TSC +#define GLINEFILE "Gline.file" +#define OPERCHANFILE "OperChan.file" +#define KILLCHANFILE "KillChan.file" +#define MAXGLINES 500 +#define CHANSUSPENDFILE "NoChan.file" +#define SUSPENDFILE "NoOper.file" +#define USE_DCC +#define CMDHISTORY 15 +#define MAXSUSPENDOPER 20 +#define MAXCLIENTS 200 +#define EGLINEFILE "NoGline.file" +#define AGLINEFILE "AGLhosts.file" +#define MHOSTFILE "Mhosts.file" +#define SHOSTFILE "Shosts.file" +#define MAXNOGLINES 100 +#define MAXMHOST 200 +#define MAXGLINEHOST 100 +#define JUPE_CHANSERVICE +#define JUPE_BUGS +#define FLUDFILE "FLUD.log" +#define VERSION "Uworld2 -- the second calling -- v2.0+wild" +#define MYSERVER "198.245.27.2" +/*#define UPLINK "okc.ok.us.undernet.org"/* */ +#define MYHOST "confusion.decade.net" /* */ +#define SERVERNAME "Uworld.undernet.org" +#define SERVERINFO "Undernet Special Services Central Cordinator" +#define BOTNAME "Uworld" +#define BOTINFO "Uworld Version 2 :The channel saving bot" +#define DEFAULTPORT 4400 +#define PASSWORD "hacker" +#define USERFILE "user.file" +#define PROTFILE "uworld.conf" +#define LOGFILE "Uworld.log" +#define FLOODFILE "Flood.log" +#define KILLFILE "kill.log" +#define HELPFILE "uworldhelp" +#define HELPBOT "UShelper" +#define OPERCHANNEL "uworld.floods" +#define MAXOPERCHAN 30 +#define WASTEDUMP + +#ifdef USE_DCC +#define S_ACTIVE 1 +#define S_FREE 0 +#define S_CLOSING -1 +#endif + +/*#define CLONE_REPORT "define this to do clonebot processing" /* */ + + /* REPORT_BADNICK -- reports user nicknames that are possible bots + ** or clones. + */ +#undef REPORT_BADNICK + +#define HELPBOTINFO "helpbot undernet.org Uworld.undernet.org :IRC HELP /msg help " +#define USHELP "Help_US" +#define USHELPINFO "helpbot undernet.org Uworld.undernet.org :/msg " +#define IRCHELP "ircIIhelp" +#define NICKSERV "NickServ" +#define NICKSERVINFO "Nickserv undernet.org Uworld.undernet.org :The nick machine" +#define CHANSVR "ChanSvr" +#define CHANSVRINFO "chansvr undernet.org Uworld.undernet.org :The channel saving bot" +#define HELPPATH "HELP" + + +#define DEFAULT_LEVEL 0 +#define DEBUG 0 +#define NOHELP 0 /* undefine this if you want the help services online */ + +#undef MAIL_GLINE +#define TSC_CHAN "Uworld.clones" +#define OPEROK -2 +#define GLINE -5 +#define RGLINE -6 +#define ASSHOLE -15 +#define KILL -20 +#define KTEL -10 +#define AUTO_BAN -25 +#define CLEARCHAN 10 +#define CLEAROPS 11 +#define CLEARBANS 12 +#define CLEARMODE 13 +#define KILTEL 15 +#define OPCOM 20 +#define SCAN 21 +#define AUTO_BAN_OPER 25 +#define AUTO_UNBAN_OPER 26 +#define AUTO_GLINE 27 +#define AUTO_UNGLINE 28 +#define SHOW_HOSTS 29 +#define OPER 100 +#define NOOPER -4 +#define MAXUSERS 4000 +#define TIMER 768845314 +#define MINCHARS 6 +#define MAXBUFSIZE 4096 +/*#define MAXBUFSIZE 1024 +**#define INPUTBUFFERSIZE 200000 +**#define INPUTBUFFERSIZE 200000 +*/ + +#define MAXFLOODHISTORY 20 +#define MSGFLOOD 10 +#define FLOODTIME 60 +#undef FLOOD_BYHOST + +struct aFloodProtect { + struct aFloodProtect *next; + struct aFloodProtect *prev; + char *hostname; + char *cmd; + int msgs; + int glined; + unsigned long reset; +}; + +#ifdef USE_DCC +struct aDccClient { + int fd; + int status; + char name[10]; + char hostname[100]; + char passwd[10]; + time_t lasttime; + int umode; +}; +#endif + + +#define DCC_ANY (1 << 0) +#define DCC_WALLOPS (1 << 1) +#define DCC_GLN (1 << 2) +#define DCC_TSC (1 << 3) +#define DCC_COMMAND (1 << 4) +#define DCC_MMG (1 << 5) +#define DCC_WALL (1 << 6) +#define USERMODES "catgwml" + +#define DCC_DEFAULT (DCC_ANY | DCC_WALLOPS) diff --git a/daemon.c b/daemon.c new file mode 100644 index 0000000..a7174a6 --- /dev/null +++ b/daemon.c @@ -0,0 +1,148 @@ + +#undef OSF1 + +/* +** This code written by danny@wildstar.net <-- wildThang --> +** You are free to use this code under the stipulation that it +** is not used to design any sort of clone/flood, or otherwise harassing +** type of application. I wrote this quickly and tried to keep it as +** basic as i could think up but enough to keep it interesting. +** Use it to LEARN! let me know if you have questions about it. +** -- this notice must remain in all code based on this code. +*/ + + +/* DAEMON.C + This file handles moving program into the background. + and it also contains the routine needed to establish a port + in case of wanting to have it listne to a port as well +*/ +#include +#include +#include +#include +#include +#include +#include + +/*#ifdef SIGTSTP */ +#include +#include +/*#endif */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +handle_kids() +{int pid; + +#ifdef OSF1 + union wait *status; + while( (pid = wait3(status,WNOHANG, (struct rusage *)0)) > 0) { } + +#else + +/* union wait status; +*/ + int status; + while( (pid = wait3(&status,WNOHANG, (struct rusage *)0)) > 0) { } + +#endif /* OSF1 */ + +} + +/* this function releases tty conrol and moves program into background */ +goto_bg() +{ +register int child,fd; + close(0); close(1); close(2); + + if(getppid() == 1) goto out; + +#ifdef SIGTTOU + signal(SIGTTOU,SIG_IGN); +#endif +#ifdef SIGTTIN + signal(SIGTTIN,SIG_IGN); +#endif +#ifdef SIGTSTP + signal(SIGTSTP,SIG_IGN); +#endif + + if( (child =fork()) < 0) + perror("fork"); + else if (child > 0) + exit(0); + +#ifdef SIGTSTP + if (setpgrp(0,getpid()) == -1) + perror("SETGROUP"); + + if( (fd = open("/dev/tty",O_RDWR)) >= 0) { + ioctl(fd, TIOCNOTTY, (char *)NULL); + close(fd); + } +#else + if(setpgrp() == -1) + perror("set group"); + + signal(SIGHUP,SIG_IGN); + + if( (child = fork()) < 0) + perror("cant fork"); + else if (child > 0) + exit(0); +#endif + +out: + for(fd=0;fd 9) exit(-1); + ; + } + else break; + } + + listen(sock,3); + return(sock); +} + diff --git a/debug.h b/debug.h new file mode 100644 index 0000000..98560c7 --- /dev/null +++ b/debug.h @@ -0,0 +1,64 @@ + +/***********************************************************/ +/* Telnet3d (the single process telnet service) written by +/* (dvmitche@nssl.uoknor.edu) ALL RIGHTS RESERVED. +/* +/* Duplication of this code is not permitted without explicit +/* aproval from the authors (dvmitche@nssl.uoknor.edu) in whole +/* or in parts. +/* +/* This project was designed to be used on UNDERNET IRC ONLY. +/* No exceptions to this without explicit permission from the +/* authors (dvmitche@nssl.uoknor.edu) +/* +/* Special Thanks for your ideas and support with this project. +/* go out to: +/* mandar@vinson.ecn.uoknor.edu +/* +/* NOTE: dvmitche@nssl.uoknor.edu is now danny@chatsystems.com +/*************************************************************/ + +/*#define DEBUG D_ALL /* */ + +FILE *debug_log; +#define DEBUG_LOGFILE "/tmp/debug.log" +#ifdef DEBUG +#define D_ALL (1 << 0) +#define D_WARNING (1 << 1) +#define D_ERROR (1 << 2) +#define D_FILE (1 << 3) +#define D_ERRNO (1 << 4) +#define D_MEMORY (1 << 5) +#define D_TRACE (1 << 6) +#define D_SOCKET (1 << 7) +#define D_INPUT (1 << 8) +#define D_KLINE (1 << 9) +#define D_NICKLIST (1 << 10) +#define D_BUFFER (1 << 11) +#define D_CHANLIST (1 << 12) +#endif + + +/******************************************************************/ +/* SPECIAL THANKS to Robin Thelland (intru@hamming.info.polymtl.ca) +/* for his input and ideas in improving the debug functions +/******************************************************************/ +#ifdef DEBUG +#define my_debug(X,Y) if((DEBUG == D_ALL) || (DEBUG & X)) \ + { if(debug_log != NULL) { \ + fprintf(debug_log,"[%s:%d] ",__FILE__,__LINE__); \ + fprintf Y; fprintf(debug_log,"\n"); fflush(debug_log); \ + } \ + } +#else +# define my_debug(X,Y) +#endif +#ifdef DEBUG +#define my_dump(X,Y) if(DUMPLOG == D_ALL) \ + { if(dump_log != NULL) { \ + fprintf Y; fprintf(dump_log,"\n"); fflush(dump_log); \ + } \ + } +#else +# define my_debug(X,Y) +#endif diff --git a/file.c b/file.c new file mode 100755 index 0000000..b512c78 --- /dev/null +++ b/file.c @@ -0,0 +1,1340 @@ +/* File.c + this file handles most of the file i/o for the bot + loading users/protected users + parsing the data into useful info + also logging functions + as well as adding a user or removing a user + + Thanks go out to Tychy for help in modifying the method of parsing + the data into readable information. +*/ +#include +#include +#include +#define __MYFILE__ +#include "config.h" +#include "myfile.h" +int user_count=0,prot_count=0; +int killstatus=1; +char LastComm[CMDHISTORY][1024]; +extern struct aDccClient MyClient[]; + +extern int DccCtr; +extern int NOWTIME,SITE_CLONE; +extern char *SuspendChan[]; +extern time_t SuspendChanTime[]; +extern char *SuspendOper[]; +extern time_t SuspendOperTime[]; +extern char *NoGlineHost[]; +extern char *GlineHost[]; +extern char *MultiUserHost[]; +extern char *SingleUserHost[]; +extern char *operchan[]; +extern char *killchan[]; + +struct aUser *buser; +struct aHost *bhost; + +struct aGline Glines[MAXGLINES]; + +extern char buf[],sockbuf[]; +extern char *token[]; +extern int sevsck,botsck; + +FILE *logfp,*logfd=NULL; +int logstats=0; + +int load_myuser(char *filename) +{ + FILE *infile; + char line[512]; + struct aUser *tmpuser; + char *tmp; + int legit=0; + + if( (infile=fopen(filename,"r")) == NULL) return 0; + + + for(; fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + if(line[0]=='#') continue; /* comment line */ + + tmpuser = (struct aUser *) malloc(sizeof(struct aUser)); + + legit=1; + tmp=strtok(line,"!"); + if(tmp == NULL) { free(tmpuser); continue; } + tmpuser->level = atoi(tmp); + + tmp=strtok(NULL,"!"); + if(tmp == NULL) { free(tmpuser); continue; } + strcpy(tmpuser->nick,tmp); + + tmp=strtok(NULL,"!"); + if(tmp == NULL) { free(tmpuser); continue; } + strcpy(tmpuser->mask,tmp); + + tmp=strtok(NULL,"!"); + if(tmp == NULL) strcpy(tmpuser->passwd,"*"); + else strcpy(tmpuser->passwd,tmp); + + tmp=strtok(NULL,"!"); + if(tmp != NULL) strcpy(tmpuser->comment,tmp); + + tmpuser->timeout=-1; + tmpuser->vrfy=0; + + tmpuser->next=buser; + buser=tmpuser; + + } +} + +struct aUser *chklevel(char *fromhost) +{ + struct aUser *tmpuser; + + tmpuser=buser; + while(tmpuser != NULL) + { if(((tmpuser->timeout < 0) || (tmpuser->timeout > NOWTIME)) && + (!match(tmpuser->mask,fromhost))) + { + return tmpuser; + } + tmpuser=tmpuser->next; + } + return NULL; +} + +struct aUser *vrfy_oper(char *fromhost,char *passwd) +{ + struct aUser *tmpuser; + + tmpuser=buser; + while(tmpuser != NULL) + { if(((tmpuser->timeout < 0) || (tmpuser->timeout > NOWTIME)) && + (!match(tmpuser->mask,fromhost))) + { + if(!strcmp(passwd,tmpuser->passwd)) + { + return tmpuser; + } + else + { + return NULL; + } + } + tmpuser=tmpuser->next; + } + return NULL; +} + +int add_myuser(int level, char *nick, char *mask,char *passwd, time_t timeout + ,char *comment) +{ + struct aUser *tmpuser; + + tmpuser = (struct aUser *) malloc(sizeof(struct aUser)); + + strcpy(tmpuser->nick,nick); + strcpy(tmpuser->mask,mask); + if((passwd != NULL) && (strlen(passwd)<9)) strcpy(tmpuser->passwd,passwd); + else strcpy(tmpuser->passwd,"*"); + if(comment != NULL) strcpy(tmpuser->comment,comment); + else (strcpy(tmpuser->comment,nick)); + tmpuser->vrfy=0; + tmpuser->level = level; + tmpuser->timeout=timeout; + tmpuser->chanlist=NULL; + + tmpuser->next=buser; + buser=tmpuser; +} + +int chkchanlevel(char *fromhost,char *channel) +{ + struct aUser *tmpuser; + + tmpuser=buser; + while(tmpuser != NULL) + { if(((tmpuser->timeout < 0) || (tmpuser->timeout > NOWTIME)) && + (!match(tmpuser->mask,fromhost)) && (*tmpuser->nick == '#') && + (!match(tmpuser->nick,channel))) + { + return tmpuser->level; + } + tmpuser=tmpuser->next; + } + return NULL; +} + +startlog() +{ + if((logfp = fopen(LOGFILE,"a")) == NULL) logstats = 0; + else logstats = 1; + if((logfd = fopen(FLOODFILE,"a")) == NULL)logfd=NULL; +} + +writelogtel(char *cbuf) +{ + time_t timer; + struct tm *tblock; + char temp[512]; + char datime[64]; + int j,k; + if(!logstats) return; + k=chk_num(0); + strcpy(temp,""); + for(j=3;j%s %s",cbuf,asctime(tblock))) fflush(logfp); +} + +writelog(char *fromhost) +{ + time_t timer; + struct tm *tblock; + char temp[512]; + char datime[64]; + int j,k; + if(!logstats) return; + if((token[3]) && (!strcmp(token[3],":dccwall"))) return; + if((token[3]) && (!strcmp(token[3],":wall"))) return; + if((token[3]) && (!strcmp(token[3],":dmsg"))) return; + if((token[3]) && (!strcmp(token[3],":dlist"))) return; + if((token[3]) && (!strcmp(token[3],":dwho"))) return; + if((token[3]) && (!strcmp(token[3],":umode"))) return; + strcpy(temp,token[3]); + for(j=4;token[j];j++) { + strcat(temp," "); + strcat(temp,token[j]); + } + if(fprintf(logfp,"%ld %s->%s %s\n",NOWTIME,fromhost,token[0], + temp)) fflush(logfp); + return; +} + +catfile(char *filename,char *botname) +{ + FILE *catfp; + char line[80]; + if( (catfp = fopen(filename,"r")) == NULL) { + sprintf(buf,":%s Privmsg %s :%s -- NOT AVAILABLE\n",botname, + token[0],filename); + writeln(sevsck,buf); + fclose(catfp); + return; + } + for(;fgets(line,80,catfp);) { + sprintf(buf,":%s NOTICE %s :%s\n",botname,token[0],line); + writeln(sevsck,buf); + } + fclose(catfp); + return; +} + +record_kill() +{ +FILE *fpkill; +char temp[600]; +time_t timer; +struct tm *tmblock; +int i=0,k; + if(!killstatus) return; + temp[0]='\0'; + k=chk_num(0); + for(i=0;i%s %s",temp,asctime(tmblock))) + fflush(logfp); + if( (fpkill=fopen(KILLFILE,"r"))==NULL) return; + fclose(fpkill); + if( (fpkill=fopen(KILLFILE,"a"))==NULL) return; + fprintf(fpkill,"KILL %s %s",temp,asctime(tmblock)); + fclose(fpkill); +} + +writelogflood(char *cbuf) +{ + time_t timer; + struct tm *tblock; + char temp[512]; + char datime[64]; + int j,k; + if(logfd==NULL) return; + k=chk_num(0); + strcpy(temp,""); + for(j=3;jlevel,tmpuser->nick,tmpuser->mask, + (tmpuser->timeout == -1)?-1:tmpuser->timeout - NOWTIME); + writeln(sck,mybuf); + tmpuser=tmpuser->next; + } +return( 0); +} + + +int destroy_myuser() +{ struct aUser *tmpuser; + while(buser != NULL) + { + tmpuser=buser; + buser=buser->next; + free(tmpuser); + } + +} + +int remove_myuser( char *mask) +{ struct aUser *tmpuser,*tmp2user; + + tmp2user=buser; + if(tmp2user == NULL) return; + + if(!strcasecmp(buser->mask,mask)) + { buser=buser->next; + destroy_banlist(tmp2user); + free(tmp2user); + return 1; + } + tmpuser = buser->next; + while(tmpuser != NULL) + { if( !strcasecmp(tmpuser->mask,mask)) + { tmp2user->next=tmpuser->next; + destroy_banlist(tmpuser); + free(tmpuser); + return 1; + } + tmp2user=tmpuser; + tmpuser=tmpuser->next; + } + + +} + +int timeout_myuser() +{ struct aUser *tmpuser,*tmp2user; + + tmp2user=buser; + if((tmp2user == NULL) || (tmp2user->next == NULL)) return; + + if((buser->timeout > 0) && (buser->timeout < NOWTIME)) + { buser=buser->next; + destroy_banlist(tmp2user); + free(tmp2user); + return 1; + } + + tmpuser = buser->next; + while(tmpuser != NULL) + { if((tmpuser->timeout > 0) && (tmpuser->timeout < NOWTIME)) + { tmp2user->next=tmpuser->next; + destroy_banlist(tmpuser); + free(tmpuser); + + tmpuser=tmp2user->next; + continue; + +/* return 1; +*/ + } + tmp2user=tmpuser; + tmpuser=tmpuser->next; + } + +} + +int showbans(char *target,int sck) +{int i,j; + struct aUser *tmpuser; + char mybuf[512]; + char lev[10]; + + tmpuser=buser; + sprintf(mybuf,":%s NOTICE %s :%3.3s %6s %30.30s %s %s\n", + CHANSVR,target,"LEV","TIME","ORIGON","MASK","COMMENT"); + writeln(sck,mybuf); + sprintf(mybuf, + ":%s NOTICE %s :===================================================\n", + CHANSVR,target); + writeln(sck,mybuf); + while(tmpuser != NULL) + { + if(tmpuser->level <= 0) + { + if(tmpuser->level == GLINE) strcpy(lev,"GLINE"); + else if(tmpuser->level == AUTO_BAN) strcpy(lev,"AUTOBAN"); + else if(tmpuser->level == RGLINE) strcpy(lev,"RGLINE"); + else sprintf(lev,"%3.3d",tmpuser->level); + + sprintf(mybuf,":%s NOTICE %s :%2.2s %6.6ld %30.30s %s %s\n", + CHANSVR,target,lev, + (tmpuser->timeout == -1)?-1:tmpuser->timeout - NOWTIME, + tmpuser->nick,tmpuser->mask,tmpuser->comment); + writeln(sck,mybuf); + } + tmpuser=tmpuser->next; + } + sprintf(mybuf, + ":%s NOTICE %s :===================================================\n", + CHANSVR,target); + writeln(sck,mybuf); + +return( 0); +} + + +int add_chan(char *name,struct aUser *myuser) +{ struct aChan *tmpchan; + + myuser->numkicks++; + tmpchan=myuser->chanlist; + + while(tmpchan) + { if(!strcasecmp(tmpchan->name,name)) return 1; + tmpchan=tmpchan->next; + } + + tmpchan= (struct aChan *) malloc(sizeof(struct aChan)); + strcpy(tmpchan->name,name); + tmpchan->next = myuser->chanlist; + myuser->chanlist=tmpchan; + myuser->numbans++; + + return 1; +} + + +int destroy_banlist(struct aUser *myuser) +{ struct aChan *tmpchan; + char outbuf[512]; + + while(myuser->chanlist != NULL) + { + tmpchan=myuser->chanlist; + myuser->chanlist=myuser->chanlist->next; + + sprintf(outbuf,":chansvr MODE %s -b %s\n",tmpchan->name,myuser->mask); + writeln(sevsck,outbuf); + free(tmpchan); + myuser->numbans=0; + } + +} + +int remove_chan( char *name,struct aUser *myuser) +{ struct aChan *tmpchan,*tmp2chan; + + tmp2chan=myuser->chanlist; + if(tmp2chan == NULL) return; + + if(!strcasecmp(myuser->chanlist->name,name)) + { myuser->chanlist=myuser->chanlist->next; + /* HERE WE COULD REMOVE BAN IF WE WANT */ + myuser->numbans--; + free(tmp2chan); + return 1; + } + tmpchan = myuser->chanlist->next; + while(tmpchan != NULL) + { if( !strcasecmp(tmpchan->name,name)) + { tmp2chan->next=tmpchan->next; + myuser->numbans--; + + /* HERE WE COULD REMOVE BAN IF WE WANT */ + free(tmpchan); + return 1; + } + tmp2chan=tmpchan; + tmpchan=tmpchan->next; + } +} + +int destroy_host() +{ int i; + struct aHost *tmphost; + + for(i=0;ihost[i] != NULL) + { + tmphost=host_hashid->host[i]; + host_hashid->host[i]=host_hashid->host[i]->next; + free(tmphost); + } + +} + +int remove_host( char *mask) +{ struct aHost *tmphost,*tmp2host; + + int hostid=0; + if(host_hashid == NULL) + { host_hashid = new_hosthash(); + return 0; + } + hostid = get_hashid(mask,HOSTHASH); + tmp2host=host_hashid->host[hostid]; + if(tmp2host == NULL) return; + + if(!strcasecmp(tmp2host->hostname,mask)) + { host_hashid->host[hostid]=host_hashid->host[hostid]->next; + if(tmp2host->hostname != NULL) free(tmp2host->hostname); + free(tmp2host); + return 1; + } + tmphost = host_hashid->host[hostid]->next; + while(tmphost != NULL) + { if( !strcasecmp(tmphost->hostname,mask)) + { tmp2host->next=tmphost->next; + if(tmphost->hostname != NULL) free(tmphost->hostname); + free(tmphost); + return 1; + } + tmp2host=tmphost; + tmphost=tmphost->next; + } +} + + +int scan_host(char *hostname,int mode) +{ +#ifdef USE_TSC + struct aHost *tmphost; + + int hostid=0; + + if(host_hashid == NULL) host_hashid = new_hosthash(); + hostid = get_hashid(hostname,HOSTHASH); + tmphost=host_hashid->host[hostid]; + + while(tmphost) + { if(!strcasecmp(tmphost->hostname,hostname)) + { if(mode) tmphost->count = tmphost->count+=mode; + if(tmphost->count == 0) + { remove_host(hostname); + return 0; + } + + return tmphost->count; + } + tmphost=tmphost->next; + } + + if(!mode) return 0; + + tmphost = (struct aHost *) malloc(sizeof(struct aHost)); + tmphost->hostname = my_strcpy(hostname); + tmphost->count=mode; + + tmphost->next=host_hashid->host[hostid]; + host_hashid->host[hostid]=tmphost; + return tmphost->count; +#else + return 1; +#endif + +} + +int show_hosts(char *target,int mode) +{ struct aHost *tmphost; + int total_count=0; + int hostid=0,i; + +#ifdef USE_TSC + + for(i=0;ihost[i]; + while(tmphost) + { if(tmphost->count >SITE_CLONE) + { + if(!mode) + { sprintf(buf,":CHANSVR PRIVMSG %s :%d %s\n", + target,tmphost->count, tmphost->hostname); + writeln(sevsck,buf); + } + else + { if(check_multiconnect(tmphost->hostname)) + { sprintf(buf,":CHANSVR PRIVMSG %s :%d %s\n", + target,tmphost->count, tmphost->hostname); + writeln(sevsck,buf); + } + } + } + total_count++; + tmphost=tmphost->next; + } + } + sprintf(buf,":CHANSVR PRIVMSG %s :Total Hosts in list %d\n", + target,total_count); + writeln(sevsck,buf); + return 1; +#else + sprintf(buf,":CHANSVR PRIVMSG %s :TSC Option Not available\n",target); + writeln(sevsck,buf); +#endif +} + + +struct aHosthash *new_hosthash() +{ struct aHosthash *host_hashid; + int i; + host_hashid=(struct aHosthash *) malloc(sizeof(struct aHosthash)); + for(i=0;ihost[i]=NULL; + return host_hashid; +} + + +int read_noglines(char *filename) +{ int i=0; + char line[512]; + FILE *infile; + + if((NoGlineHost[0]!=NULL) && (*NoGlineHost[0]!='\0')) + for(i=0;*NoGlineHost[i];i++) free(NoGlineHost[i]); + + if( (infile=fopen(filename,"r")) == NULL) + { NoGlineHost[0]=strdup("\0"); + return 0; + } + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + if(line[0]=='#') continue; + NoGlineHost[i++]=strdup(line); + if(i>MAXNOGLINES-1) break; + } + + NoGlineHost[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int read_glinehost(char *filename) +{ int i=0; + char line[512]; + FILE *infile; + + if((GlineHost[0]!=NULL) && (*GlineHost[0]!='\0')) + for(i=0;*GlineHost[i];i++) free(GlineHost[i]); + + if( (infile=fopen(filename,"r")) == NULL) + { GlineHost[0]=strdup("\0"); + return 0; + } + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + if(line[0]=='#') continue; + GlineHost[i++]=strdup(line); + if(i>MAXGLINEHOST-1) break; + } + + GlineHost[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int show_agl() +{ int cnt; + + for(cnt=0;*GlineHost[cnt];cnt++) + { if(cnt>MAXGLINEHOST) break; + sprintf(buf,":%s NOTICE %s :%s\n",CHANSVR,token[0],GlineHost[cnt]); + writeln(sevsck,buf); + } + +} + +int read_mhost(char *filename) +{ int i=0; + char line[512]; + FILE *infile; + + if((MultiUserHost[0]!=NULL) && (*MultiUserHost[0]!='\0')) + for(i=0;*MultiUserHost[i];i++) free(MultiUserHost[i]); + + if( (infile=fopen(filename,"r")) == NULL) + { MultiUserHost[0]=strdup("\0"); + return 0; + } + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + if(line[0]=='#') continue; + MultiUserHost[i++]=strdup(line); + if(i>MAXGLINEHOST-1) break; + } + + MultiUserHost[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int show_mhost() +{ int cnt; + + for(cnt=0;*MultiUserHost[cnt];cnt++) + { if(cnt>MAXMHOST) break; + sprintf(buf,":%s NOTICE %s :%s\n",CHANSVR,token[0],MultiUserHost[cnt]); + writeln(sevsck,buf); + } + +} + +int read_shost(char *filename) +{ int i=0; + char line[512]; + FILE *infile; + + if((SingleUserHost[0]!=NULL) && (*SingleUserHost[0]!='\0')) + for(i=0;*SingleUserHost[i];i++) free(SingleUserHost[i]); + + if( (infile=fopen(filename,"r")) == NULL) + { SingleUserHost[0]=strdup("\0"); + return 0; + } + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + if(line[0]=='#') continue; + SingleUserHost[i++]=strdup(line); + if(i>MAXGLINEHOST-1) break; + } + + SingleUserHost[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int show_shost() +{ int cnt; + + for(cnt=0;*SingleUserHost[cnt];cnt++) + { if(cnt>MAXMHOST) break; + sprintf(buf,":%s NOTICE %s :%s\n",CHANSVR,token[0],SingleUserHost[cnt]); + writeln(sevsck,buf); + } +} + + +int storecomm(char *fromhost) +{ + char tbuf[1024]; + int loop; + + sprintf(tbuf,"%s!%s",token[0],fromhost); + + for(loop=3;token[loop];loop++) + { strcat(tbuf," "); + strcat(tbuf,token[loop]); + } + + for(loop=0;loopCMDHISTORY) num=CMDHISTORY; + + for(loop=CMDHISTORY-num;loop0)) continue; + SuspendOperTime[i]=atol(ptr); + } + else SuspendOperTime[i]=-1; + + SuspendOper[i++]=strdup(line); + if(i>MAXSUSPENDOPER-1) break; + } + + SuspendOper[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int show_suspend() +{ int cnt; + + for(cnt=0;*SuspendOper[cnt];cnt++) + { if(cnt>MAXSUSPENDOPER) break; + sprintf(buf,":%s NOTICE %s :%s %ld\n",CHANSVR,token[0],SuspendOper[cnt], + SuspendOperTime[cnt]); + writeln(sevsck,buf); + } +} + +int save_suspend(char *filename) +{ int cnt; + FILE *outfile; + + if( (outfile=fopen(filename,"w")) == NULL) return 0; + + for(cnt=0;*SuspendOper[cnt];cnt++) + { if(cnt>MAXSUSPENDOPER) break; + + if((SuspendOperTime[cnt]>0) && (SuspendOperTime[cnt]NOWTIME)) continue; + free(SuspendOper[cnt]); + SuspendOper[cnt]=strdup(mask); + SuspendOperTime[cnt]=time; + save_suspend(SUSPENDFILE); + return 0; + } + SuspendOper[cnt]=strdup(mask); + SuspendOperTime[cnt++]=time; + SuspendOper[cnt]=strdup("\0"); + save_suspend(SUSPENDFILE); + return 0; +} + + +int read_Csuspend(char *filename) +{ int i=0; + char line[512]; + FILE *infile; + char *ptr; + + if((SuspendChan[0]!=NULL) && (*SuspendChan[0]!='\0')) + for(i=0;*SuspendChan[i];i++) free(SuspendChan[i]); + + if( (infile=fopen(filename,"r")) == NULL) + { SuspendChan[0]=strdup("\0"); + return 0; + } + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + /* MASK TIME */ + if(line[0]!='#') continue; + if((ptr=strchr(line,' ')) !=NULL) + { *ptr++='\0'; + if((atol(ptr) < NOWTIME) && (atol(ptr)>0)) continue; + SuspendChanTime[i]=atol(ptr); + } + else SuspendChanTime[i]=-1; + + SuspendChan[i++]=strdup(line); + if(i>MAXSUSPENDOPER-1) break; + } + + SuspendChan[i]=strdup("\0"); + fclose(infile); + return 1; +} + +int show_Csuspend() +{ int cnt; + + for(cnt=0;*SuspendChan[cnt];cnt++) + { if(cnt>MAXSUSPENDOPER) break; + sprintf(buf,":%s NOTICE %s :%s %ld\n",CHANSVR,token[0],SuspendChan[cnt], + SuspendChanTime[cnt]); + writeln(sevsck,buf); + } +} + +int save_Csuspend(char *filename) +{ int cnt; + FILE *outfile; + + if( (outfile=fopen(filename,"w")) == NULL) return 0; + + for(cnt=0;*SuspendChan[cnt];cnt++) + { if(cnt>MAXSUSPENDOPER) break; + + if((SuspendChanTime[cnt]>0) && (SuspendChanTime[cnt]NOWTIME)) continue; + free(SuspendChan[cnt]); + SuspendChan[cnt]=strdup(mask); + SuspendChanTime[cnt]=time; + save_suspend(SUSPENDFILE); + return 0; + } + SuspendChan[cnt]=strdup(mask); + SuspendChanTime[cnt++]=time; + SuspendChan[cnt]=strdup("\0"); + save_suspend(SUSPENDFILE); + return 0; +} + +int read_glines(char *filename) +{ int i=0; + char line[512]; + FILE *infile,*outfile; + char *ptr,*cptr; + + if(Glines[0].mask!=NULL) + for(i=0;Glines[i].mask;i++) + { free(Glines[i].comment); Glines[i].comment=NULL; + free(Glines[i].nick); Glines[i].nick =NULL; + free(Glines[i].mask); Glines[i].mask =NULL; + if(i>=MAXGLINES)break; + } + + + if( (infile=fopen(filename,"r")) == NULL) + { + return 0; + } + + if(outfile) fprintf(outfile,"Debug log Opened\n"); + + for(i=0;fgets(line,511,infile);) + { line[strlen(line)-1]='\0'; + /* MASK TIME */ + if(line[0]=='#') continue; + + /* Time mask by comment */ + + + cptr=line; + if((ptr=strchr(cptr,' ')) ==NULL) continue; + *ptr++='\0'; + if((atol(cptr) < NOWTIME) && (atol(cptr)>0)) continue; + Glines[i].time=atol(cptr); + + cptr=ptr; + if((ptr=strchr(cptr,' ')) ==NULL) continue; + *ptr++='\0'; + Glines[i].mask=strdup(cptr); + + cptr=ptr; + if((ptr=strchr(cptr,' ')) ==NULL) continue; + *ptr++='\0'; + Glines[i].nick=strdup(cptr); + + Glines[i++].comment=strdup(ptr); + + if(i>=MAXGLINES) break; + } + fclose(infile); + return 1; +} + +int show_glines() +{ int cnt; + + for(cnt=0;Glines[cnt].mask;cnt++) + { if(cnt>MAXGLINES) break; + if((Glines[cnt].time >0) && (Glines[cnt].time < NOWTIME)) continue; + sprintf(buf,":%s NOTICE %s :%ld %s %s %s\n",CHANSVR,token[0], + Glines[cnt].time,Glines[cnt].mask, + Glines[cnt].nick,Glines[cnt].comment); + writeln(sevsck,buf); + } +} + +int check_glines(char *userhost) +{ int cnt; + + for(cnt=0;Glines[cnt].mask;cnt++) + { if(cnt>MAXGLINES) break; + if((Glines[cnt].time >0) && (Glines[cnt].time < NOWTIME)) continue; + if(!match(Glines[cnt].mask,userhost)) return cnt; + } + return -1; +} + + +int save_glines(char *filename) +{ int cnt; + FILE *outfile; + + if( (outfile=fopen(filename,"w")) == NULL) return 0; + + for(cnt=0;Glines[cnt].mask;cnt++) + { if(cnt>MAXGLINES) break; + + if((Glines[cnt].time>0) && (Glines[cnt].timeNOWTIME)) continue; + free(Glines[cnt].nick); + free(Glines[cnt].mask); + free(Glines[cnt].comment); + Glines[cnt].mask=strdup(mask); + Glines[cnt].nick=strdup(nick); + Glines[cnt].comment=strdup(comment); + Glines[cnt].time=time; + save_glines(GLINEFILE); + return 0; + } + if(cnt >= MAXGLINES) return 0; + Glines[cnt].mask=strdup(mask); + Glines[cnt].nick=strdup(nick); + Glines[cnt].comment=strdup(comment); + Glines[cnt].time=time; + save_glines(GLINEFILE); + return 0; +} + + +int rem_glines(char *mask) +{ int cnt,found=0; + + for(cnt=0;Glines[cnt].mask;cnt++) + { + if((Glines[cnt].timeMAXOPERCHAN-1) break; + } + fclose(infile); + return 1; +} + +int show_operchan() +{ int cnt; + + for(cnt=0;operchan[cnt];cnt++) + { if(cnt>MAXOPERCHAN) break; + sprintf(buf,":%s NOTICE %s :%s\n",CHANSVR,token[0],operchan[cnt]); + writeln(sevsck,buf); + } +} + +int save_operchan(char *filename) +{ int cnt; + FILE *outfile; + + if( (outfile=fopen(filename,"w")) == NULL) return 0; + + for(cnt=0;operchan[cnt];cnt++) + { if(cnt>MAXOPERCHAN) break; + fprintf(outfile,"%s\n",operchan[cnt]); + } + fclose(outfile); +} + +int add_operchan(char *mask) +{ int cnt; + + for(cnt=0;operchan[cnt];cnt++) continue; + if(cnt > MAXOPERCHAN-1) return 0; + operchan[cnt]=strdup(mask); + save_operchan(OPERCHANFILE); + return 0; +} + + +int rem_operchan(char *mask) +{ int cnt,loop; + + for(cnt=0;operchan[cnt];cnt++) + { if(!strcasecmp(operchan[cnt],mask) ) + { free(operchan[cnt]); + loop=cnt+1; + while(operchan[loop]) operchan[cnt++]=operchan[loop++]; + } + } + save_operchan(OPERCHANFILE); + return 0; +} + + + +int check_operchan(char *mask) +{ int cnt,loop; + + for(cnt=0;operchan[cnt];cnt++) + { if(!strcasecmp(operchan[cnt],mask) ) return cnt+1; + } + return 0; +} + +int InitOperchan() +{ int i; + for(i=0;iMAXOPERCHAN-1) break; + } + fclose(infile); + return 1; +} + +int show_killchan() +{ int cnt; + + for(cnt=0;killchan[cnt];cnt++) + { if(cnt>MAXOPERCHAN) break; + sprintf(buf,":%s NOTICE %s :%s\n",CHANSVR,token[0],killchan[cnt]); + writeln(sevsck,buf); + } +} + +int save_killchan(char *filename) +{ int cnt; + FILE *outfile; + + if( (outfile=fopen(filename,"w")) == NULL) return 0; + + for(cnt=0;killchan[cnt];cnt++) + { if(cnt>MAXOPERCHAN) break; + fprintf(outfile,"%s\n",killchan[cnt]); + } + fclose(outfile); +} + +int add_killchan(char *mask) +{ int cnt; + + for(cnt=0;killchan[cnt];cnt++) continue; + if(cnt > MAXOPERCHAN-1) return 0; + killchan[cnt]=strdup(mask); + save_killchan(KILLCHANFILE); + return 0; +} + + +int rem_killchan(char *mask) +{ int cnt,loop; + + for(cnt=0;killchan[cnt];cnt++) + { if(!strcasecmp(killchan[cnt],mask) ) + { free(killchan[cnt]); + loop=cnt+1; + while(killchan[loop]) killchan[cnt++]=killchan[loop++]; + } + } + save_killchan(KILLCHANFILE); + return 0; +} + +int check_killchan(char *mask) +{ int cnt,loop; + + for(cnt=0;killchan[cnt];cnt++) + { if(!strcasecmp(killchan[cnt],mask) ) return cnt+1; + } + return 0; +} + +int InitKillchan() +{ int i; + for(i=0;i +#include +#include +#include "config.h" +extern char *token[],buf[]; +extern int sevsck,botsck; + + +do_ushelp(int sck) +{int j,k,l; + char filename[512]; + k=chk_num(0); + if(k > 10) return 0; + *token[0]++; + if (k > 3) { + *token[3]++; + strcpy(filename,HELPPATH); + + if(k==4) { + if(!match(token[3],"ON")) { + strcat(filename,"/ON/ON"); + catfile(filename,USHELP); + return; + } + else if(!strcmp(token[3],"?")) { + strcat(filename,"/helplist"); + catfile(filename,USHELP); + return; + } + else if(!match(token[3],"ALAIS")) { + strcat(filename,"/ALIAS/ALIAS"); + catfile(filename,USHELP); + return; + } + else if(!match(token[3],"FAQ")) { + strcat(filename,"/FAQ/FAQ"); + catfile(filename,USHELP); + return; + } + + } + + for(j=3;j 10) { sprintf(filename,"%s/JOIN",HELPPATH); + return; } + if (k > 3) { + *token[3]++; + strcpy(filename,HELPPATH); + + if(k==4) { + if(!match(token[3],"ON")) { + strcat(filename,"/ON/ON"); + catfile(filename,IRCHELP); + return; + } + else if(!strcmp(token[3],"?")) { + strcat(filename,"/helplist"); + catfile(filename,IRCHELP); + return; + } + else if(!match(token[3],"ALAIS")) { + strcat(filename,"/ALIAS/ALIAS"); + catfile(filename,IRCHELP); + return; + } + else if(!match(token[3],"FAQ")) { + strcat(filename,"/FAQ/FAQ"); + catfile(filename,USHELP); + return; + } + } + + for(j=3;j 500) return; + strcat(filename,token[j]); + if((strchr(filename,';')) || (strchr(filename,'|'))) + return; + } + + for(l=0;l 4) && (!match(token[3],":help"))) { + strcpy(filename,"HELP/"); + + if(k=5) + if(!match(token[4],"ON")) strcpy(filename,"ON/ON"); + else if(!match(token[4],"ALAIS")) strcpy(filename,"ALIAS/ALIAS"); + else if(!match(token[4],"FAQ")) strcpy(filename,"FAQ/FAQ"); + else strcat(filename,token[4]); + + printf("filename for help -- %s\n",filename); + for(l=0;l +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef SIGTSTP +#include +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +int PORTNUM = PORT,newsockfd,level; +int NUMUSERS=0; /* counter of users logged in */ +int REFPROCESS=0; +char buf[512],*hostname; +char *Serv; +char tempp[512]; +char sockbuf[512],*sptr; +char loginname[20]; + +extern char *linetok[]; /* from socketc. */ +extern int USEIDENT; /* from socket.c */ +extern char *get_server(char *fromhost); /* from socket.c */ + +/* WARNING:THIS MUST NOT BE CHANGED... ELSE STRANGE THINGS SEEM TO HAPPEN */ +#define SOCKLINK 9219423 +#define VERSION "TELCLIENT_1.8" + +void handle_kids() +{int pid; + +#ifdef OSF1 + union wait *status; + status = (union wait *)malloc(sizeof(long)); + + while( (pid = wait3(status,WNOHANG, (struct rusage *)0)) > 0) { } + +#else + + union wait status; + while( (pid = wait3(&status,WNOHANG, (struct rusage *)0)) > 0) { } + +#endif /* OSF1 */ + + NUMUSERS--; +} + + +main(argc,argv) +int argc; +char **argv; +{ int m,j,sockfd,insockfd,retlen,retval,outfd,infd,i,route; + struct sockaddr_in sockst,insock; + struct hostent *hp; + int opt=1; + struct sockaddr_in from; + int fromlen; + char hostid[255],hosthld[255]; + + signal(SIGCLD,handle_kids); + if(BACKGROUND) goto_bg(); + + + if(argc > 1) { /* process command line options */ + if(*argv[1] == '-') { + *argv[1]++; + if(*argv[1]=='p') + if(atoi(argv[2])>6000) PORTNUM = atoi(argv[2]); + } + } + + if ((sockfd=socket(AF_INET,SOCK_STREAM,0))<0) { + perror("socked"); + exit(1); + } + if(!BACKGROUND) printf("GOT SOCKET %d\n",sockfd); +#ifdef SO_REUSEADDR + if (setsockopt(sockfd,SOL_SOCKET, SO_REUSEADDR,&opt,sizeof(opt)) <0) + { exit(-1); } +#endif + + sockst.sin_family=AF_INET; + sockst.sin_addr.s_addr=INADDR_ANY; + sockst.sin_port=htons(PORTNUM); + + if ((bind(sockfd,(struct sockaddr *)&sockst,sizeof(sockst)))<0) { + perror("bind"); + exit(1); + } + if(!BACKGROUND) printf("BIND SOCKET Complete\n"); + + if ((listen(sockfd,1))<0) { + perror("listen"); + exit(1); + } + if(!BACKGROUND) printf("Listening for connections\n"); + + while(1) + { if ((newsockfd=accept(sockfd,(struct sockaddr *) 0,(int *) 0))<0) + { + continue; + /* will receive a sig from dying children */ + } + if(!BACKGROUND) printf("GOT CONNECTION %d\n",newsockfd); + + if (!fork()) + { + close(sockfd); + + do_menu(newsockfd); + close(newsockfd); + exit(0); + } + close(newsockfd); + } +} + +int bbs_cat(sck,filename) +int sck; +char *filename; +{ +FILE *fp; +char *sbuf; +char line[512],command[512]; + if ( (fp = fopen(filename,"r")) == NULL) + return 0; + for(; ;) { + if(fgets(line,80,fp) == NULL) { fclose(fp); return 1; } + if(write(sck,line,strlen(line)) != strlen(line)) { + fclose(fp); return 1; } + if(write(sck,"",0) != 0) { + fclose(fp); return 1; } + } +} + +int bbs_pcom(sck,command) +int sck; +char *command; +{ +FILE *fp; +char *sbuf; +char line[512]; + if ( (fp = popen(command,"r")) == NULL) + return 0; + for(; ;) { + if(fgets(line,80,fp) == NULL) { pclose(fp); return 1; } + if(write(sck,line,strlen(line)) != strlen(line)) { + pclose(fp); return 1; } + if(write(sck,"",0) != 0) { + pclose(fp); return 1; } + } +} +int bbs_grep(sck,filename) +int sck; +char *filename; +{ +FILE *fp; +int i; +char *sbuf,*token[256]; +char line[512],command[512]; + strcpy(line,sockbuf); + + token[i=0]=strtok(sockbuf," "); + while(token[++i]=strtok(NULL, " ")); token[i]=NULL; + + if(i < 1) return 0; + + sprintf(command,"%s -i %s %s",GREPCOM,token[0],filename); + + bbs_pcom(sck,command); +} + +int bbs_tail(sck,filename) +int sck; +char *filename; +{ +FILE *fp; +int i; +char *sbuf,*token[256]; +char line[512],command[512]; + strcpy(line,sockbuf); + + token[i=0]=strtok(sockbuf," "); + while(token[++i]=strtok(NULL, " ")); token[i]=NULL; + + if(i < 1) return 0; + + sprintf(command,"%s -50 %s",TAILCOM,filename); + + bbs_pcom(sck,command); +} + +goto_bg() +{ +register int child,fd; +#ifdef SUN + fclose(stdin); fclose(stdout); fclose(stderr); +#else + close(0); close(1); close(2); +#endif + + if(getppid() == 1) goto out; + +#ifdef SIGTTOU + signal(SIGTTOU,SIG_IGN); +#endif +#ifdef SIGTTIN + signal(SIGTTIN,SIG_IGN); +#endif +#ifdef SIGTSTP + signal(SIGTSTP,SIG_IGN); +#endif + + if( (child =fork()) < 0) + perror("fork"); + else if (child > 0) + exit(0); + +#ifdef SIGTSTP + if (setpgrp(0,getpid()) == -1) + perror("SETGROUP"); + + if( (fd = open("/dev/tty",O_RDWR)) >= 0) { + ioctl(fd, TIOCNOTTY, (char *)NULL); + close(fd); + } +#else + if(setpgrp() == -1) + perror("set group"); + + signal(SIGHUP,SIG_IGN); + + if( (child = fork()) < 0) + perror("cant fork"); + else if (child > 0) + exit(0); +#endif + +out: + for(fd=0;fd -- scans log file for occurances of 'word'\n"); + writeln(sckfd," ==================================================\n"); + + writeln(sckfd,"\nEnter Choice: (press return when done) :"); + readcom(sckfd,10); + if(strlen(sockbuf) < 1){ close(sckfd); exit(0); } + + if(!strncasecmp(sockbuf,"tail",4)) bbs_tail(newsockfd,DATAFILE); + else if(!strncasecmp(sockbuf,"all",3)) bbs_cat(newsockfd,DATAFILE); + else bbs_grep(newsockfd,DATAFILE); + +} diff --git a/logsrv/com.c b/logsrv/com.c new file mode 100644 index 0000000..c53cf2b --- /dev/null +++ b/logsrv/com.c @@ -0,0 +1,14 @@ +#include +#include "config.h" + +extern char *sptr,sockbuf[512]; + +/* i kept this seperate for ease in adding future commands. */ +void bbs_com(sck) +int sck; +{ + if(!match(sockbuf,"irc")) irc(sck,0); + else irc(sck,0); + return; +} + diff --git a/logsrv/config.h b/logsrv/config.h new file mode 100755 index 0000000..955ea04 --- /dev/null +++ b/logsrv/config.h @@ -0,0 +1,26 @@ +/* SYSTEM SPECIFIC CONFIGURATIONS */ +/* ONLY ONE OF THE FOLLOWING MAY BE DEFINED */ + +#undef ULTRIX /* this should work for most systems */ +#define OSF1 /* use this on DEC alpha machines */ +#undef NEED_SETENV /* use this if your system doesnt support setenv() */ +#define SUN + + /* list of servers for client */ +/* defualt port all ports must be > 6000 if specified from commandline */ +#define PORT 9500 +#define DATAFILE "/ecn/ecnstf0/danny/dvmitche/uworld/Uworld.log" +#define GREPCOM "/usr/ucb/grep" +#define TAILCOM "/usr/ucb/tail" + +#define MAXLINE 512 +#define TRUE 1 +#define FALSE 0 +#define BACKGROUND 1 /* +-integer for background */ + +#ifdef SUN +#ifndef NEED_SETENV +#define NEED_SETENV +#endif + +#endif diff --git a/logsrv/socket.c b/logsrv/socket.c new file mode 100644 index 0000000..3dd7f20 --- /dev/null +++ b/logsrv/socket.c @@ -0,0 +1,144 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +extern char buf[512]; +extern char sockbuf[512],*sptr; +extern int PORTNUM; +extern int level; + + +char *linetok[256]; +int USEIDENT= 0; +int call_socket(hostname,portnum) + char *hostname; + int portnum; +{ struct sockaddr_in sa; + struct hostent *hp; + int a, s; + if((hp=gethostbyname(hostname))==NULL) { + errno=ECONNREFUSED; + return(-1); } + bzero(&sa, sizeof(sa)); + bcopy(hp->h_addr, (char *)&sa.sin_addr, hp->h_length); + sa.sin_family = hp->h_addrtype; + sa.sin_port = htons((u_short)portnum); + if((s=socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) return(-1); + if(connect(s,(struct sockaddr *) &sa, sizeof(sa)) < 0) { + close(s); + return(-1); } + return(s); +} + +int readln(int sckfd) +{ int i=0,valid=1; char c; +while(valid) { + if(read(sckfd,&c,1)<1) return(0); + if(i<511 && c != '\n') sockbuf[i++]=c; else valid=0; } +sockbuf[i]='\0'; return(1); +} + +int writeln(sckfd,outbuf) +int sckfd; +char *outbuf; +{ int to=0; +if(write(sckfd, outbuf, strlen(outbuf)) < to ) + return(0); +return(1); +} + +int readcom(sck,tout) +int sck; +int tout; +{ +int sok; +time_t time_in,time_out; +int dumb = 1; +fd_set readfs; +struct timeval *zimeout; +time_in=time(NULL); +while(1) { + time_out = time(NULL); + if(time_out - time_in > tout) return 0; + FD_ZERO(&readfs); + FD_SET(sck,&readfs); + if(select(FD_SETSIZE, &readfs, NULL, NULL,(dumb ? NULL : zimeout))) { + + if(FD_ISSET(sck,&readfs)) { + if(!BACKGROUND) puts("READING REPLY"); + sok = readln(sck); + if (sok) { + sptr=sockbuf; + *(sptr+strlen(sockbuf)-1)='\0'; + return 1; + } } + } + } +} + + + + +int do_auth(hostname,sockfd) +char *hostname; +int sockfd; +{ int authfd,ulen,tlen,lcnt,ct; + struct sockaddr_in sock,us,them; + + writeln(sockfd,"Checking your identification\n"); + + if( (authfd=call_socket(hostname,113)) < 0) /* host not running identd */ + { + USEIDENT=0; + sprintf(buf,"[%d] [%s] You should ask your sysadmin to instal identd\n", + authfd,hostname); + writeln(sockfd,buf); + return 0; + } + + if(getsockname(sockfd,(struct sockaddr *)&us,&ulen)) + { if(!BACKGROUND) puts("getsockname failed"); + USEIDENT=0; + return 0; + } + if(getpeername(sockfd,(struct sockaddr *)&them,&tlen)) + { if(!BACKGROUND) puts("getpeername failed"); + USEIDENT=0; + return 0; + } + + sprintf(buf,"%u,%u \r\n", + (unsigned int) ntohs(them.sin_port), + (unsigned int) PORTNUM); + + writeln(authfd,buf); + writeln(sockfd,"CHECKING IDENTD\n"); + + readcom(authfd,15); + if(!BACKGROUND) puts(sockbuf); + + linetok[lcnt=0]=strtok(sockbuf," "); + while(linetok[++lcnt]=strtok(NULL, " ")); linetok[lcnt]=NULL; + + if((lcnt > 7) && (!strcmp(linetok[4],"USERID"))) + { USEIDENT = 1; + sprintf(buf,"Greetings %s@%s, Welcome to our system\n",linetok[8], + hostname); + writeln(sockfd,buf); + if(!BACKGROUND) + { printf("GOT IT %s %d\n",linetok[8],lcnt); + } + } + else USEIDENT = 0; + close(authfd); +} diff --git a/map.c b/map.c new file mode 100644 index 0000000..ee327f1 --- /dev/null +++ b/map.c @@ -0,0 +1,125 @@ +#include "config.h" + +#include +#include +#include + + +struct aServer { + struct aServer *next; + struct aServer *down; + char *name; + +}; + +struct aServData { + int count; + int list; +}; + +struct aServer *MYuplink=NULL; +struct aServData ServerData; + + +int LinkServer(char *server, char *uplink) +{ + struct aServer *ServerID; + + ServerID=newserver(); + ServerID->name=strdup(server); + + if(MYuplink==NULL) + { MYuplink=ServerID; + ServerData.list=1; + return 1; + } + return (AddServer(ServerID,uplink,&MYuplink)); +} + +struct aServer *newserver() +{ struct aServer *newserver; + + newserver= (struct aServer *) calloc(1,sizeof(struct aServer)); + ServerData.count++; + + return newserver; +} + + +int AddServer(struct aServer *newserver,char *uplink,struct aServer **Startid) +{ + struct aServer **UplinkID; + struct aServer *ServerID; + + Uplinkid=FindServer(uplink,Startid); + if(Uplinkid == NULL) return 0; /* ERROR HERE */ + ServerID= *Uplinkid; + + /* This is a DOWNLINK of the said server.. + ** Downlinks go DOWN ->next -> next -> next ... + */ + if( ServerID->down == NULL) + { ServerID->down = newserver; + ServerData.list++; + return 1; + } + ServerID=Serverid->down; + while(ServerID->next !=NULL) ServerID=ServerID->next; + ServerID->next=newserver; + ServerData.list++; + return 1; +} + +struct aServer **FindServer(char *name,struct aServer **Startid) +{ + struct aServer *SearchID; + struct aServer **ServerID; + + if(!StartID ) return NULL; + + SearchID= *Startid; + + if(!strcasecmp(name,StartID->name)) return Startid; + + /* This is not the server we are looking for */ + ** First scan NEXT as far as we can... Then try Down + ** We are not modifying the information in the structures + ** in this calls + */ + + if( (ServerID=FindServer(name,&(SearchID->next))) != NULL) return ServerID; + if( (ServerID=FindServer(name,&(SearchID->down))) != NULL) return ServerID; + + return NULL; +} + + +void dumpsubmap(struct aServer *server) +{ + static char prefix[80]=""; + static int offset=0; + char localbuf[512]; + + if(server==NULL) + return; + + if(server->next==NULL) + { sprintf(localbuf,"PRIVMSG WildThang :%s`-%s",prefix,server->name); + } + else + { sprintf(localbuf,"PRIVMSG WildThang :%s|-%s",prefix,server->name); + } + writeln(botsck,localbuf); + + + if(server->next!=NULL) + strcpy(prefix+offset,"| "); + else + strcpy(prefix+offset," "); + + offset+=2; + dumpsubmap(server->down); + offset-=2; + prefix[offset]='\0'; + dumpsubmap(server->next); +} diff --git a/match.c b/match.c new file mode 100755 index 0000000..1e81854 --- /dev/null +++ b/match.c @@ -0,0 +1,41 @@ +/************************************ + * match(string1,string2) * + * wild card matching routine * + * origionally for Ultima1.0 * + * Written by WildThang * + * dvmitche@midway.ecn.uoknor.edu * + * based on ideas by hendrix * + ************************************/ + +/* int do_match(char *string1,char *string2) + returns 0 if match + returns 1 if do not match */ + + +#include +#include + +int match(char *check,char *orig) +{ + while(*check == '*' || + tolower(*check)==tolower(*orig) || + *check == '?') + if(*check == '*') + if(*++check) { + while(*orig) + if(!match(check,orig++)) return 0; + return 1; + } + else + return 0; + else if (!*check) + return 0; + else if (!*orig) + return 1; + else { + ++check; + ++orig; + } + return 1; +} + diff --git a/myfile.h b/myfile.h new file mode 100644 index 0000000..f52c372 --- /dev/null +++ b/myfile.h @@ -0,0 +1,49 @@ +#define HOSTHASH 4000 +#ifdef __MYFILE__ + struct aHosthash *host_hashid=NULL; +#else + extern struct aHosthash *host_hashid; +#endif + +struct aGline { + char *mask; + char *nick; + time_t time; + char *comment; +}; + +struct aUser { + struct aUser *next; + struct aChan *chanlist; + int level; + int numbans; + int numkicks; + char mask[150]; + char nick[150]; + time_t timeout; + int vrfy; + char passwd[10]; + char comment[512]; +}; + +struct aHost { + struct aHost *next; + char *hostname; + int count; +}; + +struct aHosthash { + struct aHost *host[HOSTHASH]; +}; + +struct aChan { + struct aChan *next; + char name[255]; +}; + +struct aUser *chklevel(char *fromhost); +struct aUser *vrfy_oper(char *fromhost,char *passwd); +char *my_strcpy(char *inp); +int my_strfree(char *inp); +struct aHosthash *new_hosthash(); + diff --git a/nicklist.c b/nicklist.c new file mode 100644 index 0000000..663af9d --- /dev/null +++ b/nicklist.c @@ -0,0 +1,1579 @@ +/***********************************************************/ +/* Telnet3d (the single process telnet service) written by +/* (dvmitche@nssl.uoknor.edu) ALL RIGHTS RESERVED. +/* +/* Duplication of this code is not permitted without explicit +/* aproval from the authors (dvmitche@nssl.uoknor.edu). +/* +/* This project was designed to be used on UNDERNET IRC ONLY. +/* No exceptions to this without explicit permission from the +/* authors (dvmitche@nssl.uoknor.edu) +/* +/* Special Thanks for your ideas and support with this project. +/* go out to: +/* mandar@vinson.ecn.uoknor.edu +/* NOTE: dvmitche@nssl.uoknor.edu is now danny@chatsystems.com +/*************************************************************/ + + +#define __NICKLIST__ +#include +#include +#include +#include +#include "nicklist.h" +#include "debug.h" +#include "config.h" +#include "clones.h" +#include "myfile.h" + +struct aFloodProtect *FloodProt=NULL; +extern struct aGline Glines[]; +extern char UPLINK[]; +extern time_t S_TIME; +extern int NETBURST; +extern char *NoGlineHost[],*GlineHost[],buf[]; +extern char *MultiUserHost[],*SingleUserHost[]; +extern char *token[],controlbot[]; +extern int sevsck,botsck; +extern int MAX_SESSIONS,MAX_ALLOWED; +extern int SITE_CLONE,WARNCLONE; +extern time_t NOWTIME; +extern int KILL_NICKFLOOD,num_servs,UID_GLINE; +extern int DO_AUTOKICK,DO_CORE; +extern char server_list[][100]; +extern int lonum,hinum,dignum,LOGHOST,nohelp,LOG_TSC,ACT_ANAL,STRICT_SCAN, + KICK_ASS,AUTOGLINE,IPSCAN,ANAL_GLINE,NO_TSC,SECURE_OPER,SCAN_CLONES; +extern int LOGJOIN; + +char *cln[]={"TSC","CLN","UID","AGL",""}; + +char *mynicks[]={"Com1","Com2","Lpt1","Lpt2",""}; + +char *operchan[MAXOPERCHAN],*killchan[MAXOPERCHAN]; + +char *ircnames[]= {" pig"," clone",""}; +int IS_CLONE=0,DO_GLINE=0; +char *logjoin[]={ "" }; + +char *loghost[]={ "*fallline*","" }; + +int open_debug() +{ if( (debug_log = fopen(DEBUG_LOGFILE,"a")) == NULL) return 0; + return 1; +} + +struct nick_hash *new_nick_hash() +{ struct nick_hash *nick_hashid; + int i; + my_debug((D_TRACE ), + (debug_log, "new_nick_hash: creating new nick table ") ); + nick_hashid=(struct nick_hash *) malloc(sizeof(struct nick_hash)); + MEM_nickhash_total += sizeof(struct nick_hash); + for(i=0;ihost[i]=NULL; + return nick_hashid; +} + +struct nicklist *new_nicklist() +{ struct nicklist *nicklistid; + nicklistid=(struct nicklist *) malloc(sizeof(struct nicklist)); + MEM_nicklist_total+= sizeof(struct nicklist); + nicklistid->next = NULL; + nicklistid->prev = NULL; + nicklistid->hops=0; + nicklistid->level = 0; + nicklistid->oper = 0; + nicklistid->vrfy = 0; + nicklistid->ts=0; + nicklistid->name = NULL; + nicklistid->uname=NULL; + nicklistid->iphost=NULL; + nicklistid->host=NULL; + nicklistid->serv=NULL; + nicklistid->umode=0x0; + nicklistid->nickchange=0; + nicklistid->lastchange=NOWTIME; + MEM_nicklist_cnt++; + my_debug(D_NICKLIST, + (debug_log, "new_nicklist: 0x%X defined:%d memory:%ld", + nicklistid,MEM_nicklist_cnt,MEM_nicklist_total)); + return nicklistid; +} + +int add_nickhash(nicklistid) +struct nicklist *nicklistid; +{ int hostid=0,i,glineID; + int hostcount=0; + char mybufr[512]; + time_t timer; + struct tm tblock; + struct aUser *myuser; + int level; + char local_buf[512]; + + if(nick_hashid == NULL) nick_hashid = new_nick_hash(); + + hostid = get_hashid(nicklistid->name,MAXNICKHASH); + + my_debug((D_TRACE | D_NICKLIST), + (debug_log, "add_nickhash: %d for 0x%X (%s)", + hostid, nicklistid,nicklistid->name)); + + if((!strcasecmp(nicklistid->name,"uworld")) && + (strncmp(nicklistid->host,MYHOST,4))) + { sprintf(mybufr,"KILL %s FAKE UWORLD\n",nicklistid->name); + writeln(sevsck,mybufr); + botsck=bot_login(UPLINK); + return 1; + } + +#ifdef JUPE_BUGS + for(i=0;*mynicks[i];i++) + if(!strcasecmp(nicklistid->name,mynicks[i])) + { nohelp=0; + makehelp(sevsck,mynicks[i],"!JUPE This is an illegal nick on this net"); + return 1; + } + +#endif + +#ifdef JUPE_CHANSERVICE + if( (!strcasecmp(nicklistid->name,"X")) && + (strcasecmp(nicklistid->host,"undernet.org")) ) + { /* FAKE SERVICE */ + nohelp=0; + makehelp(sevsck,nicklistid->name,"!JUPE for channel service"); + return 1; + } +#endif + /* ADDED FOR GLINE SUPPORT 7/3/96 + */ + if(!NETBURST) + { sprintf(local_buf,"%s@%s",nicklistid->uname,nicklistid->host); + myuser = chklevel(local_buf); + if(myuser != NULL) level=myuser->level; + else level = 0; + nicklistid->level = level; + + if((glineID=check_glines(local_buf)) !=-1) + { + sprintf(local_buf,"KILL % :G-Lined\n",nicklistid->name); + writeln(sevsck,local_buf); + sprintf(local_buf,"GLINE %s +*%s %ld :%s\n", + nicklistid->serv,Glines[glineID].mask, + Glines[glineID].time-NOWTIME,Glines[glineID].comment); + writeln(sevsck,local_buf); + myfree_nicklist(nicklistid); + return 1; + } + } + /* END OF GLINE SUPPORT + */ + +#ifdef REPORT_BADNICK + if(check_floodbot(nicklistid->name)) + { + sprintf(mybufr,":CHANSVR PRIVMSG #uworld.floods :BN: %s!%s@%s %s\n", + nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->serv); + writeln(sevsck,mybufr); + } +#endif + + if(LOGHOST) + for(i=0;*loghost[i];i++) + { if((!match(loghost[i],nicklistid->host)) || + (!match(loghost[i],nicklistid->uname)) || + (!match(loghost[i],nicklistid->name))) + { + tblock=*localtime(&nicklistid->ts); + sprintf(mybufr,"%s!%s@%s %s %s", + nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->serv,asctime(&tblock)); + add_logfile(mybufr,"USERS.loghost"); + break; + } + } + + if(nick_hashid->host[hostid] == NULL) nick_hashid->host[hostid] = nicklistid; + else + { nicklistid->prev=NULL; + nicklistid->next = nick_hashid->host[hostid]; + nick_hashid->host[hostid]->prev = nicklistid; + nick_hashid->host[hostid] = nicklistid; + } + MEM_nicklist_used++; + + my_debug((D_NICKLIST | D_MEMORY), + (debug_log, + "add_nicklist: [0x%X] 0x%X name:%s (%s@%s) sck:%d hop:%d ts:%ld, <%d>", + &nick_hashid->host[hostid], + nicklistid,nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->sck,nicklistid->hops,nicklistid->ts,MEM_nicklist_used)); + + my_debug(D_MEMORY, + (debug_log,"add_nickhash: 0x%X [%s] --> --> 0x%X [%s]", + nicklistid->prev,(nicklistid->prev != NULL)? nicklistid->prev->name : "null", + nicklistid->next,(nicklistid->next != NULL)? nicklistid->next->name : "null") + ); + + return 1; +} + +int remove_nicklist(nicklistid) +struct nicklist *nicklistid; +{ int hostid=0; + + hostid= get_hashid(nicklistid->name,MAXNICKHASH); + + my_debug((D_TRACE | D_NICKLIST), + (debug_log, "remove_nicklist:[0x%X] 0x%X nicklist %d %s", + &nick_hashid->host[hostid], + nicklistid,hostid,nicklistid->name)); + + my_debug(D_MEMORY, + (debug_log,"remove_nicklist: 0x%X [%s] --> --> 0x%X [%s]", + nicklistid->prev,(nicklistid->prev != NULL)? nicklistid->prev->name : "null", + nicklistid->next,(nicklistid->next != NULL)? nicklistid->next->name : "null") + ); + + if(nicklistid == nick_hashid->host[hostid]) + { + nick_hashid->host[hostid]= nicklistid->next; + if(nick_hashid->host[hostid] != NULL) + nick_hashid->host[hostid]->prev = NULL; + } + else + { if((nicklistid->prev != NULL) && (nicklistid->prev->next == nicklistid)) + nicklistid->prev->next = nicklistid->next; + else my_debug(D_MEMORY, + (debug_log,"remove_nicklist: WARNING prev/next error in 0x%X", + nicklistid) ); + if((nicklistid->next!=NULL) && (nicklistid->next->prev == nicklistid)) + nicklistid->next->prev = nicklistid->prev; + else my_debug(D_MEMORY, + (debug_log,"remove_nicklist: WARNING next/prev error in 0x%X [0x%X]", + nicklistid,(nicklistid->next==NULL)? 0 : nicklistid->next) ); + } + + /* ADDED for HOSTCOUNT SUPPORT 7/27/96 + ** this is used to simply remove a user when they exit. + */ +#ifdef USE_TSC + if(SCAN_CLONES) scan_host(nicklistid->host,-1); +#endif + + /* Recall: uworld will NOT have info on a nick for its own 'X' + */ + + if(!strcasecmp(nicklistid->name,"X")) + { nohelp=0; + makehelp(sevsck,"X","!JUPE for channel service"); + } + if(!strcasecmp(nicklistid->name,"W")) + { nohelp=0; + makehelp(sevsck,"W","!JUPE for channel service"); + } + + + MEM_nicklist_used--; + my_debug((D_NICKLIST), + (debug_log,"remove_nicklist: 0x%X list:%d remain:%d Memory:%ld", + nicklistid,hostid,MEM_nicklist_cnt,MEM_nicklist_cnt)); + myfree_nicklist(nicklistid); +} + +int myfree_nicklist(nicklistid) +struct nicklist *nicklistid; +{ + my_debug((D_TRACE | D_NICKLIST), + (debug_log, "myfree_nicklist: 0x%X", + nicklistid)); + if(nicklistid->name != NULL) my_strfree(nicklistid->name); + if(nicklistid->uname != NULL) my_strfree(nicklistid->uname); + if(nicklistid->iphost != NULL) my_strfree(nicklistid->iphost); + if(nicklistid->host != NULL) my_strfree(nicklistid->host); + if(nicklistid->serv != NULL) my_strfree(nicklistid->serv); + free(nicklistid); + MEM_nicklist_total -= sizeof(struct nicklist); + MEM_nicklist_cnt--; + my_debug((D_NICKLIST | D_MEMORY), + (debug_log, "myfree_nicklist: remain:%d Memory:%ld", + MEM_nicklist_cnt,MEM_nicklist_total)); +} + +int nick_oper(char *nickname,int flag) +{ struct nicklist *nicklistid; + char local_buf[512]; + struct aUser *myuser; + int level; + + if( (nicklistid = find_nicklist(nickname)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_oper: WARNING: NICKNAME DESYNCH %s", + nickname)); + return 0; + } + sprintf(local_buf,"%s@%s",nicklistid->uname,nicklistid->host); + myuser = chklevel(local_buf); + if(myuser != NULL) level=myuser->level; + else level = 0; + + nicklistid->level=level; + + /* NETBURST of 2 implies that :uplink SERVER newserv + ** so its not US connecting. + */ + if((!NETBURST) || (NETBURST == 2)) + { + sprintf(local_buf,":%s PRIVMSG #uworld.floods :OPR %s %s@%s %s\n", + CHANSVR, + nicklistid->name,nicklistid->uname,nicklistid->host,nicklistid->serv); + writeln(sevsck,local_buf); + } + + if(level == NOOPER) + { sprintf(local_buf,"KILL %s :Your Oper License has been REVOKED\n", + nicklistid->name); + writeln(sevsck,local_buf); + remove_nicklist(nicklistid); + return 0; + } + if(!flag) nicklistid->oper = 0; + if(flag == 1) nicklistid->oper = 1; + else return nicklistid->oper; + +} + +int nick_level(char *nickname) +{ struct nicklist *nicklistid; + + if( (nicklistid = find_nicklist(nickname)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_level: WARNING: NICKNAME DESYNCH %s", + nickname)); + + return 0; + } + return nicklistid->level; + +} + +char *nick_userhost(char *nickname) +{ struct nicklist *nicklistid; + static char mybuf[512]; + + if( (nicklistid = find_nicklist(nickname)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_userhost: WARNING: NICKNAME DESYNCH %s", + nickname)); + + return NULL; + } + sprintf(mybuf,"%s@%s",nicklistid->uname,nicklistid->host); + return mybuf; + +} + + +int add_newuser(char *mytok[],int args,int offset) +{ struct nicklist *nicklistid; + char mybuf[512],*mybuf_ptr,mybuf2[512],mybuf3[512]; + char mask[100],*tmpptr; + int count,hostcount,i; + struct aUser *myuser; + + if(nick_hashid == NULL) nick_hashid = new_nick_hash(); + + if( (nicklistid = find_nicklist(mytok[1+offset])) != NULL) + { /* NICK ALREADY EXISTS */ + + remove_nicklist(nicklistid); + my_debug(D_TRACE,(debug_log,"add_newuser: WARNING: NICKNAME DESYNCH %s", + mytok[1+offset])); + /* since we dont create, assume desync and replace */ + + } + + if( ((tmpptr=strchr(mytok[5+offset],'*')) != NULL) || + ((tmpptr=strchr(mytok[5+offset],'?')) !=NULL) ) + { +/* + sprintf(mybuf,"NOTICE Wildthang :%s %s\n",mytok[1+offset], + mytok[5+offset]); +*/ + sprintf(mybuf,"KILL %s :Fake hostnames are prohibited\n", + mytok[1+offset]); + writeln(sevsck,mybuf); + return 0; + } + + nicklistid=new_nicklist(); + + nicklistid->name = my_strcpy(mytok[1+offset]); + nicklistid->uname = my_strcpy(mytok[4+offset]); + nicklistid->host = my_strcpy(mytok[5+offset]); + nicklistid->serv = my_strcpy(mytok[6+offset]); + nicklistid->hops = atoi(mytok[2+offset]); + nicklistid->level = 0; + nicklistid->oper = 0; + nicklistid->ts=atol(mytok[3+offset]); + + if((!NETBURST) && (args>7)) + { + if(mytok[7+offset] != NULL) + strcpy(mybuf2,mytok[7+offset]+1); /* IRCNAME */ + for(count=8;mytok[count+offset];count++) + { strcat(mybuf2," "); + strcat(mybuf2,mytok[count+offset]); + } + + for(count=0;*ircnames[count];count++) + { if(!match(ircnames[count],mybuf2)) + { sprintf(mybuf,":%s NOTICE #uworld.floods :NAM %s!%s@%s (%s) %s\n", + nicklistid->name,nicklistid->uname,nicklistid->host,mybuf2, + nicklistid->serv); + writeln(sevsck,buf); + } + } + sprintf(mybuf,"*%s@%s*",nicklistid->uname,nicklistid->host); + + myuser=chklevel(mybuf); + if(myuser != NULL) nicklistid->level = myuser->level; + else nicklistid->level = 0; + } + + add_nickhash(nicklistid); + + /* ADDED FOR CLONEBOT DETECTION SUPPORT 7/26/96 + ** if host exists, add 1 to the count, if not, + ** create it with a 1 user count. + */ + +#ifdef USE_TSC + if(SCAN_CLONES) + { + hostcount=scan_host(nicklistid->host,1); + + if(!NETBURST) + { + IS_CLONE=0; + for(i=0;*kloneuser[i];i++) + if(!match(kloneuser[i],nicklistid->uname)) + { IS_CLONE=2; + break; + } + + if(hostcount>1) + if((IS_CLONE) || ((hostcount > SITE_CLONE) && + (check_multiconnect(nicklistid->host, nicklistid->uname)))) + { + if((!NO_TSC) || (IS_CLONE)) + { + sprintf(mybuf, + ":CHANSVR PRIVMSG #Uworld.floods :%s %d connections %s %s!%s\n", + cln[IS_CLONE], + hostcount,nicklistid->host,nicklistid->name,nicklistid->uname); + writeln(sevsck,mybuf); + } + + sprintf(mybuf,"*@%s",nicklistid->host); + if((hostcount > WARNCLONE) && (IS_CLONE)) + { + warn_clone(mybuf); + } + + + + if((UID_GLINE) && (IS_CLONE==2) && (hostcount >=UID_GLINE)) + do_gline(mybuf,"GLINEHOST","AntiClone Systems - detected floodbots", + 600); + else if((DO_GLINE) && (ANAL_GLINE) && (hostcount >=AUTOGLINE)) + do_gline(mybuf,"GLINEHOST", + "Automatically banned for clones and flooding",600); + else if((KICK_ASS) && (IS_CLONE) && (hostcount>=AUTOGLINE)) + { do_gline(mybuf,"AUTOMATION","Autodetected Clone Site",600); + } + + log_tsc(nicklistid,hostcount,"TSC.log"); + } + } + } +#endif + my_debug((D_TRACE | D_NICKLIST), + (debug_log, "add_newuser: 0x%X %s [online %d]",nicklistid,mybuf,count)); + return 1; +} + +int seperate_nicklist(nicklistid) +struct nicklist *nicklistid; +{ int hostid=0; + if(nicklistid == NULL) return 0; + + hostid= get_hashid(nicklistid->name,MAXNICKHASH); + + my_debug((D_TRACE | D_NICKLIST), + (debug_log, "seperate_nicklist:[0x%X] 0x%X nicklist %d %s", + &nick_hashid->host[hostid], + nicklistid,hostid,nicklistid->name)); + + my_debug(D_MEMORY, + (debug_log,"seperate_nicklist: 0x%X [%s] --> --> 0x%X [%s]", + nicklistid->prev,(nicklistid->prev != NULL)? nicklistid->prev->name : "null", + nicklistid->next,(nicklistid->next != NULL)? nicklistid->next->name : "null") + ); + + + if(nicklistid == nick_hashid->host[hostid]) + { + nick_hashid->host[hostid]= nicklistid->next; + if(nick_hashid->host[hostid] != NULL) + nick_hashid->host[hostid]->prev = NULL; + } + else + { if((nicklistid->prev != NULL) && (nicklistid->prev->next == nicklistid)) + nicklistid->prev->next = nicklistid->next; + else my_debug(D_MEMORY, + (debug_log,"seperate_nicklist: WARNING prev/next error in 0x%X", + nicklistid) ); + if((nicklistid->next!=NULL) && (nicklistid->next->prev == nicklistid)) + nicklistid->next->prev = nicklistid->prev; + else my_debug(D_MEMORY, + (debug_log,"seperate_nicklist: WARNING next/prev error in 0x%X [0x%X]", + nicklistid,(nicklistid->next==NULL)? 0 : nicklistid->next) ); + } + + MEM_nicklist_used--; + my_debug(D_NICKLIST, + (debug_log,"seperate_nicklist: 0x%X (list %d) %d", + nicklistid,hostid,MEM_nicklist_used)); +} + +struct nicklist *find_nicklist(char *name) +{ struct nicklist *nicklistid; + int hostid=0; + + hostid = get_hashid(name,MAXNICKHASH); + + if(nick_hashid == NULL) return NULL; + + nicklistid=nick_hashid->host[hostid]; + while(nicklistid) + { + if(!strcasecmp(nicklistid->name,name)) return nicklistid; /* */ + nicklistid=nicklistid->next; + } + my_debug(D_NICKLIST, + ( debug_log,"find_nicklist: %s not in list %d",name,hostid)); + return NULL; /* nickname not found in list */ +} + +int switch_nickname(mytok,args) +char *mytok[]; +int args; +{ struct nicklist *nicklistid; + char mylocbuf[512]; + char oldnick[20]; + int serv_cnt; + + my_debug((D_NICKLIST | D_TRACE), + (debug_log,"switch_nickname: swapping nickname for user %s --> %s", + mytok[0],mytok[2])); + nicklistid=find_nicklist(mytok[0]+1); + if(nicklistid == NULL) + { + my_debug(D_TRACE,(debug_log,"switch_nickname: WARNING: NICKNAME DESYNCH %s", + mytok[0]+1)); + + return 0; + } + seperate_nicklist(nicklistid); + strcpy(oldnick,nicklistid->name); + my_strfree(nicklistid->name); + nicklistid->name =my_strcpy(mytok[2]); + nicklistid->nickchange++; +/* WT */ + if(nicklistid->nickchange > 5) + { + if((NOWTIME - nicklistid->lastchange) > 10) + { nicklistid->nickchange=0; + } + + nicklistid->lastchange=NOWTIME; + } + add_nickhash(nicklistid); + return 1; +} + +int remove_nickname(char *name) +{ struct nicklist *nicklistid; + nicklistid=find_nicklist(name); + if(nicklistid == NULL) + { + my_debug(D_TRACE,(debug_log,"remove_nickname: WARNING: NICKNAME DESYNCH %s", + name)); + + return 0; + } + remove_nicklist(nicklistid); + return 1; +} + + +int get_hashid(char *name,int MAXHASH) +{ int i=0; + int hashid=0; + + while(iuname,nicklistid->host); + + tblock = *localtime(&nicklistid->ts); + sprintf(mybuf,":%s NOTICE %s :Name %s (%s@%s) level %d [%s] [%s] [%s]\n", + CHANSVR, + token[0],nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->level,(nicklistid->oper)?"OPER":"USER", + (nicklistid->vrfy)?"VRFY":"NO-VRFY", + (nicklistid->iphost)?nicklistid->iphost:"iphost"); + writeln(sck,mybuf); + + if(nicklistid->iphost == NULL) + { sprintf(mybuf,"IPWHO %s",nicklistid->name); + writeln(botsck,mybuf); + } + sprintf(mybuf,":%s NOTICE %s :on server %s since %s\n", + CHANSVR, token[0], nicklistid->serv,asctime(&tblock)); + writeln(sck,mybuf); + +} + +int total_users() +{ return MEM_nicklist_used; +} +int total_defined() +{ return MEM_nicklist_cnt; +} + +int scan_userid(char *fromhost) +{ struct nicklist *nicklistid; + char mybuf[512]; + int found=0; + int cntr=0; + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { nicklistid = nick_hashid->host[cntr]; + while(nicklistid) + { sprintf(mybuf,"%s!%s@%s",nicklistid->name, + nicklistid->uname,nicklistid->host); + if(!match(fromhost,mybuf)) found++; + nicklistid = nicklistid->next; + } + } + return found; +} + +int kill_userid(char *fromhost) +{ struct nicklist *nicklistid,*tempid; + char mybuf[512],mybuf2[512]; + int found=0; + int cntr=0; + sprintf(mybuf2,"WALLOPS :MASSKILL request by %s for %s\n",token[0],fromhost); + writeln(sevsck,mybuf2); + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { nicklistid = nick_hashid->host[cntr]; + while(nicklistid) + { sprintf(mybuf,"%s!%s@%s",nicklistid->name, + nicklistid->uname,nicklistid->host); + tempid = nicklistid->next; + if(!match(fromhost,mybuf)) + { found++; + sprintf(mybuf2,"KILL %s :server [%s]\n", + nicklistid->name,nicklistid->serv); + writeln(sevsck,mybuf2); + remove_nicklist(nicklistid); + } + nicklistid = tempid; + } + } + return found; +} + +int dump_nicklist(char *fromhost,char *filename) +{ struct nicklist *nicklistid; + FILE *ofile; + time_t timer; + struct tm tblock; + char mybuf[512]; + int found=0; + int cntr=0; + if( (ofile = fopen(filename,"a"))== NULL) return 0; + + timer=NOWTIME; + tblock = *localtime(&timer); + fprintf(ofile,"\n%s",asctime(&tblock)); + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { nicklistid = nick_hashid->host[cntr]; + while(nicklistid) + { sprintf(mybuf,"%s!%s@%s",nicklistid->name, + nicklistid->uname,nicklistid->host); + if((fromhost == NULL) || (!match(fromhost,mybuf))) + { tblock = *localtime(&nicklistid->ts); + fprintf(ofile,"%-40.40s %-25.25s %02d/%2d %02d:%2d\n", + mybuf,nicklistid->serv, + tblock.tm_mon+1,tblock.tm_mday,tblock.tm_hour,tblock.tm_min); + + } + nicklistid = nicklistid->next; + } + } + fflush(ofile); + fclose(ofile); + return found; +} + +int destroy_nickhash() +{ struct nicklist *nicklistid,*tempid; + int cntr; + if(nick_hashid == NULL) return; + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { + nicklistid = nick_hashid->host[cntr]; + tempid = nicklistid; + while(nicklistid) + { tempid = nicklistid->next; + myfree_nicklist(nicklistid); + nicklistid = tempid; + } + nick_hashid->host[cntr] = NULL; + } +} + +int add_kline(struct nicklist *nicklistid,char *filename) +{ FILE *ofile; + time_t timer; + char line[512],kline[512]; + struct tm tblock; + if( (ofile = fopen(filename,"a")) == NULL) return 0; + + strcpy(line,nicklistid->host); + timer = NOWTIME; + tblock = *localtime(&timer); + fprintf(ofile,"\n# %s",asctime(&tblock)); + fprintf(ofile,"K:*%s::*%s\n",strchr(line,'.'), + (nicklistid->uname[0] == '~' || nicklistid->uname[0] == '^') ? + nicklistid->uname+1 : nicklistid->uname); + + fclose(ofile); + return 1; +} + +int bad_user(char *nickname,int flag,char *channel) +{ struct nicklist *nicklistid; + char local_buf[512]; + char mybuf[512],mask[100],mybufr[100]; + struct aUser *myuser; + struct tm tblock; + int level,scan; + int i,glineID; + + if( (nicklistid = find_nicklist(nickname)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_oper: WARNING: NICKNAME DESYNCH %s", + nickname)); + return 0; + } + + sprintf(local_buf,"%s@%s",nicklistid->uname,nicklistid->host); + + myuser = chklevel(local_buf); + if(myuser != NULL) level=myuser->level; + else level = 0; + + /* Uworld.floods OPER ONLY Support + */ + + if(myuser->level != OPEROK) + { for(scan=0;operchan[scan];scan++) + { + sprintf(mybuf,"*%s*",operchan[scan]); + if( (!match(mybuf,channel)) && (!nicklistid->oper)) + {join_opchan(channel); + sprintf(mybuf, + ":Chansvr KICK #%s %s :This channel is for opers only\n", + operchan[scan],nickname ); + writeln(sevsck,mybuf); + break; + } + } + + for(scan=0;killchan[scan];scan++) + { + sprintf(mybuf,"*%s*",killchan[scan]); + if( (!match(mybuf,channel)) && (!nicklistid->oper)) + { char hostmask[255]; + if (GetUserHost(nicklistid->name,hostmask) <1) break; + if(hostmask[0]!='\0') + { +/* + sprintf(mybuf,"NOTICE WildThang :Banning %s for joining %s\n", + hostmask,killchan[scan]); + writeln(sevsck,mybuf); +*/ + do_gline(hostmask,killchan[scan], + "Banned due to participation or joining in prohibited activities", + 600); + } + break; + } + } + } + /* GLINE SUPPORT. + ** this is really, the wrong place to test Glines + ** but, doesnt hurt to have a backup just in case + ** the first one misses :) + */ +#ifdef UNDEFINED + if(level == GLINE) + { if(strlen(myuser->comment) < 3) strcpy(myuser->comment, + "This site has been GLINED (banned) from Undernet"); + sprintf(local_buf,"GLINE %s +*%s 600 :%s\n", + nicklistid->serv,myuser->mask,myuser->comment); + writeln(sevsck,local_buf); + } +#endif + + if((glineID=check_glines(local_buf))!=-1) + { + sprintf(mybuf,"GLINE %s +*%s %ld :%s\n", + nicklistid->serv,Glines[glineID].mask, + Glines[glineID].time-NOWTIME,Glines[glineID].comment); + writeln(sevsck,mybuf); + } + + + if(LOGJOIN) + for(i=0;*logjoin[i];i++) + { if((!match(logjoin[i],(*channel == ':')?channel+1:channel))) + { + tblock=*localtime(&nicklistid->ts); + sprintf(mybufr,"%s!%s@%s %s %s %s", + nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->serv,(*channel == ':')?channel+1:channel,asctime(&tblock)); + add_logfile(mybufr,"Channel.log"); + break; + } + } + + + if(level == AUTO_BAN) + { + if(DO_CORE) + { sprintf(local_buf,"333 %s :\n352 %s :\n463 %s :version\n465 %s\n", + nicklistid->name, nicklistid->name, nicklistid->name, nicklistid->name); + writeln(sevsck,local_buf); + } + sprintf(local_buf,"MODE %s +b *!%s\n", + (*channel == ':')?channel+1:channel,myuser->mask); + writeln(sevsck,local_buf); + add_chan((*channel == ':')?channel+1:channel,myuser); + + if(DO_AUTOKICK) + { sprintf(local_buf,"KICK %s %s\n",(*channel == ':')?channel+1:channel, + nicklistid->name); + writeln(sevsck,local_buf); + } + + } + + return level; +} + + +int spew_nicklist(char *fromhost,char *target) +{ struct nicklist *nicklistid; + time_t timer; + struct tm tblock; + char mybuf[512]; + int found=0; + int cntr=0; + char localbuf[512]; + + timer=NOWTIME; + tblock = *localtime(&timer); + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { nicklistid = nick_hashid->host[cntr]; + while(nicklistid) + { sprintf(mybuf,"%s!%s@%s",nicklistid->name, + nicklistid->uname,nicklistid->host); + if((fromhost == NULL) || (!match(fromhost,mybuf))) + { tblock = *localtime(&nicklistid->ts); + sprintf(localbuf,":Chansvr NOTICE %s :%-40.40s %-25.25s %02d/%2d %02d:%2d\n", + target, mybuf,nicklistid->serv, + tblock.tm_mon+1,tblock.tm_mday,tblock.tm_hour,tblock.tm_min); + writeln(sevsck,localbuf); + } + nicklistid = nicklistid->next; + } + } + return found; +} + + +int add_myserv(char *name,int sck) +{ struct nicklist *nicklistid; + int cnt; + time_t *timer; + struct tm tblock; + char mybuf[512]; + if( (nicklistid = find_nicklist(name)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_info: WARNING: NICKNAME DESYNCH %s", + nick)); + + return 0; + } + for(cnt=0;cntserv,server_list[cnt])) break; + + if(num_servs > 39) return 0; + + if(cnt == num_servs) + { if(nicklistid->oper) + { strcpy(server_list[num_servs++],nicklistid->serv); + sprintf(mybuf,"NOTICE %s :%s Added to guardian list\n",name, + nicklistid->serv); + file_protected(); + } + else sprintf(mybuf,"NOTICE %s :You must be an operator for %s\n",name, + nicklistid->serv); + } + else sprintf(mybuf,"NOTICE %s :%s Already in guardian list\n",name, + nicklistid->serv); + writeln(sevsck,mybuf); + + return 1; +} + + +int dump_protected(char *name) +{ int count; + char mybuf[512]; + + for(count=0;count < num_servs;count++) + { + sprintf(mybuf,"NOTICE %s :%s\n",name,server_list[count]); + writeln(sevsck,mybuf); + } +} + +int file_protected() +{ int count; + FILE *outfile; + char mybuf[512]; + + if( (outfile=fopen("servers.admin","w")) == NULL) return; + + for(count=0;count < num_servs;count++) + { + if(strlen(server_list[count]) > 1) + fprintf(outfile,"%s\n",server_list[count]); + } + fflush(outfile); + fclose(outfile); +} + + + + +int rem_myserv(char *name,int sck) +{ struct nicklist *nicklistid; + int cnt; + time_t *timer; + struct tm tblock; + char mybuf[512]; + if( (nicklistid = find_nicklist(name)) == NULL) + { + my_debug(D_TRACE,(debug_log,"nick_info: WARNING: NICKNAME DESYNCH %s", + nick)); + + return 0; + } + for(cnt=0;cntserv,server_list[cnt])) break; + + if(num_servs > 39) return 0; + + if(cnt == num_servs) + { if(nicklistid->oper) + { + sprintf(mybuf,"NOTICE %s :%s not in guardian list\n",name, + nicklistid->serv); + } + else sprintf(mybuf,"NOTICE %s :You must be an operator for %s\n",name, + nicklistid->serv); + } + else + { sprintf(mybuf,"NOTICE %s :%s Removed from guardian list\n",name, + nicklistid->serv); + strcpy(server_list[cnt],""); + file_protected(); + load_serv("servers.admin"); + } + writeln(sevsck,mybuf); + + + return 1; +} + + + +int broadcast(char *fromhost,char *message) +{ struct nicklist *nicklistid; +#ifdef UNDEFINED +** time_t timer; +** struct tm tblock; +** char mybuf[512]; +** int found=0; +** int cntr=0; +#endif + char localbuf[512]; + + sprintf(localbuf,":%s NOTICE #%s :%s\n", + CHANSVR,fromhost,message); + writeln(sevsck,localbuf); + +#ifdef UNDEFINED +** timer=NOWTIME; +** tblock = *localtime(&timer); +** for(cntr=0;cntr < MAXNICKHASH;cntr++) +** { nicklistid = nick_hashid->host[cntr]; +** while(nicklistid) +** { sprintf(mybuf,"%s!%s@%s",nicklistid->name, +** nicklistid->uname,nicklistid->host); +** if((fromhost == NULL) || (!match(fromhost,mybuf))) +** { tblock = *localtime(&nicklistid->ts); +** sprintf(localbuf, +** "372 %s :%s\n", +** nicklistid->name,message); +** writeln(sevsck,localbuf); +** } +** nicklistid = nicklistid->next; +** } +** } +** return found; +#endif +} + +int check_floodbot(char *name) +{ int upcnt=0,locnt=0,digcnt=0; + int pos=0; + int isflood=0; + + for(pos=0;pos 'A') && (name[pos] < 'Z')) + { upcnt++; + } + else if((name[pos] > 'a') && (name[pos] < 'z')) + { locnt++; + } + else if (isdigit(name[pos])) + { digcnt++; + } + + } + + if((upcnt>3) && (locnt > 3)) return 1; + if((upcnt>3) && (digcnt > 2)) return 1; + if((upcnt>2) && (locnt > 2) && (digcnt > 2)) return 1; + return 0; + +} + +int add_logfile(char *string,char *filename) +{ + FILE *outfile; + + if((outfile=fopen(filename,"a")) == NULL) return; + + fprintf(outfile,"%s",string); + fclose(outfile); +} + +int check_multiconnect(char *hostname,char *username) +{ + char *temp,tmphost[512]; + int i; + int havedigit=0,havehyphen=0; + + strcpy(tmphost,hostname); + temp=strtok(tmphost,"."); + + IS_CLONE=0; + DO_GLINE=0; + + /* CHECK FOR CLONE USERID.. IF match then CLONE!!*/ + + for(i=0;*MultiUserHost[i];i++) + if(!match(MultiUserHost[i],hostname)) return 0; + + for(i=0;*GlineHost[i];i++) if(!match(GlineHost[i],hostname)) + { DO_GLINE=1; + IS_CLONE=3; + return 1; + } + + /* Next, check unresolved IP's + */ + if(IPSCAN) + if(atoi(temp)) {IS_CLONE=1; return 1;} + + + if(STRICT_SCAN) + for(i=0;ioper) + { + sprintf(mybuf,":CHANSVR INVITE %s %s\n",nick,channel); + } + else sprintf(mybuf,":CHANSVR NOTICE %s :You must be an operator\n",nick); + + writeln(sevsck,mybuf); + + return 1; +} + +int log_tsc(struct nicklist *nicklistid,int count,char *filename) +{ FILE *outfile; + time_t timer; + struct tm tblock; + char outbuf[1024]; + + if(!LOG_TSC) return 0; + + if( (outfile=fopen(filename,"a")) == NULL) return 0; + + timer=NOWTIME; + tblock=*localtime(&timer); + + fprintf(outfile,"%s %3d %10.10s %10.10s %s %20.20s %s", + cln[IS_CLONE], + count,nicklistid->name,nicklistid->uname,nicklistid->host, + nicklistid->serv, + asctime(&tblock)); + + sprintf(outbuf,"%3.3s %3d %s!%s@%s\n", + cln[IS_CLONE], count, + nicklistid->name,nicklistid->uname,nicklistid->host); + DccGlobal(outbuf,DCC_TSC); + + fclose(outfile); + return 1; +} + +int warn_clone(char *target) +{ char mybuf[512]; + + broadcast(target,"WARNING: Multiple connections from a single user host are considered clones. If this continues, you risk being banned from the entire Undernet. (Think about it.. Is it worth it?) Undernet will not tolerate flooding or clones. Your host has been added to the logfiles\n"); + + + +} + +int do_gline(char *mask,char *owner,char *comment,int Gtime) +{ char mybuf[512]; + char myline[512]; + char myowner[100]; + char outbuf[1024]; + if(error_check(mask) < MINCHARS) return 0; + + if(!check_gline_mask(mask)) return 0; + + sprintf(mybuf,"%s [%d]",comment,scan_userid(mask)); + + add_gline(mask,NOWTIME+Gtime,mybuf,owner); + +#ifdef UNDEFINED + add_myuser(GLINE,owner,mask,"gline",NOWTIME+Gtime,mybuf); +#endif + + sprintf(outbuf,"GLN [%d] (%s) %10.10s (%s)\n",Gtime,mask,owner,mybuf); + sprintf(myline,":Chansvr PRIVMSG #uworld.floods :%s",outbuf); + writeln(sevsck,myline); + DccGlobal(outbuf,DCC_GLN); + + broadcast(mask, + "From: Undernet's Coopertive Anti-Abuse Task Force\n"); + broadcast(mask, + "You have been banned from the Undernet IRC Network.\n"); + + sprintf(myline,"GLINE * +%s %d :Banned (%s) until %ld (%s)\n", + mask,Gtime,mask,Gtime+NOWTIME,mybuf); + writeln(sevsck,myline); + mail_report(mask,mybuf); +} + +int mail_report(char *fromhost,char *comment) +{ + struct nicklist *nicklistid; + FILE *ofile,*gfile; + time_t timer; + struct tm tblock; + char mybuf[512]; + int found=0; + int cntr=0; + char myline[512]; + + + timer=NOWTIME; + tblock = *localtime(&timer); + sprintf(myline,"GLINES/GLINE.log.%2.2d%2.2d%2.2d", + tblock.tm_mon+1,tblock.tm_mday,tblock.tm_year); + if( (gfile = fopen(myline,"a")) == NULL); + + if(gfile != NULL) + fprintf(gfile,"\n:GLINE SET FOR %s (%s) at %s",fromhost,comment, + asctime(&tblock)); + for(cntr=0;cntr < MAXNICKHASH;cntr++) + { nicklistid = nick_hashid->host[cntr]; + while(nicklistid) + { sprintf(mybuf,"%s!%s@%s",nicklistid->name, + nicklistid->uname,nicklistid->host); + if((fromhost == NULL) || (!match(fromhost,mybuf))) + { tblock = *localtime(&nicklistid->ts); + + if(gfile != NULL) + fprintf(gfile,"%-40.40s %-25.25s %02d/%2d %02d:%2d\n", + mybuf,nicklistid->serv, + tblock.tm_mon+1,tblock.tm_mday,tblock.tm_hour,tblock.tm_min); + + } + nicklistid = nicklistid->next; + } + } + + + if(gfile!=NULL) fclose(gfile); + return found; + +} + +int IsOper(char *nick,char *fromhost) +{ char host[200]; + char buf[512]; + struct nicklist *nicklistid; + if( (nicklistid = find_nicklist(nick)) == NULL) + { + return 0; + } + sprintf(host,"%s@%s",nicklistid->uname,nicklistid->host); + if((nicklistid->oper) && (!match(fromhost,host))) + { + + if((SECURE_OPER) && (!nicklistid->vrfy)) + { sprintf(buf,":%s NOTICE %s :You must /m %s vrfy PASSWD first\n", + CHANSVR,token[0],controlbot); + writeln(sevsck,buf); + return 0; + } + + else return 1; + } + return 0; +} + +int VrfyOper(char *nick,char *fromhost,char *passwd) +{ char host[200]; + struct aUser *myuser; + struct nicklist *nicklistid; + if( (nicklistid = find_nicklist(nick)) == NULL) + { + return 0; + } + + sprintf(host,"%s@%s",nicklistid->uname,nicklistid->host); + if((nicklistid->oper) && (!match(fromhost,host))) + { + myuser=vrfy_oper(fromhost,passwd); + if(myuser !=NULL) nicklistid->vrfy=1; + else nicklistid->vrfy=0; + return nicklistid->vrfy; + } + return 0; +} + +int OperCom(char *nick) +{ char host[200]; + char buf[512]; + struct nicklist *nicklistid; + if( (nicklistid = find_nicklist(nick)) == NULL) + { + return 0; + } + sprintf(host,"%s@%s",nicklistid->uname,nicklistid->host); + parse(host); + return 1; +} + + +int check_gline_mask(char *mask) +{ int i; + char mybuf[512]; + + if(strchr(mask,'@') == NULL) strcpy(mybuf,mask); + else strcpy(mybuf,strchr(mask,'@')); + + /* WILDCARD IN THE HOST ** PASS IT */ + for(i=0;iMAXNOGLINES-1) break; + } + + /* default to DO IT */ + return 1; + +} + +int showfloods(char *nick) +{ struct aFloodProtect *tmp; + + tmp=FloodProt; + if(tmp == NULL) + { sprintf(buf,":%s NOTICE %s :NO COMMAND HISTORY\n",CHANSVR,nick); + writeln(sevsck,buf); + return 0; + } + else + sprintf(buf,":%s NOTICE %s :Start Command List\n",CHANSVR,nick); + writeln(sevsck,buf); + + while(tmp) + { sprintf(buf,":%s NOTICE %s :%d %ld %s %s\n",CHANSVR,nick,tmp->msgs, + tmp->reset,tmp->hostname,tmp->cmd); + writeln(sevsck,buf); + tmp=tmp->next; + } + + + sprintf(buf,":%s NOTICE %s :END Command List\n",CHANSVR,nick); + writeln(sevsck,buf); + return 0; +} + +int FloodProtect(char *nick,char *cmd) +{ int floodctr=0; + + struct aFloodProtect *tmp,*ttmp; + int loop=0; + + struct nicklist *nicklistid; + +#ifdef FLOOD_BYHOST + if( (nicklistid = find_nicklist(nick)) == NULL) { return 0; } +#endif + + tmp=FloodProt; + + while(tmp) + { + /* Sanity Checks */ + if(tmp == FloodProt) loop++; + if(loop > 10) break; + + if ( tmp->reset < NOWTIME) + { ttmp=tmp; + tmp=tmp->next; + + if(ttmp == FloodProt) FloodProt=tmp; + + if(ttmp->prev) ttmp->prev->next = ttmp->next; + if(ttmp->next) ttmp->next->prev=ttmp->prev; + + /* sanity checks*/ + ttmp->prev=NULL; + ttmp->next=NULL; + + free(ttmp->hostname); + free(ttmp); + continue; + } +#ifdef FLOOD_BYHOST + else if(!strcasecmp(tmp->hostname,nicklistid->host)) +#else + else if(!strcasecmp(tmp->hostname,nick)) +#endif + { tmp->msgs++; + if(tmp->cmd) free(tmp->cmd); + tmp->cmd = strdup(cmd); + + if(tmp->msgs > MSGFLOOD) + { char mask[512]; +#ifndef FLOOD_BYHOST + if( (nicklistid = find_nicklist(nick)) == NULL) { return 0; } +#endif + sprintf(mask,"*%s@%s",nicklistid->uname,nicklistid->host); + + if((strchr(nicklistid->uname,'*')) || (strchr(nicklistid->uname,'?'))) + { sprintf(buf,"KILL %s Uworld.undernet.org :FLOODING UWORLD\n",nick); + writeln(sevsck,buf); + } + else if( ((!strncmp(nicklistid->uname,"telnet",6)) || + (!strncmp(nicklistid->uname,"~telnet",7)) ) && + (!match("*.wildstar.net",nicklistid->host)) ) + { sprintf(buf,"KILL %s Uworld.undernet.org :FLOODING UWORLD\n",nick); + writeln(sevsck,buf); + } + else + { + + if((!tmp->glined) && (!nicklistid->oper) && + (match(mask,"cservice@undernet.org")) ) + do_gline(mask,"Uworld","Flooding Uworld",600); + } + tmp->glined=1; + } + return 1; + } + tmp=tmp->next; + } + /* user wasnt in the list */ + + tmp=(struct aFloodProtect *) calloc(1,sizeof(struct aFloodProtect)); +#ifdef FLOOD_BYHOST + tmp->hostname=strdup(nicklistid->host); +#else + tmp->hostname=strdup(nick); +#endif + tmp->cmd = strdup(cmd); + tmp->reset=NOWTIME+FLOODTIME; + tmp->next=FloodProt; + if(tmp->next) tmp->next->prev = tmp; + tmp->prev=NULL; + tmp->msgs=1; + tmp->glined=0; + FloodProt=tmp; + return 0; +} + + +int GetUserHost(char *nick,char *host) +{ struct nicklist *nicklistid; + host[0]='\0'; + IS_CLONE=0; + if( (nicklistid = find_nicklist(nick)) != NULL) + { + + check_multiconnect(nicklistid->host, nicklistid->uname); + + if(IS_CLONE) + { sprintf(host,"*@%s",nicklistid->host); + } + else + { sprintf(host,"*%s@%s", + (*nicklistid->uname=='~')?nicklistid->uname+1:nicklistid->uname, + nicklistid->host); + } + return (nicklistid->oper)?-1:1; + } + return 0; +} + + +int GetFromhost(char *nick,char *fromhost) +{ + struct nicklist *nicklistid; + if( (nicklistid = find_nicklist(nick)) == NULL) + { + fromhost[0]='\0'; + return 0; + } + sprintf(fromhost,"%s@%s", + (*nicklistid->uname=='~')?nicklistid->uname+1:nicklistid->uname, + nicklistid->host); + return 1; +} + + +int MakeOper(char *nick) +{ char host[200]; + char buf[512]; + struct nicklist *nicklistid; + if( (nicklistid = find_nicklist(nick)) == NULL) + { + return 0; + } + nicklistid->oper=2; + return 1; +} diff --git a/nicklist.h b/nicklist.h new file mode 100644 index 0000000..6818de5 --- /dev/null +++ b/nicklist.h @@ -0,0 +1,93 @@ + + +/***********************************************************/ +/* Telnet3d (the single process telnet service) written by +/* (dvmitche@nssl.uoknor.edu) ALL RIGHTS RESERVED. +/* +/* Duplication of this code is not permitted without explicit +/* aproval from the authors (dvmitche@nssl.uoknor.edu) in whole +/* or in parts. +/* +/* This project was designed to be used on UNDERNET IRC ONLY. +/* No exceptions to this without explicit permission from the +/* authors (dvmitche@nssl.uoknor.edu) (intru@step.polymtl.ca) +/* +/* Special Thanks for your ideas and support with this project. +/* go out to: +/* mandar@vinson.ecn.uoknor.edu +/*************************************************************/ +#include + +#define MAXNICKLEN 15 + + /* Original value 26 */ +#define MAXNICKHASH 59 +/* +#define MAXNICKHASH 2600 +*/ +#define KLINE_FILE "kline.request" +struct nicklist { + struct nicklist *next; + struct nicklist *prev; + int level; + char oper; + char vrfy; + char *serv; + char *name; + char *uname; + char *host; + char umode; + int hops; + int sck; + time_t ts; + int nickchange; + time_t lastchange; + char *ip; + char *iphost; +}; +struct nick_hash { + struct nicklist *host[MAXNICKHASH]; +}; + +struct nick_hash *new_nick_hash(); +struct nicklist *new_nicklist(); +int add_nickhash(struct nicklist *nicklistid); +int add_nicklist(struct nicklist *nicklistid,struct nicklist **startid); +int remove_nicklist(struct nicklist *nicklistid); +int myfree_nicklist(struct nicklist *nicklistid); +int nick_oper(char *nickname,int flag); +int nick_level(char *nickname); +char *nick_userhost(char *nickname); +int add_newuser(char *mytok[],int args,int offset); +int seperate_nicklist(struct nicklist *nicklistid); +struct nicklist *find_nicklist(char *name); +int switch_nickname(char *mytok[],int args); +int get_hashid(char *name,int MAXHASH); +char *my_strcpy(char *inp); +int my_strfree(char *inp); +int nick_info(char *nick,int sck); +int remove_nickname(char *name); +int total_users(); +int scan_userid(char *fromhost); +int destroy_nickhash(); +int dump_nicklist(); +int add_kline(struct nicklist *nicklistid,char *filename); + + + + +#ifdef __NICKLIST__ + long MEM_nicklist_total = 0; + long MEM_nickhash_total = 0; + int MEM_nicklist_cnt = 0; + long MEM_nicklist_used = 0; + long MEM_string=0; + struct nick_hash *nick_hashid=NULL; +#else + extern long MEM_nicklist_total; + extern long MEM_nickhash_total; + extern int MEM_nicklist_cnt; + extern long MEM_nicklist_used; + extern struct nick_hash *nick_hashid; + extern long MEM_string; +#endif diff --git a/nickserv.c b/nickserv.c new file mode 100755 index 0000000..1e43686 --- /dev/null +++ b/nickserv.c @@ -0,0 +1,13 @@ +#include +#include +#include "config.h" + +extern char buf[],sockbuf[], *token[]; +extern int sevsck,botsck; +nickserv(char *target) +{ + sprintf(buf,":%s NOTICE %s :You are using a registered nick\n", + NICKSERV,target); writeln(sevsck,buf); + sprintf(buf,"433 %s :Registered Nickname Please Choose another\n", + target); writeln(sevsck,buf); +} diff --git a/parse.c b/parse.c new file mode 100755 index 0000000..d8f0d53 --- /dev/null +++ b/parse.c @@ -0,0 +1,1768 @@ +#include +#include +#include +#include +#include +#ifdef USE_DCC +#include +#include +#include +#include +#include +#endif + +#include "config.h" + +#include "myfile.h" +char *nomodchan[]={ + "#wildstar","" }; +char *badchan[]={ + "*!!*", "*warez*","*hack*","" }; + +#ifdef USE_DCC +extern struct aDccClient MyClient[]; +extern char UPLINK[]; +#endif + +extern int SNOOP; +int GlineTime,LOGJOIN=0,UID_GLINE=0,SCAN_CLONES=1; + +extern char *SuspendOper[]; +extern time_t SuspendOperTime[]; +extern char *SuspendChan[]; +extern time_t SuspendChanTime[]; +extern int DccCtr; + +extern int NETBURST,FLOODPROTECTION; +extern char storebuf[]; +extern char *operchan[],*killchan[]; +extern long D_JOIN,D_NICK,D_PART,D_MODE,D_KICK,D_SERVER,D_QUIT,D_USER,D_SQUIT; +extern long N_JOIN,N_NICK,N_PART,N_MODE,N_KICK,N_SERVER,N_QUIT,N_USER,N_SQUIT; +extern long D_TOTAL,N_TOTAL,N_OTHER,D_OTHER,FLOODLOGS; +extern long D_KILL,N_KILL; +extern long D_TOPIC,N_TOPIC; +extern int DO_AUTOKICK,DO_CORE; +extern time_t S_TIME; +extern char *token[]; +extern int CLONE_UP,CLONE_LO,CLONE_DIG,LOGHOST; +extern int MAX_SESSIONS,MAX_ALLOWED; +extern int SITE_CLONE,KILL_NICKFLOOD; +extern time_t NOWTIME; +extern int killstatus; +extern char buf[]; +extern int botsck,sevsck; +int noopers=0,doclearkick=0,doclearops=0,docleanchan=0,docleanops=0; +char channel[255]; +char comment[255],modes[10]; +char orig[255]; +char opcommand[512]; +int status; +int showme=0; +int DO_WIBBLE=0; +int nohelp=NOHELP; +int LOG_TSC=1,WARNCLONE=3,ACT_ANAL=0,STRICT_SCAN=1,AUTOGLINE=4,KICK_ASS=0,ANAL_GLINE=1,NO_TSC=0; +int CLEAR_KICK=0; +int SECURE_OPER=0; +int IPSCAN=0; +char *opcom_command[]={"MODE","KICK",""}; +char *invitekiller[]={"willy13","born2rok","babybluz","rkzmedud", + "melubue","MissPowy","BLITZKRIE", +""}; + +char *invitehosts[]={ "palimano.horsesale.com","stallion.horsesale.com", + "arapaho.wfire.net","nebula.wildstar.net","creek.wfire.net", + "orion.wildstar.net","BATTLESERVER.COM", +""}; + +parse(char *fromhost) +{ +int level=0,i,j,k,m,chk,loop; +char temp[512]; +char filename[80]; +char mask[100]; +char tbuf[1024]; +struct aUser *myuser,*targuser; +/* PROCESS MSGS FROM USERS */ + writelog(fromhost); + myuser = chklevel(fromhost); + if(myuser != NULL) level = myuser->level; + if(!level) level=DEFAULT_LEVEL; + k=chk_num(0); + + *token[0]++; + /* remove the leading : */ + if((token[3]) && (*token[3]==':')) token[3]++; + + if(level < 1) + { sprintf(tbuf,":%s NOTICE %s :ACCESS DENIED\n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + return 0; + } + + + if(level < 8) + { + for(loop=0;*SuspendOper[loop];loop++) + { + if((SuspendOperTime[loop]<0) || (SuspendOperTime[loop]>NOWTIME)) + { if(!match(SuspendOper[loop],fromhost)) + { if(DccCtr<0) + { sprintf(tbuf,":%s NOTICE %s :Your Uworld access is Suspended\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + else + { writeln(MyClient[DccCtr].fd,"Your Uworld access is suspended\n"); + } + return; + } + } + } + } + + + if((NETBURST) && (*token[3]!='d')) + { + sprintf(tbuf,":%s NOTICE %s :Processing Netburst [%d]\n",CHANSVR, + token[0],NETBURST); + writeln(sevsck,tbuf); + } + + + if((k>3) && (*token[3]=='\1')) + { if((k>7) && (!strcmp(token[3]+1,"DCC")) && (!strcmp(token[4],"CHAT"))) + { if((level > 1) && (IsOper(token[0],fromhost))) + accept_dcc(fromhost); + else + { sprintf(tbuf,":%s NOTICE %s :You forgot your secret key\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + } + return 1; + } + + if((k>3) && (strcasecmp(token[3],"mycmd")) && + (strcasecmp(fromhost,"cservice@undernet.org")) && + (strcasecmp(token[3],"dmsg")) && + (strcasecmp(token[3],"vrfy")) && + (strcasecmp(token[3],"wall")) && (strcasecmp(token[3],"dccwall")) + ) storecomm(fromhost); + + if ((k>3) && (!match(token[3],"help"))) { + if(IsOper(token[0],fromhost)) + { strcpy(filename,HELPFILE); + catfile(filename,CHANSVR); + } + else + { sprintf(tbuf,":%s NOTICE %s :This service is for operators only\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + return; + } + + if((k > 4) && (!strcmp(token[3],"reop")) && + ((!strcmp(token[0],"W")) || (!strcasecmp(token[0],"X"))) ) + { if(*token[4]!='#') + { sprintf(tbuf,":%s NOTICE %s :can only reop a channel\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + if((level>6) + /*&& !match("*cservice@channels*.undernet.org",fromhost)*/ + ) + { + sprintf(tbuf,"MODE %s +o %s\n",token[4],token[0]); + writeln(sevsck,tbuf); + return; + } + else if(chkchanlevel(fromhost,token[4])>4) + { + sprintf(tbuf,"MODE %s +o %s\n",token[4],token[0]); + writeln(sevsck,tbuf); + } + else + { sprintf(tbuf, + ":%s NOTICE %s :sorry you dont have clearance on that channel\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + return; + } + + /* VERIFY USER IS AN OPERATOR */ + if((k>4) && ( !strcasecmp(token[3],"vrfy"))) + { + if(VrfyOper(token[0],fromhost,token[4])) + { sprintf(tbuf,":%s NOTICE %s :Auth Successful\n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + else + { sprintf(tbuf,":%s NOTICE %s :Auth FAILED\n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + } + + if((level > 1) && (IsOper(token[0],fromhost))) + { + if(!match(token[2],"VERSION")) do_version(); + + if(k>3) /* Commands w/o arguments */ + { + + /* Toggle WIBBLE MODE ON/OFF */ + if(!strcasecmp(token[3],"dowibble")) + { + DO_WIBBLE = (DO_WIBBLE)?0:1; + sprintf(tbuf,":%s NOTICE %s :Wibble mode set %s\n",CHANSVR,token[0], + (DO_WIBBLE)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + if((k>4) && (!strcasecmp(token[3],"leave")) && (*token[4]=='#')) + { sprintf(tbuf,":%s PART %s\n",CHANSVR,token[4]); + writeln(sevsck,tbuf); + return; + } + if((k>4) && (!strcasecmp(token[3],"join")) && (*token[4]=='#')) + { sprintf(tbuf,":%s JOIN %s\n",CHANSVR,token[4]); + writeln(sevsck,tbuf); + return; + } + if(!strcasecmp(token[3],"users")) + { showall(token[0],sevsck); + return; + } + if(!strcasecmp(token[3],"stats")) + { dump_stats(); + return; + } + + /* BANS */ + if(!strcasecmp(token[3],"bans")) + { + show_glines(); + return; + } + + if((k>4) && (!strcasecmp(token[3],"testban"))) + { + sprintf(tbuf,":%s NOTICE %s :%s == %d\n", + CHANSVR,token[0],token[4],check_glines(token[4])); + writeln(sevsck,tbuf); + return; + } + + if(!strcasecmp(token[3],"loadglines")) + { + read_glines(GLINEFILE); + sprintf(tbuf,"NOTICE %s :rebooted GLINES list from file\n",token[0]); + writeln(sevsck,tbuf); + + return; + } + if(!strcasecmp(token[3],"showbans")) + { + show_glines(); + return; + } + + if(!strcmp(token[3],"clones")) + { status = SHOW_HOSTS; + sprintf(tbuf,":%s WHOIS %s \n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + + + } /* End of K>3 */ + + if(k>4) /* commands with 1 argument */ + { + if(!strcmp(token[3],"chanlevel")) + { sprintf(tbuf,":%s NOTICE %s :your channel access on %s is %d\n", + CHANSVR, token[0],token[4],chkchanlevel(fromhost,token[4])); + writeln(sevsck,tbuf); + return; + } + + /* CLEAR CHANNEL */ + if(!strcmp(token[3],"clearchan")) + { + if((*token[4]!='#') && (k>5)) + { + comment[0]='\0'; + if((k>6) && token[6]) + { for(loop=6;token[loop+1];loop++) + { strcat(comment,token[loop]); + strcat(comment," "); + } + strcat(comment,token[loop]); + } + + if(*token[4]=='-') *token[4]++; + strncpy(modes,token[4],9); + modes[9]='\0'; + strcpy(channel,token[5]); + } + else + { + comment[0]='\0'; + if((k>5) && token[5]) + { for(loop=5;token[loop+1];loop++) + { strcat(comment,token[loop]); + strcat(comment," "); + } + strcat(comment,token[loop]); + } + + strcpy(modes,"mob"); + strcpy(channel,token[4]); + } + if(!strcasecmp(channel,"#wasteland")) + { sprintf(tbuf, + ":%s NOTICE %s :That channel is no longer withing my control\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + else + DoClearchan(token[0],channel); + } + if(!strcmp(token[3],"clearops")) + { + strcpy(channel,token[4]); + DoClearOps(token[0],channel); + } + if(!strcmp(token[3],"clearbans")) + { + strcpy(channel,token[4]); + DoClearBans(token[0],channel); + } + if(!strcmp(token[3],"clearmodes")) + { + strcpy(channel,token[4]); + DoClearModes(token[0],channel); + } + + + if((k>5) && (!strcmp(token[3],"gline"))) + { char *gmask; + char *hstname; + char hostmask[255]; + GlineTime=600; + gmask=token[4]; + + if((k>6) && (atoi(token[4])) ) + { GlineTime=atoi(token[4]); + + if((GlineTime > 864000) && (level < 8)) + { gmask=token[0]; + sprintf(tbuf, + ":%s NOTICE %s :Gline timelimits are 10 days (864000) Anything more is a bit redicilous. -- BOUNCING GLINE for violation of regulations\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + else + gmask=token[5]; + } + + if( (hstname=strchr(gmask,'@')) != NULL) + { for(loop=0;loop5) + { for(loop=(gmask==token[5])?6:5;loop5) && (atoi(token[4])) ) + { GlineTime=atoi(token[4]); + if((GlineTime > 864000) && (level < 8)) + { gmask=token[0]; + sprintf(tbuf, + ":%s NOTICE %s :Gline timelimits are 10 days (864000) Anything more is a bit redicilous. -- BOUNCING GLINE for violation of regulations\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + else + gmask=token[5]; + } + if( (hstname=strchr(gmask,'@')) == NULL) + { sprintf(tbuf,"NOTICE %s :You must specify a username\n", + token[0]); + writeln(sevsck,tbuf); + return 0; + } + + comment[0]='\0'; + if(k>5) + { + for(loop=(gmask==token[5])?6:5;loop5) && (atoi(token[4])) ) + { GlineTime=atoi(token[4]); + gmask=token[5]; + } + if( (hstname=strchr(gmask,'@')) == NULL) + { sprintf(tbuf,"NOTICE %s :You must specify a username\n", + token[0]); + writeln(sevsck,tbuf); + return 0; + } + + comment[0]='\0'; + if(k>5) + { + for(loop=(gmask==token[5])?6:5;loop5) && (atoi(token[4])) ) + { GlineTime=atoi(token[4]); + gmask=token[5]; + } + if( (hstname=strchr(gmask,'@')) != NULL) + { for(loop=0;loop5) + { for(loop=5;loop5) + { for(loop=5;loop4 */ + + + } /* END OF OPER COMMANDS */ + + if (level > 5) { + + if(k>3) /* Commands w/o arguments */ + { + if(!strcasecmp(token[1],"DCC")) + { if(!strcasecmp(token[3],"dmsg")) DccMessage(token[4]); + if(!strcasecmp(token[3],"dwho")) DccWho(token[4]); + if(!strcasecmp(token[3],"umode")) DccUmode(token[4]); + if(!strcasecmp(token[3],"dccwall")) DccWall(); + if(!strcasecmp(token[3],"wall")) DccWall(); + if(!strcasecmp(token[3],"dlist")) DccList(); + } + } + + if((k>4) && (!strcmp(token[3],"info"))) do_info(token[4]); + else if((k>3) && (!strcmp(token[3],"servs"))) dump_protected(token[0]); + else if((k>3) && (!strcmp(token[3],"protect"))) add_myserv(token[0], + sevsck); + else if((k>3) && (!strcmp(token[3],"unprotect"))) rem_myserv(token[0], + sevsck); + else if(!strcmp(token[3],"scan2")) do_scan(sevsck,k); + else if((k>3) && (!strcmp(token[3],"nofloods")) ) + oper_invite(token[0],"#Uworld.floods"); + else if((k>4) && (!strcmp(token[3],"operin")) && + (IsOper(token[0],fromhost))) + { while(*token[4]=='#') ++token[4]; + if(check_operchan(token[4])) + { char mylbuf[128]; + sprintf(mylbuf,"#%s",token[4]); + oper_invite(token[0],mylbuf); + } + } + else if((k>4) && (!strcmp(token[3],"operrem")) && + (IsOper(token[0],fromhost))) + { while(*token[4]=='#') ++token[4]; + if(check_operchan(token[4])) + { rem_operchan(token[4]); + sprintf(tbuf,":Chansvr MODE #%s -i\n:Chansvr PART #%s\n", + token[4],token[4]); + writeln(sevsck,tbuf); + } + } + else if((!strcmp(token[3],"showoperchan")) && + (IsOper(token[0],fromhost))) + show_operchan(); + else if((k>4) && (!strcmp(token[3],"operadd")) && + (IsOper(token[0],fromhost))) + { char mylbuf[128]; + + if(level <9) + { sprintf(tbuf,":%s NOTICE %s :Permission denied\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + while(*token[4]=='#') ++token[4]; + if(!check_operchan(token[4])) add_operchan(token[4]); + sprintf(tbuf,":CHANSVR Wallops :%s OPERCHAN %s\n", + token[0],token[4]); + writeln(sevsck,tbuf); + join_opchan(token[4]); + sprintf(mylbuf,"#%s",token[4]); + oper_invite(token[0],mylbuf); + } + + else if((!strcmp(token[3],"showkillchan")) && + (IsOper(token[0],fromhost))) + show_killchan(); + + else if((k>4) && (!strcmp(token[3],"remkillchan")) && + (IsOper(token[0],fromhost))) + { + rem_killchan(token[4]); + sprintf(buf,":%s NOTICE %s :remkillchan %s\n", + CHANSVR,token[0],token[4]); + writeln(sevsck,buf); + } + + else if((k>4) && (!strcmp(token[3],"killchan")) && + (IsOper(token[0],fromhost))) + { char mylbuf[128]; + add_killchan(token[4]); + sprintf(tbuf,":CHANSVR Wallops :%s BANCHAN %s\n", + token[0],token[4]); + writeln(sevsck,tbuf); + } + + + else if((k > 4) && (!strcmp(token[3],"scan"))) + { + strcpy(channel,token[0]); + strcpy(opcommand,token[4]); + status = SCAN; + sprintf(tbuf,":%s WHOIS %s\n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + } + else if(!strcmp(token[3],"lusers")) do_lusers(); + else if(!strcmp(token[3],"lastcomm")) + lastcomm((token[4])?atoi(token[4]):CMDHISTORY); + else if(!strcmp(token[3],"lastlog")) + lastcomm((token[4])?atoi(token[4]):CMDHISTORY); + + if((k > 4) && (!strcmp(token[3],"opcom"))) { + + for(chk=0;*opcom_command[chk];chk++) + { if(!strcasecmp(token[4],opcom_command[chk])) + { + if(atoi(token[4])) + { sprintf(tbuf, + ":%s NOTICE %s :Sorry, numerics have been disables\n", + CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + + strcpy(temp,token[4]); + for(i=5;i 6) || (IsOper(token[0],fromhost))) + { + DoOpcom(token[0],temp); + } + return; + } + } + sprintf(tbuf, + ":%s NOTICE %s :Sorry, that command is INVALID per request of MMMM!mandar@vinson.ecn.uoknor.edu\n",CHANSVR,token[0]); + writeln(sevsck,tbuf); + return; + } + } + + /* NOTE: level 7 command == opcom w/o oper check */ + if(level > 7) { + if((k > 4) && (!strcmp(token[3],"spew"))) + { if(error_check(token[4])>MINCHARS) spew_nicklist(token[4],token[0]); + else + { sprintf(tbuf,"NOTICE %s :Not enough characters in pattern\n", + token[0]); + writeln(sevsck,tbuf); + } + } + else if( (k > 3) && (!strcasecmp(token[3],"actanal"))) + { + ACT_ANAL = (ACT_ANAL)?0:1; + sprintf(tbuf,":%s NOTICE %s :ACT_ANAL mode set %s\n",CHANSVR,token[0], + (ACT_ANAL)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + else if( (k > 3) && (!strcasecmp(token[3],"ipscan"))) + { + IPSCAN = (IPSCAN)?0:1; + sprintf(tbuf,":%s NOTICE %s :IPSCAN mode set %s\n",CHANSVR,token[0], + (IPSCAN)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + + else if( (k > 4) && (!strcasecmp(token[3],"uidgline"))) + { + UID_GLINE=(atoi(token[4])>2)?atoi(token[4]):0; + sprintf(tbuf,":%s NOTICE %s :UID_GLINE mode set %d\n",CHANSVR,token[0], + UID_GLINE); + writeln(sevsck,tbuf); + } + + else if( (k > 3) && (!strcasecmp(token[3],"tsc"))) + { + NO_TSC = (NO_TSC)?0:1; + sprintf(tbuf,":%s NOTICE %s :NO_TSC mode set %s\n",CHANSVR,token[0], + (NO_TSC)?"ON":"OFF"); + writeln(sevsck,tbuf); + } + + else if( (k > 3) && (!strcasecmp(token[3],"floodlog"))) + { + FLOODLOGS = (FLOODLOGS)?0:1; + sprintf(tbuf,":%s NOTICE %s :FLOODLOGS mode set %s\n",CHANSVR,token[0], + (FLOODLOGS)?"ON":"OFF"); + writeln(sevsck,tbuf); + } + + else if( (k > 3) && (!strcasecmp(token[3],"secureoper"))) + { + SECURE_OPER = (SECURE_OPER)?0:1; + sprintf(tbuf,":%s NOTICE %s :SECURE_OPER mode set %s\n",CHANSVR,token[0], + (SECURE_OPER)?"ON":"OFF"); + writeln(sevsck,tbuf); + sprintf(tbuf, + ":CHANSVR WALLOPS :SECURE_OPER MODE SET %s\n", + (SECURE_OPER)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + + else if( (k > 3) && (!strcasecmp(token[3],"clearkick"))) + { + CLEAR_KICK = (CLEAR_KICK)?0:1; + sprintf(tbuf,":%s NOTICE %s :CLEAR_KICK mode set %s\n",CHANSVR,token[0], + (CLEAR_KICK)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + else if( (k > 3) && (!strcasecmp(token[3],"snoop"))) + { + SNOOP = (SNOOP)?0:1; + sprintf(tbuf,":%s NOTICE %s :SNOOP mode set %s\n",CHANSVR,token[0], + (SNOOP)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + + + else if( (k > 3) && (!strcasecmp(token[3],"kickass"))) + { + KICK_ASS = (KICK_ASS)?0:1; + sprintf(tbuf,":%s NOTICE %s :KICK_ASS mode set %s\n",CHANSVR,token[0], + (KICK_ASS)?"ON":"OFF"); + writeln(sevsck,tbuf); + sprintf(tbuf, + ":CHANSVR WALLOPS :AUTOMATED GLINES SET %s anti-clone level %d\n", + (KICK_ASS)?"ON":"OFF",AUTOGLINE); + writeln(sevsck,tbuf); + return; + } + + else if( (k > 3) && (!strcasecmp(token[3],"dogline"))) + { + ANAL_GLINE = (ANAL_GLINE)?0:1; + sprintf(tbuf,":%s NOTICE %s :ANAL_GLINE mode set %s\n",CHANSVR,token[0], + (ANAL_GLINE)?"ON":"OFF"); + writeln(sevsck,tbuf); + sprintf(tbuf, + ":CHANSVR WALLOPS :NO TOLERANCE GLINES ARMED %s anti-clone level %d\n", + (ANAL_GLINE)?"ON":"OFF",AUTOGLINE); + writeln(sevsck,tbuf); + return; + } + + else if( (k > 3) && (!strcasecmp(token[3],"strictscan"))) + { + STRICT_SCAN = (STRICT_SCAN)?0:1; + sprintf(tbuf,":%s NOTICE %s :STRICT_SCAN mode set %s\n",CHANSVR,token[0], + (STRICT_SCAN)?"ON":"OFF"); + writeln(sevsck,tbuf); + return; + } + + else if(!strcmp(token[3],"reconnect")) { close(sevsck); + sevsck=sev_login(UPLINK); + do_bots(); + } + else if((k > 4) && (!strcmp(token[3],"jupe"))) + sev_jupe(token[4],token[0]); + else if((k > 4) && (!match(token[3],"makehelp"))) { + nohelp=0; + makehelp(sevsck,token[4],"Commander Bot"); + } + } + + if (level > 8) { + if(!strcmp(token[3],"nohelp")) nohelp=1; + else if((k>3) && (!strcmp(token[3],"makeop"))) + { if(MakeOper(token[4])) + sprintf(tbuf,":%s NOTICE %s :%s is considerd an Operator\n", + CHANSVR,token[0],token[4]); + else sprintf(tbuf,":%s NOTICE %s :%s not found\n", + CHANSVR,token[0],token[4]); + writeln(sevsck,tbuf); + return; + } + else if((k>4) && (!strcmp(token[3],"opersuspend"))) + { time_t gtime; + struct tm tblock; + if(token[5]) gtime=NOWTIME+atoi(token[5]); + else gtime=NOWTIME+19999999; + add_suspend(token[4],gtime); + tblock=*localtime(>ime); + sprintf(tbuf,"*** OPERSUSPEND [%s] by %s until %s", + token[4],token[0],asctime(&tblock)); + DccGlobal(tbuf,DCC_ANY); + } + else if((k>4) && (!strcmp(token[3],"chansuspend"))) + { time_t gtime; + struct tm tblock; + if(token[5]) gtime=NOWTIME+atoi(token[5]); + else gtime=NOWTIME+19999999; + add_Csuspend(token[4],gtime); + tblock=*localtime(>ime); + sprintf(tbuf,"*** CHANNEL SUSPEND [%s] by %s until %s", + token[4],token[0],asctime(&tblock)); + DccGlobal(tbuf,DCC_ANY); + } + else if(!strcmp(token[3],"nokill")) KILL_NICKFLOOD=0; + else if(!strcmp(token[3],"autokick")) + { DO_AUTOKICK = (DO_AUTOKICK)?0:1; + sprintf(tbuf,"NOTICE %s :AUTOKICK set %s\n", + token[0],(DO_AUTOKICK)?"on":"off"); + writeln(sevsck,tbuf); + } + else if(!strcmp(token[3],"autocore")) + { DO_CORE = (DO_CORE)?0:1; + sprintf(tbuf,"NOTICE %s :CORE set %s\n", + token[0],(DO_CORE)?"on":"off"); + writeln(sevsck,tbuf); + } + else if(!strcmp(token[3],"floodprotection")) + { FLOODPROTECTION = (FLOODPROTECTION)?0:1; + sprintf(tbuf,"NOTICE %s :FLOODPROTECTION set %s\n", + token[0],(FLOODPROTECTION)?"on":"off"); + writeln(sevsck,tbuf); + } + else if(!strcmp(token[3],"logjoin")) + { LOGJOIN = (LOGJOIN)?0:1; + sprintf(tbuf,"NOTICE %s :LOGJOIN set %s\n", + token[0],(LOGJOIN)?"on":"off"); + writeln(sevsck,tbuf); + } + + else if(!strcmp(token[3],"loghost")) + { LOGHOST = (LOGHOST)?0:1; + sprintf(tbuf,"NOTICE %s :LOGHOST set %s\n", + token[0],(LOGHOST)?"on":"off"); + writeln(sevsck,tbuf); + } + else if((k > 7) && (!strcmp(token[3],"addusr"))) + { if(atoi(token[4]) < 8) + { + if(error_check(token[6]) < MINCHARS) return; + add_myuser(atoi(token[4]),token[5],token[6],token[7], + NOWTIME+3600,NULL); + } + } + else if((k > 4) && (!strcmp(token[3],"remusr"))) + { + remove_myuser(token[4]); + } + else if(!strcmp(token[3],"showagl")) show_agl(); + else if(!strcmp(token[3],"showmhost")) show_mhost(); + else if(!strcmp(token[3],"showmhost")) show_shost(); + else if(!strcmp(token[3],"showsuspend")) show_suspend(); + else if(!strcmp(token[3],"showcsuspend")) show_Csuspend(); + else if(!strcmp(token[3],"loadchansuspend")) + { + read_Csuspend(CHANSUSPENDFILE); + sprintf(tbuf,"NOTICE %s :rebooted CHANNEL SUSPEND list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"loadkillchan")) read_killchan(KILLCHANFILE); + else if(!strcmp(token[3],"loadsuspend")) + { + read_suspend(SUSPENDFILE); + sprintf(tbuf,"NOTICE %s :rebooted SUSPEND list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"loadshost")) + { + read_shost(SHOSTFILE); + sprintf(tbuf,"NOTICE %s :rebooted SHOST list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"loadmhost")) + { + read_mhost(MHOSTFILE); + sprintf(tbuf,"NOTICE %s :rebooted MHOST list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"loadagl")) + { + read_glinehost(AGLINEFILE); + sprintf(tbuf,"NOTICE %s :rebooted AGL list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"loadnogln")) + { + read_noglines(EGLINEFILE); + sprintf(tbuf,"NOTICE %s :rebooted exempt list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"showfloods")) { showfloods(token[0]); return;} + else if(!strcmp(token[3],"loadusr")) + { destroy_myuser(); + load_myuser("user.file"); + sprintf(tbuf,"NOTICE %s :rebooted user list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if(!strcmp(token[3],"dokill")) KILL_NICKFLOOD=1; + else if(!strcmp(token[3],"reboot")) reboot(); + else if(!strcmp(token[3],"masskill")) + { if(error_check(token[4])>MINCHARS) do_kill(sevsck,k); + else + { sprintf(tbuf,"NOTICE %s :Not enough characters in pattern\n", + token[0]); + writeln(sevsck,tbuf); + } + } + else if((k > 4) && (!strcmp(token[3],"check"))) + do_error_check(token[4],token[0]); + else if(!strcmp(token[3],"reconnect")) { close(sevsck); + sevsck=sev_login(UPLINK); + do_bots(); + } + + } + + if (level > 9) { + if((k > 4) && (!strcmp(token[3],"nickserv"))) nickserv(token[4]); + else if((k>4) + && (!strcmp(token[3],"dkill"))) DccKill(token[4]); + else if(!strcmp(token[3],"reload")) + { destroy_myuser(); + load_myuser("user.file"); + sprintf(tbuf,"NOTICE %s :rebooted user list from file\n",token[0]); + writeln(sevsck,tbuf); + return; + } + else if((k>4) + && (!strcmp(token[3],"killlog"))) killstatus=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"noopers"))) noopers=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"maxses"))) MAX_SESSIONS=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"maxsite"))) SITE_CLONE=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"autogline")) && + (atoi(token[4])>3)) AUTOGLINE=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"warnclone"))) WARNCLONE=atoi(token[4]); + else if((k>4) + && (!strcmp(token[3],"maxclients"))) MAX_ALLOWED=atoi(token[4]); + else if(!strcmp(token[3],"mycmd")) do_scmd(sevsck); + else if((k>4)&&(!strcmp(token[3],"makemybots"))) + makemybots(atoi(token[4])); + else if((k>4)&&(!strcmp(token[3],"killmybots"))) + killmybots(atoi(token[4])); + else if((k>4) && + (!strcmp(token[3],"checkmask"))) + { if(check_gline_mask(token[4])) + sprintf(tbuf,":%s NOTICE %s :MASK: %s -- OK\n",CHANSVR,token[0], + token[4]); + else + sprintf(tbuf,":%s NOTICE %s :MASK: %s -- INVALID\n",CHANSVR,token[0], + token[4]); + writeln(sevsck,tbuf); + return 0; + } + else if(!strcmp(token[3],"showhost")) show_hosts(token[0],0); + else if(!strcmp(token[3],"nickdump")) dump_nicklist(NULL,"NICK_LIST"); + else if((k > 5) && (!strcmp(token[3],"filenick"))) + dump_nicklist(token[4],token[5]); + else if(!strcmp(token[3],"numnuk")) num_nuk(token[4]); + else if(!strcmp(token[3],"numnuk2")) num_nuk2(token[4]); + else if(!strcmp(token[3],"numnuk3")) num_nuk3(token[4]); + else if(!strcmp(token[3],"kill")) mass_kill(k); + else if(!strcmp(token[3],"deop")) mass_deop(k); + else if(!strcmp(token[3],"dome")) do_scmd(botsck); + else if(!strcmp(token[3],"exit")) + { sprintf(tbuf,"ACK.. Forced exit by %s!\n",token[0]); + DccGlobal(tbuf,DCC_ANY); + exit(0); + } + } + +} + +sevstuff(sck,fromhost) +int sck; +char *fromhost; +{ +int j,k,i,level; +char temp[255]; +int stat,myrand; +int offset; +static time_t last_wibble=0; +struct aUser *targuser; + + offset=0; + k=chk_num(0); + temp[0]='\0'; + + if(!strcmp(token[0],"NICK")) + { /* NEW USER */ + add_newuser(token,k,0); + } + if(!match(token[1],"NICK")) + { if(!strchr(token[0],'.')) switch_nickname(token,k); + else + if(k > 8) + { + add_newuser(token,k,1); + sprintf(temp,"%s@%s",token[5],token[6]); + + level=0; + } + return; + } + if(k < 3) return; + + if((!strcmp(token[1],"WALLOPS")) && (!strchr(token[0],'.'))) + { + sprintf(temp,"!%s!",token[0]+1); + for(i=2;token[i];i++) + { strcat(temp," "); strcat(temp,token[i]); + } + strcat(temp,"\n"); + DccGlobal(temp,DCC_WALL); + } + + if(!strcmp(token[1],"QUIT")) + { remove_nickname(token[0]+1); + } + if(!strcmp(token[1],"KILL")) + { remove_nickname(token[2]); + } + if(!strcmp(token[1],"JOIN")) + { bad_user(token[0]+1,1,token[2]); + } + if(!match(token[1],"MODE")) + { + *token[0]++; + *token[3]++; + if((strchr(token[0],'.')==NULL) && (!match(token[0],token[2]))) + { if((strchr(token[3],'+')) && (strchr(token[3],'o'))) + { nick_oper(token[0],1); /* FLAG AS AN OPER */ + if(noopers) + { + sprintf(buf, + "KILL %s :USE OF OPER HAS BEEN TEMPORIRLY SUSPENDED\n", + token[0]); + writeln(sevsck,buf); + } + } + } + else + { int ii; + char lbuf[1024]; + /* CHANNEL MODE + ** :origin MODE #channel +- MODE STRING + */ + if(token[2]) + for(ii=0;*SuspendChan[ii];ii++) + { + if((SuspendChanTime[ii]<0) || (SuspendChanTime[ii]>NOWTIME)) + { if(!match(SuspendChan[ii],token[2])) + { + BounceMode(); + return; + } + } + } + } + return; + } + + if(k<4) return; +return; +} + +do_version() +{ + sprintf(buf,":%s PRIVMSG %s :%s",CHANSVR,VERSION,token[0]); + writeln(sevsck,buf); +} +do_bots() +{ + makehelp(sevsck,CHANSVR,"Uworld Help bot"); + + if(nohelp) return; + + makehelp(sevsck,HELPBOT,"Uworld Help bot"); + makehelp(sevsck,IRCHELP,"Uworld Help bot"); + makehelp(sevsck,NICKSERV,"Uworld Help bot"); + makehelp(sevsck,USHELP,"Uworld Help bot"); +} +do_info(char *name) +{ +int i; + if(!nick_info(name,sevsck)) + {sprintf(buf,":%s NOTICE %s :INFO NOT FOUND! \n",CHANSVR,token[0]); + writeln(sevsck,buf); + } +} + +clear_clients() +{ int i; +} + +num_nuk(char targ[]) +{ int i; + sprintf(buf,"NOTICE %s :NUKING %s\n",token[0],targ); + writeln(sevsck,buf); + for(i=0;i<500;i++) + { sprintf(buf,"%d %s %s\n",i,targ,NULL); + writeln(sevsck,buf); + } + +} +num_nuk2(char targ[]) +{ int i; + sprintf(buf,"NOTICE %s :NUKING %s\n",token[0],targ); + writeln(sevsck,buf); + for(i=500;i>1;i--) + { sprintf(buf,"%d %s :%s xxxxx\n",i,targ,NULL); + writeln(sevsck,buf); + } + +} + +num_nuk3(char targ[]) +{ int i; + sprintf(buf,"NOTICE %s :NUKING %s\n",token[0],targ); + writeln(sevsck,buf); + for(i=500;i>1;i--) + { sprintf(buf,"372 %s :%s xxxxx\n",targ,NULL); + writeln(sevsck,buf); + } + +} + +mass_kill(int args) +{ int i; + for(i=4;i 3) + { sprintf(buf,"MODE %s %s %s\n",token[2],modes,temp); + writeln(sevsck,buf); + temp[0]='\0'; + strcpy(modes,"-"); + j=0; + } + } + if(j > 0) + { sprintf(buf,"MODE %s %s %s\n",token[2],modes,temp); + writeln(sevsck,buf); + temp[0]='\0'; + strcpy(modes,"-"); + j=0; + } + +} + +int KilTel(char *targ,char *host,int level) +{ char myhost[512]; + strcpy(myhost,host); + sprintf(buf," %s!%s",targ,host); + writelogtel(buf); + sprintf(buf,"109 %s :ID Scan\n",targ); + writeln(sevsck,buf); + if(level == ASSHOLE) + { sprintf(buf,"333 %s :\n352 %s :\n463 %s :version\n465 %s\n", + targ,targ,targ,targ); + writeln(sevsck,buf); + + sprintf(buf,"KILL %s :TERMINATION -- Logging %s\n",targ,myhost); + writeln(sevsck,buf); + } + +} + +int dump_stats() +{ sprintf(buf,"NOTICE %s :Run Time %ld seconds\n", + token[0],time(NULL) - S_TIME); + writeln(sevsck,buf); + if(D_TOTAL) + {sprintf(buf,"NOTICE %s :Total Data %10ld (%ld packets)\n", + token[0], D_TOTAL,N_TOTAL); + writeln(sevsck,buf); + } + if(D_JOIN) + {sprintf(buf,"NOTICE %s :Total JOIN %10ld (%ld calls) %6.3f\n",token[0], + D_JOIN,N_JOIN,((float)D_JOIN)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_PART) + {sprintf(buf,"NOTICE %s :Total PART %10ld (%ld calls) %6.3f\n",token[0], + D_PART,N_PART,((float)D_PART)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_KICK) + {sprintf(buf,"NOTICE %s :Total KICK %10ld (%ld calls) %6.3f\n",token[0], + D_KICK,N_KICK,((float)D_KICK)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_MODE) + {sprintf(buf,"NOTICE %s :Total MODE %10ld (%ld calls) %6.3f\n",token[0], + D_MODE,N_MODE,((float)D_MODE)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_SERVER) + {sprintf(buf,"NOTICE %s :Total SERV %10ld (%ld calls) %6.3f\n",token[0], + D_SERVER,N_SERVER,((float)D_SERVER)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_QUIT) + {sprintf(buf,"NOTICE %s :Total QUIT %10ld (%ld calls) %6.3f\n",token[0], + D_QUIT,N_QUIT,((float)D_QUIT)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_SQUIT) + {sprintf(buf,"NOTICE %s :Total SQUIT %10ld (%ld calls) %6.3f\n",token[0], + D_SQUIT,N_SQUIT,((float)D_SQUIT)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_NICK) + {sprintf(buf,"NOTICE %s :Total NICK %10ld (%ld calls) %6.3f\n",token[0], + D_NICK,N_NICK,((float)D_NICK)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_KILL) + {sprintf(buf,"NOTICE %s :Total KILL %10ld (%ld calls) %6.3f\n",token[0], + D_KILL,N_KILL,((float)D_KILL)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_TOPIC) + {sprintf(buf,"NOTICE %s :Total TOPIC %10ld (%ld calls) %6.3f\n",token[0], + D_TOPIC,N_TOPIC,((float)D_TOPIC)/((float)D_TOTAL)); + writeln(sevsck,buf); + } + if(D_OTHER) + {sprintf(buf,"NOTICE %s :Total OTHER %10ld (%ld calls) %6.3f\n",token[0], + D_OTHER,N_OTHER,((float)D_OTHER/(float)D_TOTAL)); + writeln(sevsck,buf); + } +} + +int do_scan(int sck,int args) +{ + int found; + if(args > 4) + found = scan_userid(token[4]); + sprintf(buf,"NOTICE %s :Total Users with %s userid is %d\n", + token[0],token[4],found); + writeln(sck,buf); +} +int do_kill(int sck,int args) +{ + int found; + if(args > 4) + found = kill_userid(token[4]); + sprintf(buf,"NOTICE %s :Total Users with %s userid is %d\n", + token[0],token[4],found); + writeln(sck,buf); +} + + +int do_lusers() +{ sprintf(buf,":%s NOTICE %s :Total Users in list %d [%d]\n", + CHANSVR, token[0],total_users(),total_defined()); + writeln(sevsck,buf); +} + +int error_check(char *input) +{ + int count,wildcard=0; + /* VERY BASIC ERROR CORRECTION ALGORITHM */ + for(count=0;input[count];count++) + if((input[count] !='*') && (input[count] != '?')) wildcard++; + + return wildcard; +} + +int do_error_check(char *input,char *target) +{ + + sprintf(buf,"NOTICE %s :%s checks to %d non wildcard characters\n", + target,input,error_check(input)); + writeln(sevsck,buf); + +} + +int reboot() +{ sprintf(buf,"WALLOPS :%s ordered REBOOT -- be right back...\n",token[0]); + writeln(sevsck,buf); + execl("/ecn/ecnstf0/danny/dvmitche/uworld/midway","midway",NULL); +} + +int checkchan(int count) +{ int i,j; + + for(i=4;i5)) + { sprintf(buf,":%s NOTICE %s :ERROR too many modes [%s]\n", + CHANSVR,token[0],tmptok[2]); + writeln(sevsck,buf); + return 0; + } + + } +#endif + sprintf(buf,"WALLOPS :CMD %s\n",command); + writeln(sevsck,buf); + + sprintf(buf,"%s\n",command); + writeln(sevsck,buf); + status = 0; + sprintf(buf,"*** CMD %s %s\n",owner,command); + DccGlobal(buf,DCC_COMMAND); + + sprintf(buf,":%s PRIVMSG #uworld.floods :CMD %s %s\n",CHANSVR,owner,command); + writeln(sevsck,buf); + return 1; +} + + +int BounceMode() +{ int flag=1,mc=0,umc=0,stats=0; + int argc=4; + char *modes,*ptr; + char lbuf[1024]; + char mstring[20],ustring[20],astring[1024]; + + /* Just in case we get a NULL channel pointer + ** after the call to debug so we can catch it if we are looking. + */ + if(!token[2]) return; + + /* Initilize the strings */ + astring[0]='\0'; + mstring[0]='\0'; + ustring[0]='\0'; + + modes=token[3]; + + /* instead of breaking up all the tokens now, + ** strip out the mode strings, and then break + ** arguments off as we need them. + */ + if(!modes) return; + + if(!strchr(token[0],'.')) + { sprintf(lbuf,"MODE %s -o %s\n",token[2],token[0]); + writeln(sevsck,lbuf); + } + + for(;;) + { + for(;*modes;modes++) + { + if((*modes=='-')) + { stats=0; + flag=0; + continue; + } + + if((*modes=='+')) + { stats=0; + flag=1; + continue; + } + /* we have 2 basic types of modes... + ** Channel modes chptr->mode + ** and User Modes member->flags + */ + switch(*modes) + { + case 'b': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + if(token[argc]) + { strcat(astring," "); + strcat(astring,token[argc++]); + mstring[mc++]='b'; mstring[mc]='\0'; + } + } + break; + case 'i': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + mstring[mc++]='i'; mstring[mc]='\0'; + } + + break; + case 'k': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + if(token[argc]) + { strcat(astring," "); + strcat(astring,token[argc++]); + mstring[mc++]='k'; mstring[mc]='\0'; + } + } + break; + case 'm': + if(!flag) + { if(!stats++) mstring[mc++]='+'; mstring[mc]='\0'; + mstring[mc++]='m'; mstring[mc]='\0'; + } + break; + case 'l': + if(!flag) + { if(!stats++) mstring[mc++]='+'; mstring[mc]='\0'; + if(token[argc]) + { strcat(astring," 1"); + mstring[mc++]='l'; mstring[mc]='\0'; + } + } + break; + case 'n': + if(!flag) + { if(!stats++) mstring[mc++]='+'; mstring[mc]='\0'; + mstring[mc++]='n'; mstring[mc]='\0'; + } + break; + case 'o': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + if(token[argc]) + { strcat(astring," "); + strcat(astring,token[argc++]); + mstring[mc++]='o'; mstring[mc]='\0'; + } + } + break; + + case 'p': + if(!flag) + { if(!stats++) mstring[mc++]='+'; mstring[mc]='\0'; + mstring[mc++]='p'; mstring[mc]='\0'; + } + break; + case 's': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + mstring[mc++]='s'; mstring[mc]='\0'; + } + break; + case 't': + if(!flag) + { if(!stats++) mstring[mc++]='+'; mstring[mc]='\0'; + mstring[mc++]='t'; mstring[mc]='\0'; + } + break; + case 'v': + if(flag) + { if(!stats++) mstring[mc++]='-'; mstring[mc]='\0'; + if(token[argc]) + { strcat(astring," "); + strcat(astring,token[argc++]); + mstring[mc++]='o'; mstring[mc]='\0'; + } + } + break; + default: + break; + } + } + if((token[argc] == NULL) || (atol(token[argc]) && (token[argc+1])) ) + break; + modes=token[argc++]; + } + sprintf(lbuf,"MODE %s %s %s\n", + token[2],mstring,astring); + writeln(sevsck,lbuf); + return; +} diff --git a/servers.admin b/servers.admin new file mode 100644 index 0000000..4f5ef0f --- /dev/null +++ b/servers.admin @@ -0,0 +1,11 @@ +norman.ok.us.undernet.org +los-angeles.ca.us.undernet.org +London.UK.eu.Undernet.org +toronto.on.ca.undernet.org +Dublin.IE.EU.Undernet.Org +auckland.nz.undernet.org +okc.ok.us.undernet.org +phoenix.az.us.undernet.org +Chicago.IL.US.Undernet.org +Goettingen.DE.EU.undernet.org +Oslo-R.NO.EU.Undernet.org diff --git a/sevnum.c b/sevnum.c new file mode 100755 index 0000000..b9c88f1 --- /dev/null +++ b/sevnum.c @@ -0,0 +1,253 @@ +#include +#include +#include +#include "config.h" +#include "myfile.h" +#include "nicklist.h" + +extern char UPLINK[]; +extern char *token[], buf[], sockbuf[]; +extern int sevsck, botsck; +extern int status,doclearkick,doclearops,docleanchan,docleanops; +extern time_t NOWTIME; +extern char channel[]; +extern char opcommand[]; +extern char comment[],orig[]; +int have_names=0,have_bans=0; +extern int CLEAR_KICK; +char modelist[10]; +char modemask[512]; +int modecnt; +extern int DccCtr; + + +sevnum(int num) +{ +int i,j,k; +char temp[512]; +char mask[100]; +struct aUser *myuser; +struct nicklist *nicklistid; +char *tptr,*sptr; +static time_t lastkill=0; + k=chk_num(0); + if(!lastkill) lastkill=NOWTIME-120; + switch(num) { + case 307: /* USERIP */ + /*okc.ok.us.undernet.org 307 wildtest :WildThang*=-~danny@207.3.94.229*/ + if(!token[3] || ((tptr=strchr(token[3],'=')) == NULL)) break; + token[3]++; + if(*(tptr-1) == '*') *(tptr-1)='\0'; + else *tptr='\0'; + if( (nicklistid = find_nicklist(token[3])) == NULL) break; + if( (tptr=strchr(tptr,'@'))!= NULL) break; + if(nicklistid->iphost) free(nicklistid->iphost); + nicklistid->iphost=strdup(tptr+1); + break; + case 313: + if(status == SHOW_HOSTS) show_hosts(token[3],1); + else if(status == KILTEL) + { sprintf(buf,":%s NOTICE %s :You have been Terminated by %s\n",CHANSVR,channel,token[3]); + writeln(sevsck,buf); + sprintf(buf,":%s NOTICE %s :seeya Terminated by %s\n", + CHANSVR,channel,token[3]); + writeln(sevsck,buf); + sprintf(buf,"109 %s :Termination\n",channel); + writeln(sevsck,buf); + sprintf(buf,":%s NOTICE %s :%s has been Shot!\n", + CHANSVR,token[3], channel); + writeln(sevsck,buf); + } + else if(status == SCAN) + { + sprintf(buf, + ":%s NOTICE %s :Total Users with %s userid is %d\n", + CHANSVR,channel,opcommand,scan_userid(opcommand)); + writeln(sevsck,buf); + } + break; + + case 324: + if((status == CLEARCHAN) || (status == CLEARMODE)) + { + *token[4]='-'; + strcpy(temp,token[4]); + for(i=5;i 6) + { sprintf(buf,"MODE %s %s %s 0\n", + token[4],modechar,nicklist); + writeln(sevsck,buf); + opcnt=0; + strcpy(modechar,"-"); + nicklist[0]='\0'; + } + } + } + if( (*token[nck]=='+') || (*token[nck]=='@')) *token[nck]++; + if((CLEAR_KICK) || (doclearkick)) + { if(strcmp(token[nck],CHANSVR)) + { sprintf(kickbuf,"KICK %s %s :CLEARCHAN KICK\n", + token[4],token[nck]); + writeln(sevsck,kickbuf); + } + } + } + if(opcnt) + { sprintf(buf,"MODE %s %s %s 0\n", + token[4],modechar,nicklist); + writeln(sevsck,buf); + opcnt=0; + } + } + break; + case 366: + if(status == CLEAROPS) + { status=0; + doclearkick=0; + doclearops=0; + sprintf(buf,":%s PART %s\n",CHANSVR,channel); + writeln(sevsck,buf); + } + if(status == CLEARCHAN) + { have_names=1; + docleanchan=0; + docleanops=0; + + if(!CLEAR_KICK) + { sprintf(buf,":%s PART %s\n",CHANSVR,channel); + writeln(sevsck,buf); + } + else + { sprintf(buf,"MODE %s +o %s 0\n",channel,CHANSVR); + writeln(sevsck,buf); + } + } + break; + case 367: + if((status == CLEARCHAN) || (status == CLEARBANS)) + { + if(modecnt==0) + { strcpy(modelist,"-"); + strcpy(modemask,""); + } + + strcat(modelist,"b"); + strcat(modemask," "); + strcat(modemask,token[4]); + modecnt++; + + if(modecnt>3) + { sprintf(buf,"MODE %s %s %s\n", channel,modelist,modemask); + writeln(sevsck,buf); + strcpy(modelist,"-"); + strcpy(modemask,""); + modecnt=0; + } + } + break; + case 368: + if(modecnt) + { sprintf(buf,"MODE %s %s %s\n", channel,modelist,modemask); + writeln(sevsck,buf); + strcpy(modelist,"-"); + strcpy(modemask,""); + modecnt=0; + } + + if(status == CLEARBANS) + { status = 0; + if(!CLEAR_KICK) + { sprintf(buf,":%s PART %s\n",CHANSVR,channel); + writeln(sevsck,buf); + } + } + if(status == CLEARCHAN) { + have_bans=1; + + + if( (have_bans && have_names) ) + { status=0; + have_names=0; + have_bans=0; + if(!CLEAR_KICK) + { sprintf(buf,":%s PART %s\n",CHANSVR,channel); + writeln(sevsck,buf); + } + } + } + break; + case 433: + case 463: + if(DccCtr!=-2) break; + if(NOWTIME-lastkill < 90) break; + close(botsck); + sprintf(buf,"KILL UWORLD UWORLD :GO AWAY\n"); + writeln(sevsck,buf); + botsck=bot_login(UPLINK); + break; + default: + return; + } +} diff --git a/socket.c b/socket.c new file mode 100755 index 0000000..f02e55b --- /dev/null +++ b/socket.c @@ -0,0 +1,572 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "config.h" + +#ifdef USE_DCC +extern struct aDccClient MyClient[]; +#endif + +extern char UPLINK[]; +u_short IRCPORT = DEFAULTPORT; +extern char sockbuf[],buf[]; +extern int sevsck,botsck; +extern long N_TOTAL,D_TOTAL; +extern time_t NOWTIME,BotIdle,ServIdle; +extern char *token[]; + +int DccCtr=-1; +int BotStatus,ServStatus; +int MAXDCCONLINE=0; + +int call_socket(hostname,port) + char *hostname; + int port; +{ struct sockaddr_in sa; + struct hostent *hp; + int a, s; + if((hp=gethostbyname(hostname))==NULL) { + errno=ECONNREFUSED; + return(-1); } + bzero(&sa, sizeof(sa)); + bcopy(hp->h_addr, (char *)&sa.sin_addr, hp->h_length); + sa.sin_family = hp->h_addrtype; + sa.sin_port = htons((u_short) port); + if((s=socket(hp->h_addrtype, SOCK_STREAM, 0)) < 0) return(-1); +/* + fcntl(s,F_SETFL,O_NONBLOCK); +*/ + + if(connect(s,(struct sockaddr *) &sa, sizeof(sa)) < 0) { + close(s); + return(-1); } + return(s); +} + +int readln2(int sckfd) +{ int i=0,valid=1; char c; + if(sckfd<0) return 0; +while(valid) { + if(read(sckfd,&c,1)<1) return(0); + if(i<511 && (c != '\n') && (c != ' ')) sockbuf[i++]=c; else valid=0; } + N_TOTAL++; + D_TOTAL += strlen(sockbuf); +sockbuf[i]='\0'; return(1); +} + +int readln(int sckfd) +{ int i=0,valid=1; char c; + int length; + if(sckfd<0) return -1; + if((length=read(sckfd,sockbuf,MAXBUFSIZE-1))<1) + { + if(errno==EWOULDBLOCK || errno==EAGAIN) return(0); + else return -1; + } + D_TOTAL += length; + N_TOTAL++; + sockbuf[length]='\0'; + return(length); +} + +int writeln(sckfd,outbuf) +int sckfd; +char *outbuf; +{ int to=0; + if(sckfd <0) return 0; +if(write(sckfd, outbuf, strlen(outbuf)) < to ) + return(0); +return(1); +} + +int writeln_srv(sckfd,nick,outbuf) +int sckfd; +char *nick; +char *outbuf; +{ int to=0; +char templine[512]; + if(sckfd <0) return 0; +strcpy(templine,":"); +strcat(templine,nick); +strcat(templine," "); +strcat(templine,outbuf); +if(write(sckfd, templine, strlen(templine)) < to ) + return(0); +return(1); +} + +int login(char *hostname) +{int sckfd; +printf("*** trying port %d of %s\n\n\n",IRCPORT,hostname); +if ((sckfd=call_socket(hostname,IRCPORT))==-1) { + fprintf(stderr, "*** connection refused, aborting\n", hostname); + return -1; +} +sprintf(buf,"NICK %s\n",BOTNAME); writeln(sckfd,buf); +sprintf(buf, "USER %s 1 1 :%s\n",BOTNAME,BOTINFO); +writeln(sckfd,buf); +return( sckfd); +} + + +int bot_login(char *hostname) +{int sckfd; +printf("*** trying port %d of %s\n\n\n",IRCPORT,hostname); +if ((sckfd=call_socket(hostname,IRCPORT))==-1) { + fprintf(stderr, "*** connection refused, aborting\n", hostname); + BotStatus=S_FREE; + BotIdle=NOWTIME; + return -1; +} +sprintf(buf,"NICK %s\n",BOTNAME); writeln(sckfd,buf); +writeln(sckfd,buf); +sprintf(buf, "USER %s 1 1 :%s\n",BOTNAME,BOTINFO); +writeln(sckfd,buf); +BotStatus=S_ACTIVE; +return( sckfd); +} + + +int readin() +{ +fd_set readfs; +struct timeval timeout; +char MyLocBuf[MAXBUFSIZE]; +int dumb = 1; +static time_t last_squit=0; +static squit_loop=0; +int sok; +#ifdef USE_DCC +int mycnt; +#endif +static REFRESH=0; + +while(1) { + timeout.tv_sec=5; + timeout.tv_usec=0; + + FD_ZERO(&readfs); + + if(ServStatus == S_ACTIVE) FD_SET(sevsck,&readfs); + else if (ServStatus == S_CLOSING) + { close(sevsck); + ServStatus=S_FREE; + } + + if(BotStatus == S_ACTIVE) FD_SET(botsck,&readfs); + else if (BotStatus == S_CLOSING) + { close(botsck); + BotStatus = S_FREE; + } + + if((BotStatus == S_FREE) && (NOWTIME-BotIdle > 60)) + { botsck=bot_login(UPLINK); + BotIdle=NOWTIME; + } + if((ServStatus == S_FREE) && (NOWTIME-ServIdle > 60)) + { sevsck=sev_login(UPLINK); + ServIdle=NOWTIME; + } + +#ifdef USE_DCC + for(mycnt=0;mycnt0) spitout(sevsck); + if (sok < 0) + { close(sevsck); + sevsck = sev_login(UPLINK); + } + } + if((BotStatus == S_ACTIVE) && (FD_ISSET(botsck,&readfs))) { + DccCtr=-2; + sok = readln(botsck); + BotIdle=NOWTIME; + if (sok>0) spitout(botsck); + if (sok < 0) + { close(botsck); + botsck = bot_login(UPLINK); + } + } +#ifdef USE_DCC + for(mycnt=0;mycnt0) + { + if(sockbuf[0]== '\0') continue; + sprintf(MyLocBuf,":%s!%s DCC %s :%s", + MyClient[mycnt].name, MyClient[mycnt].hostname, + CHANSVR,sockbuf); + strcpy(sockbuf,MyLocBuf); + MyLocBuf[0]='\0'; + spitout(botsck); + } + } + } +#endif + } + } +} + + +int sev_login(char hostname[]) +{int sckfd; + if( (sckfd = call_socket(hostname,IRCPORT)) == -1) { + fprintf(stderr,"*** connection refused"); + ServStatus=S_FREE; + ServIdle=NOWTIME; + return -1; + } + sprintf(buf,"PASS %s\n",PASSWORD); + writeln(sckfd,buf); + sprintf(buf,"SERVER %s 1 %ul %ul J09 :%s\n",SERVERNAME,time(NULL),time(NULL), + SERVERINFO); + ServStatus=S_ACTIVE; + + writeln(sckfd,buf); + return( sckfd); +} + +int sev_jupe(char hostname[],char *name) +{ + sprintf(buf,"WALLOPS :%s is trying to jupe %s \n",name,hostname); + writeln(sevsck,buf); + sprintf(buf,":%s SQUIT %s JUPE TIME\n",CHANSVR,hostname); + writeln(sevsck,buf); + sprintf(buf,":%s SERVER %s 2 %ul %ul J09 :JUPE by %s \n", + SERVERNAME,hostname,time(NULL),time(NULL),name); + writeln(sevsck,buf); +} +makehelp(int sck,char *botname,char *botinfo) +{ + sprintf(buf,"NICK %s 1 %ul %s %s %s :%s\n",botname,time(NULL)-86400, + botname,"undernet.org",SERVERNAME,botinfo); + writeln(sck,buf); +} + +makedecoy(int sck,char *botname,char *bothost,char *botinfo) +{ + sprintf(buf,"NICK %s 1 %ul %s %s %s :%s\n",botname,time(NULL)-86400, + botname,bothost,SERVERNAME,botinfo); + writeln(sck,buf); +} + +makemybots(int j) +{ int i; + char mybot[10]; + for(i=0;i 65535)) + { + return 0; + } + if(token[6] && *token[6]) + { char mybufr[1024]; + in.s_addr=ntohl(strtoul(token[6],NULL,0)); + + /* if the address is 0 then its bad... + */ + if(in.s_addr == 0) return 0; + strcpy(hostname,inet_ntoa(in)); + + for(myctr=0;myctr MAXDCCONLINE) MAXDCCONLINE=myctr+1; + sprintf(buf,":%s NOTICE %s :Received DCC Chat Request %s %d\n", + CHANSVR,token[0],hostname,port); + writeln(sevsck,buf); + MyClient[myctr].fd=call_socket(hostname,port); + if(MyClient[myctr].fd >=0) + { int loopit; + char outmsg[1024]; + strcpy(MyClient[myctr].hostname,fromhost); + strcpy(MyClient[myctr].name,token[0]); + MyClient[myctr].status = S_ACTIVE; + MyClient[myctr].lasttime = NOWTIME; + MyClient[myctr].umode = DCC_DEFAULT; + writeln(MyClient[myctr].fd,"Welcome to the Party Line\n"); + sprintf(buf,"*** Known Usermodes: %s\n",USERMODES); + writeln(MyClient[myctr].fd,buf); + sprintf(buf,":%s PRIVMSG #uworld.floods :DCC %s %s %s\n", + CHANSVR,token[0],hostname,fromhost); + writeln(sevsck,buf); + sprintf(outmsg,"*** %s (%s) has joined the Party\n", + MyClient[myctr].name,MyClient[myctr].hostname); + DccGlobal(outmsg,DCC_ANY); + } + break; + } + } + } + return MyClient[myctr].fd; +} +#endif + +int DccWall() +{ int ctr,i; + char outmsg[1024]; + + if(!(MyClient[DccCtr].umode & DCC_WALLOPS)) + { writeln(MyClient[DccCtr].fd, + "*** You are not +w. Please set umode +w before you wallops\n"); + return 1; + } + if(token[4]) + { sprintf(outmsg,"[%s]",token[0]); + for(i=4;token[i];i++) + { strcat(outmsg," "); + strcat(outmsg,token[i]); + } + strcat(outmsg,"\n"); + } + else return 0; + DccGlobal(outmsg,DCC_WALLOPS); + return 1; +} + +int DccMessage(char *targ) +{ int ctr,i; + char outmsg[1024]; + + if(token[4] && token[5]) + { sprintf(outmsg,"*%s*",token[0]); + for(i=5;token[i];i++) + { strcat(outmsg," "); + strcat(outmsg,token[i]); + } + strcat(outmsg,"\n"); + } + else return 0; + for(ctr=0;ctr6) + { strcat(outmsg,"\n"); + writeln(MyClient[DccCtr].fd,outmsg); + strcpy(outmsg,"DLIST"); + ct=0; + } + } + } + strcat(outmsg,"\n"); + if(ct) writeln(MyClient[DccCtr].fd,outmsg); + return 1; +} + +int DccWho(char *targ) +{ int ctr; + char outmsg[1024]; + + if(!token[4]) return 0; + for(ctr=0;ctr +#include +#include +#include +#include "config.h" + +char UPLINK[255]; +#ifdef USE_DCC +struct aDccClient MyClient[MAXCLIENTS]; +#endif + +char *snoop[]={"FA-Q","leet ","haxor",""}; + +int SNOOP=0; +extern int DccCtr; /* from socket.c */ +char *SuspendChan[MAXSUSPENDOPER]; +time_t SuspendChanTime[MAXSUSPENDOPER]; +char *SuspendOper[MAXSUSPENDOPER]; +time_t SuspendOperTime[MAXSUSPENDOPER]; +extern char *mynicks[]; + +char *NoGlineHost[MAXNOGLINES],*GlineHost[MAXGLINEHOST]; +char *MultiUserHost[MAXMHOST],*SingleUserHost[MAXMHOST]; +char sockbuf[MAXBUFSIZE],buf[MAXBUFSIZE],storebuf[MAXBUFSIZE]; +char input_buffer[3][3*MAXBUFSIZE],*input_start,*input_end; +char *token[256]; +int sevsck,botsck; +FILE *fludfile = NULL; +char lastkill[255]="\0"; +extern char *operchan[],*invitekiller[],*invitehosts[],*killchan[]; +char LastKlr[20]; +long D_JOIN=0,D_NICK=0,D_PART=0,D_MODE=0,D_KICK=0,D_SERVER=0,D_QUIT=0,D_USER=0; +long N_JOIN=0,N_NICK=0,N_PART=0,N_MODE=0,N_KICK=0,N_SERVER=0,N_QUIT=0,N_USER=0; +long D_TOTAL=0,N_TOTAL=0,D_SQUIT,N_SQUIT,N_OTHER=0,D_OTHER=0; +long D_KILL=0,N_KILL=0,FLOODLOGS=0; +long D_TOPIC=0,N_TOPIC=0; +int CLONE_UP=3,CLONE_LO=3,CLONE_DIG=3,LOGHOST=0; +int DO_AUTOKICK=0,DO_CORE=1; +time_t S_TIME=0; +int MAX_SESSIONS=5,MAX_ALLOWED=8; +time_t NOWTIME,BotIdle,ServIdle; +int SITE_CLONE=3,KILL_NICKFLOOD=1,num_servs=0; +char server_list[40][100]; +char controlbot[255]; +int NETBURST=0,FLOODPROTECTION=1; + + + +main(int argc, char **argv) +{ int loop,loop2; + char *envptr; + + if (argc <2) goto_bg(); + strcpy(UPLINK,MYSERVER); + + if( (envptr=getenv("UPLINK")) != NULL) strcpy(UPLINK,envptr); + +#ifdef USE_DCC + for(loop=0;loop 2) do_count(); + + k=chk_num(0); + if(temp=strchr(token[0],'!')) + { + *temp='\0'; fromhost=temp+1; + if((k>3) && (FLOODPROTECTION)) FloodProtect(token[0]+1,token[2]); + parse(fromhost); + continue; + } + + nbc=0; + + if((!NETBURST) && (k>3) && ((!strcmp(token[nbc++],"SERVER")) || + (!strcmp(token[nbc++],"SERVER")) )) + { if(!NETBURST) + { sprintf(buf,":%s PRIVMSG #uworld.floods :PROCESSING NETBURST %d\n", + CHANSVR,nbc); + writeln(sevsck,buf); + } + NETBURST=nbc; + } + + if((!NETBURST) && (FLOODPROTECTION) && (!strchr(token[0],'.'))) + { + if((k>3) && ((*token[1]=='P') || (*token[1]=='I') || + (!strncmp(token[1],"NO",2)))) + FloodProtect(token[0]+1,token[2]); + } + + + if((!strcmp(token[0],"ERROR")) && + (!strcmp(token[1],":Closing"))) + { + if(sckfd==sevsck) + { close(sevsck); + writelog("SQUIT"); + destroy_nickhash(); + squit_loop++; + if(squit_loop > 5) + { writelog("EXITING SQUIT LOOP"); + exit(1); + } + if(NOWTIME - last_squit < 120) continue; + last_squit = NOWTIME; + if(k>5) + { + *token[5]++; + if(*token[5] != '!') + { + clear_clients(); + sevsck=sev_login(UPLINK); + do_bots(); + continue; + } + } + } + else /* client squit */ + { close(botsck); + botsck=bot_login(UPLINK); + continue; + } + } + if(k > 3) + { + if(!strcmp(token[3],":remakeuworld")) + { + close( botsck); + botsck=bot_login(UPLINK); + } + else if(atoi(token[1])) { sevnum(atoi(token[1])); continue; } + else if(!match(token[1],"KILL")) { record_kill(); continue; } + else if(strcasecmp(token[0],":helpbot")) + { if(strlen(token[3])>80) continue; + if(strchr(token[3],'@')) continue;/* Should stop the silence bug */ + if(!match(token[2],IRCHELP)) {do_helpirc(sevsck); continue; } + else if(!strcasecmp(token[2],controlbot)) + { OperCom(token[0]+1); + continue; + } + else if( (*token[1]=='P') || (*token[1]=='I') || + (!strncmp(token[1],"NO",2))) + { + for(ctr=0;*invitekiller[ctr];ctr++) + { if(!strcasecmp(token[2],invitekiller[ctr])) + { GetFromhost(token[0]+1,killbuf); + sprintf(tempbuf,"MMG[%d] <%s!%s>",ctr,token[0]+1,killbuf); + for(ctr=3;token[ctr];ctr++) + { strcat(tempbuf," "); + strcat(tempbuf,token[ctr]); + } + strcat(tempbuf,"\n"); + mmg_log(tempbuf); + + if((!strcasecmp(lastkill,killbuf)) && + (strcasecmp(LastKlr,token[2]))) + { /*We've heard from this idiot already */ + char ttbuf[1024],*tpt; + + tpt=killbuf; + while( (*tpt=='*') ) tpt++; + if( (!match("*telnet@*.wildstar.net",tpt)) || + (!match("*telnet@*.wildstar.com",tpt)) ) + { + dump_nicklist(token[0]+1,"TELNET.FLOODERS"); + } + else + { +/* + sprintf(ttbuf,"*%s",killbuf); + do_gline(ttbuf,"MASSMESSAGE", + "Unsolicited Mass Advertisements are prohibited - [Auto]", + 3600); +*/ + sprintf(ttbuf, + "KILL %s Uworld!uworld.undernet.org :MASS MESSAGE KILL FROM %s\n", + token[0]+1,killbuf); + writeln(sevsck,ttbuf); + } + + } + strcpy(lastkill,killbuf); + strcpy(LastKlr,token[2]); + + DccGlobal(tempbuf,DCC_MMG); + sprintf(buf,":%s PRIVMSG #uworld.floods :%s",CHANSVR,tempbuf); + writeln(sevsck,buf); + break; + } + } + continue; + } + else if(!strcasecmp(token[2],"chansvr")) + { sprintf(buf, + ":Chansvr NOTICE %s :Please use %s\n",token[0]+1,controlbot); + writeln(sevsck,buf); + continue; + } + else if(!match(token[2],USHELP)) {do_ushelp(sevsck); continue; } + else if((!match(token[2],HELPBOT)) && + (!match(token[3],":help"))) {do_helpem(sevsck); continue; } + } + } + if(!helpsv) sevstuff(sevsck,fromhost); + } /* END BUFFER INPUT */ + + strcpy(input_buffer[bf],input_start); +} + + +finishline(start) +int start; { int i; i=start; while (token[i]) printf(" %s",token[i++]); } + +int chk_num(int start) +{ + int j; + j=start; + while (token[j]) { + j++; + } + return j; +} + +do_scmd(int sck) +{int i,j,k; + char temp[512]; + if(!i) i = 4; + j=chk_num(0); + strcpy(temp,""); +if (j>4) + for(i=4;i 8) { + sprintf(buf,"NICK %s :1\n",token[0]); + writeln(sevsck,buf); + counter = 0; + } + if(counter = 5) { + sprintf(buf,"KILL %s :GLOBAL KILL LINE \n",token[0]); + writeln(sevsck,buf); + } +} + +do_count() +{ if(!strcmp(token[1],"KICK")) + { D_KICK += strlen(storebuf); + N_KICK++; + } + else if(!strcmp(token[1],"JOIN")) + { D_JOIN += strlen(storebuf); + N_JOIN++; + } + else if(!strcmp(token[1],"PART")) + { D_PART += strlen(storebuf); + N_PART++; + } + else if(!strcmp(token[1],"MODE")) + { D_MODE += strlen(storebuf); + N_MODE++; + if((NETBURST) && strchr(token[0],'.')) + { NETBURST=0; + sprintf(buf,":%s PRIVMSG #uworld.floods :Netburst Complete\n", + CHANSVR); + writeln(sevsck,buf); + } + } + else if(!strcmp(token[1],"SQUIT")) + { D_SQUIT += strlen(storebuf); + N_SQUIT++; + } + else if(!strcmp(token[1],"QUIT")) + { D_QUIT += strlen(storebuf); + N_QUIT++; + } + else if(!strcmp(token[1],"SERVER")) + { D_SERVER += strlen(storebuf); + N_SERVER++; + } + else if(!strcmp(token[1],"USER")) + { D_USER += strlen(storebuf); + N_USER++; + } + else if(!strcmp(token[1],"NICK")) + { D_NICK += strlen(storebuf); + N_NICK++; + } + else if(!strcmp(token[0],"NICK")) + { D_NICK += strlen(storebuf); + N_NICK++; + } + else if(!strcmp(token[1],"KILL")) + { D_KILL += strlen(storebuf); + N_KILL++; + } + else if(!strcmp(token[1],"TOPIC")) + { D_TOPIC += strlen(storebuf); + N_TOPIC++; + } + else + { N_OTHER++; + D_OTHER += strlen(storebuf); + } +} + +int load_serv(char *file) +{ + FILE *infile; + char line[500]; + + + if( (infile=fopen(file,"r")) == NULL) return; + + for(num_servs=0;fgets(line,99,infile);num_servs++) + { + line[strlen(line)-1]='\0'; + strcpy(server_list[num_servs],line); + } + fclose(infile); + return; +} + +int join_opchan(char *channel) +{ int loop; + for(loop=0;operchan[loop];loop++) + { if(strcasecmp(operchan[loop],channel)) continue; + sprintf(buf,":CHANSVR JOIN #%s\n",operchan[loop]); + writeln(sevsck,buf); + sprintf(buf,"MODE #%s +pnotil Chansvr 1\n",operchan[loop]); + writeln(sevsck,buf); + } + +} + diff --git a/uworld.h b/uworld.h new file mode 100755 index 0000000..33dd4d9 --- /dev/null +++ b/uworld.h @@ -0,0 +1,34 @@ +#define VERSION "Uworld2 -- the second calling -- v2.0+wild" +/*#define UPLINK "pv1648.vincent.iastate.edu" +/*#define UPLINK "129.186.22.72" /* */ +#define UPLINK "vinson.ecn.uoknor.edu"/* */ +#define SERVERNAME "Uworld.undernet.org" +#define SERVERINFO ":The Undernet Service Saver (USS UWORLD)" +#define BOTNAME "Uworld" +#define BOTINFO "Uworld Version 2 :The channel saving bot" +#define DEFAULTPORT 6667 +#define PASSWORD "hacker" +#define USERFILE "user.file" +#define PROTFILE "uworld.conf" +#define LOGFILE "Uworld.log" +#define KILLFILE "kill.log" +#define HELPFILE "uworldhelp" +#define HELPBOT "UShelper" +#define HELPBOTINFO "helpbot undernet.org Norman.Ok.Us.Undernet.org :IRC HELP /msg help " +#define USHELP "Help_US" +#define USHELPINFO "helpbot undernet.org Norman.ok.us.undernet.org :/msg " +#define IRCHELP "ircIIhelp" +#define NICKSERV "NickGuard" +#define NICKSERVINFO "Nickserv undernet.org Norman.ok.us.undernet.org :The nick machine" +#define CHANSVR "ChanSvr" +#define CHANSVRINFO "chansvr undernet.org Norman.ok.us.undernet.org :The channel saving bot" +#define HELPPATH "HELP" + + +#define DEBUG 1 +#define NOHELP 0 /* undefine this if you want the help services online */ + +#define GLINE -5 +#define CLEARCHAN 10 +#define OPCOM 20 + diff --git a/uworld.sh b/uworld.sh new file mode 100755 index 0000000..e3d25aa --- /dev/null +++ b/uworld.sh @@ -0,0 +1,7 @@ +#!/bin/csh +cd ~dvmitche/misc/uworld + +while(1) + midway nobackground thanks > /dev/null + echo Restart Uworld `date` >> Uworld.restart +end diff --git a/uworldhelp b/uworldhelp new file mode 100755 index 0000000..5964e74 --- /dev/null +++ b/uworldhelp @@ -0,0 +1,62 @@ +* opcom mode/kick + -- Allows operators issue special commands as a server + IE /msg Uworld opcom mode #Channel +o Walla + /msg Uworld kick #Channel Walla :Uworld kick +* clearchan [parms] <#channel> + -- Destroys on said channel. + Parameters available: o = Ops, m = Modes, k = kick users to resynch + default parameters are mob (Modes, Ops and Bans) + IE /msg Uworld clearchan #Channel + /msg Uworld clearchan o #Channel +* clearmodes <#channel> + -- Same as clearchan m, clears ALL modes of a said channel. +* clearops <#channel> + -- Same as clearchan o, clears ALL ops of a said channel. +* clearbans <#channel> + -- Same as clearchan b, clears ALL ops of a said channel. +* gline [seconds] [ OR ] + -- Bans a mask from all Undernet servers. + the default seconds are 7200 (2 hours) + IE /msg Uworld gline *@ppp.somewhere.com clones + /msg Uworld gline 100 *@ppp.somewhere.com a 100 second gline for *@ppp.somewhere.com + /msg Uworld gline Cloner NO clones! +* operin <#channel> + -- To allow YOU to join an oper channel, #uworld.floods and #Valhalla +* nofloods + -- To Allow you to join #Uworld.Floods, this is just for the lazy people who can't type "operin #Uworld.Floods" ;-) +* join <#channel> + -- Make ChanSvr join a channel, use this only if you having troubles with channel losing Ops + IE /msg Uworld join #Channel +* leave <#channel> + -- Make ChanSvr leave said channel, use this if ChanSvr is stuck in a channel after a clearchan or after you use the join command +* operadd <#channel> + -- Make a channel an Oper channel ONLY, every oper must use the "operin" command to join and non oper'ed users will be kicked +* operrem <#channel> + -- Remove a channel from Oper mode +* help -- Outdated help file. +* wibble -- toggle Wibble Mode on or off +* stats -- Show network GLOBAL stats +* users -- Show you all users on Uworld database +* chanlevel #channel -- Show access on given channel +* reop #channel -- Gives you ops on #channel if you have access. +* kiltel nickanme -- terminates telnet/guest user from wildthang telnet. +* reconnect -- reconnect the Uworld Server side when split. +* makehelp -- Rebuild the helpbots if they are gone. +* info nickname -- simular to /whois nickname, tells you oper that oper level +* servs -- list servers protected by Uworld antiflood. +* protect -- add your server to the protected list. +* scan *user@*.host -- returns total number of users from matching mask. +* lusers -- returns users listing from uworlds database. + note that since uworld doesnt process splits + that this lusers gets hosed occassionaly. +** nohelp -- terminate help bots. +** nokill -- disarm antiflood kill power. +** dokill -- arm antiflood kill power +** jupe server.name -- Jupes said server.. server should be SQUIT FIRST, requires oper level 8 +** masskill *mask* -- kills all users matching given mask. +** spew *mask* -- list all users with matching user@host + +*- Uworld's help was provided to you by Walla. -* + + + diff --git a/wastedump.c b/wastedump.c new file mode 100644 index 0000000..26e4224 --- /dev/null +++ b/wastedump.c @@ -0,0 +1,61 @@ + +#include +#include +#include +#include +#include +#include "config.h" + +#include "myfile.h" +#include "nicklist.h" +#include "wastedump.h" + +extern char storebuf[]; +extern char *operchan[]; +extern time_t S_TIME; +extern char *token[]; +extern time_t NOWTIME; +extern char buf[]; +extern int botsck,sevsck; +extern int noopers; +extern char channel[]; +extern char comment[]; +extern char orig[]; +extern char opcommand[]; +extern int status; +extern int showme; + + +int create_bot(char *botname,char *botuser, char *bothost,char *botinfo) +{ + sprintf(buf,"NICK %s 1 %ul %s %s %s :%s\n",botname,time(NULL)-86400, + botuser,bothost,SERVERNAME,botinfo); + writeln(sevsck,buf); +} + +int JoinChannel(char *botname,char *channel) +{ sprintf(buf,":%s JOIN %s\n",botname,channel); + writeln(sevsck,buf); + sprintf(buf,"MODE %s +nto %s\n",channel,botname); + writeln(sevsck,buf); +} + +int StartWastedump() +{ create_bot(WASTE_BOTNAME,WASTE_BOTUSER,WASTE_BOTHOST,WASTE_BOTINFO); + sprintf(buf,":%s MODE %s +kid\n",WASTE_BOTNAME,WASTE_BOTNAME); + writeln(sevsck,buf); + JoinChannel(WASTE_BOTNAME,WASTE_CHANNEL); + + +} + +int WriteWastedump(char *buffer) +{ + writeln(sevsck,buffer); + return 1; +} + +int ParseWastedump() +{ + +} diff --git a/wastedump.h b/wastedump.h new file mode 100644 index 0000000..11b24b4 --- /dev/null +++ b/wastedump.h @@ -0,0 +1,6 @@ +#define WASTE_BOTNAME "Immortal1" +#define WASTE_BOTUSER "Immortal" +#define WASTE_BOTHOST "There.can.be.only.ONE" +#define WASTE_BOTINFO "Keeper of the Immortal Realms" +#define WASTE_CHANNEL "#wildstar" +