spamguard-devel/0040755000175000000000000000000010077146560013151 5ustar muratwheelspamguard-devel/tr/0040755000175000000000000000000010077146562013600 5ustar muratwheelspamguard-devel/tr/BENIOKU0100644000175000000000000000271110077142152014604 0ustar muratwheel spamGuard 1.7 BENIOKU --------------------------------------------- Gnmzde e-posta sistem yneticilerinin hemen hemen en byk problemi spamdir. Bu yzden EnderUNUX takm mail kayt dosyalarnz inceleyerek buradaki tehlikeli aktiviteleri monitr eden bir program yazd. SpamGuard 'in tek amac etrafta spam yapmaya alanlar durudurmaktr. Zamanla program Qmail (syslog ve multilog) sendmail ve posftix 'i destekleyecek ekilde yazld. Mantik: ---------- 1. spamGuard crontab vasitasiyla belirli zaman araliklari ile calistirilir. 2. spamGuard mailloglarini tarayarak hangi kullanicin ne kadar mail gonderdigini bulur. 3. spamGuard ignore dosyasindan onemsenmeyecek mail adreslerini ve badmailfiles dosyasini yukler. 4. Esik degerini asan kullanicilar spam eden olarak belirlenir ve badmail dosyasina eklenir (Esik degeri olarak 3 degisik deger vardir: warning, block and paranoid) 5. Eger spam eden birisi belirlenmisse bu sistem yoneticisine mail ile bildirilir. 6. Sendmail icin access dosyasinin hash edilmisi de uretilir. spamGuard 85 MB lik bir log dosyasini 10 saniyeden az bir surede isler. Test edilen sistemler: FreeBSD 4-STABLE Solaris 2.7-Sparc Solaris 8-Sparc Slackware Linux 8.0 RedHat 7.2 Digital UNIX Eger sisteminiz DigitalUnix ise lutfen BENIOKU.DigitalUnix dosyasina bakin Sorulariniz icin: spamguard-subscribe@yahoogroups.com EnderUNIX SDT @ Istanbul/Turkey roots@enderunix.org - http://www.enderunix.org Tue Jul 20 10:02:43 EEST 2004 spamguard-devel/tr/BENIOKU.DigitalUnix0100644000175000000000000000154710077142152017032 0ustar muratwheelDigital Unix. -------------------- Digital Unix'te spamGuard calistirilinca, spamGuard su sekilde bir hata mesaji dondururse: [1200]#/usr/local/bin/spamguard -w 50 -b 100 -p 2000 Unaligned access pid=31946 va=0x14000d23c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Unaligned access pid=31946 va=0x14001607c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Unaligned access pid=31946 va=0x14001631c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Cozum: --------- SpamGuard'i calistirmadan once "/usr/bin/uac p 0" (tirnak isaretleri yok) komutunu calistirin. crontab girdiniz su sekilde olmali: (hepsi bir satirda) 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/uac p 0 ; /usr/local/bin/spamguard -w 50 -b 100 -p 2000 Krediler: -------- "Juan Enciso" , bu cozumu urettigi icin tesekkurler. spamguard-devel/tr/COPYING0100644000175000000000000000355010077142152014622 0ustar muratwheel Copyright (c) 2004 , EnderUNIX SDT All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the EnderUNIX Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EnderUNIX Software Development Team @ Turkiye Tue Jul 20 10:03:07 EEST 2004 spamguard-devel/tr/DEGISIKLIKLER0100644000175000000000000000412710077142152015475 0ustar muratwheel * Development * Tue Jul 20 10:03:19 EEST 2004 Version 1.7 cikti * Tue May 4 18:03:21 EEST 2004 Version 1.7-BETA cikti - stat hatasi duzeltildi. - #@[] adresi hesaplanmaz. - paranoid mode adresin daha onceden badmailfrom'a eklenip eklenmedigini kontrol eder. - adreslerdeki '<' ve '>' karakerlerini kaldirma (rmspace) - Bir cok guvenlik duzeltmesi - Parser modulu bastan yazildi - autogen.sh en bastan yazildi * Mon Oct 7 10:58:20 EEST 2002 Version 1.6 cikti: - Parser modulu Isoqlog'unki ile degisitrildi. - spamguard.conf dosyasi daha kullanici dostu hale getirildi. AYRICA konfigurasyon parametreleri calisma esnasinda ayarlanabilecek hale getirildi. - MTA altdizini kaldirildi. Kurulum cok kolay hale getirildi. * Fri Mar 15 06:20:12 EET 2002 Version 1.5 teki degisiklikler: - Solaris, Free/Net/Open BSD, Digital Unix, Linux uzerinde testler yapildi. - ignore dosyasini islerkenki bug duzeltildi. Eger 1.4 versiyonunu kullaniyorsaniz siddetle 1.5 kullanmainizi salik veriyoruz. - Yeni Ozellik: 3 degisik esik degeri eklendi warning, block and paranoid. - Kod temizligi yapildi * Thu Feb 21 02:13:46 EET 2002 Version 1.4 taki degisiklikler: - Performanstan dolayi linked listler hash tablolari ile degistirildi. - Postfix destegi eklendi. - Bazi hafiza akitimlari temizlendi. * Sun Feb 10 16:19:07 EET 2002 Version 1.3 teki degisiklikler: - Genel fonksiyonlar MTA 'ya bagli kodlardan arindirildi. - Qmail syslog destegi verildi - Sendmail destegi verildi - Code'a onceki kaldigi yeri hatirlamasi icin gerekli degisikliker yapildi. Boylece log dosyalarinizi rotate etmenize gerek kalmadi * Tue Feb 5 00:43:45 EET 2002 Version 1.2 deki degisiklikler: - Ignore dosyasi icin wildcard destegi verildi - Hafiza akitimlari temizlendi. (Geoff Mitchell 'e tesekkurler) - SPAMNUMBER artik code'un icine gomulu degil. Boylece istediginiz gibi SPAMNUMBER sayisini degistireblirsiniz. * Tue Feb 2 02:30:40 EET 2002 Bakim versiyonu: 1.1 * Thu Jan 31 03:32:10 EET 2002 Ilk public versiyon spamguard-devel/tr/KURULUM0100644000175000000000000000625010077142152014656 0ustar muratwheelEnderUNIX spamGuard 'i install etmek icin ==================================================================== Bu dosya spamGuard 'i UNIX sisteminizde nasil derleyeceginizi ve kuracaginizi anlatmaktadir. Daha detayli bilgiyi EnderUNIX web sitesinde bulabilirsiniz (http://www.enderunix.org/spamguard/spamguard-1.6/tr/KURULUM). En azindan bu dosyayi okumaniz ya da bir goz gezdirmeniz tavsiye edilmektedir! Derlemek ve KURMAK ----------------------------------------------- 1. Yazilimi aciniz ve dizini degistiriniz: % tar xfz spamguard-VERSION.tar.gz % cd spamguard-VERSION (VERSION 'u gerekli versiyon kelimesi ile degistiriniz). Haa bu arada bu dosyayi okuyorsaniz zaten bunu yapmissiniz demektir :) 2. ./configure 3. Kullandiginiz konsolda: % make Eger hersey duzgun giderse butun binaryler derlenmis olur. 4. Derlediginiz yazilimi kurun Bunu yapmak icin yetkili bir kullanici olmak zorundasiniz (mesela root) % su root -c 'make install' (Linux sistemler icin gecerli komut) Binary dosyasi /usr/local/bin dizinine install edilecektir. Ayrica spamguard.conf dosyasi da /usr/local/etc dizine kurulacaktir. 5. SpamGuard dosyasini editeleyin. Eger spamGuard konfigurasyon dosyasi /usr/local/etc den baska bir dizindeyse calisma esnasinda -f switch 'i ile bunu belirtmelisiniz. logtype = "qmail" Log tipiniz: Ornek olarak qmail, sendmail, postfix logfile = "/var/log/qmail/current" Log dosyalarinizin yeri: Burada onemli olan bir mevzuda log dosyalarinizin buyuklugunu mumkun oldugunca buyuk tutun. Mesela qmail'i multilog destegi ile kullaniyorsaniz qmail-send/log/run file dosyasinda s parameteresi ile oynamalisiniz (Hepsi bir satirda olacak sekilde) #!/bin/sh exec /usr/local/bin/setuidgid qmaill \ /usr/local/bin/multilog t s5000000 \ /var/log/qmail if you're using syslog, change the rotate size. ignorefile = "/usr/local/etc/spam-ignore.txt" # Ignore dosyanizin yeri. badmailfile = "/var/qmail/control/badmailfrom" MTA 'nizin blacklist dosyasinin yeri. Ornek olarak: /var/qmail/control/badmailfrom; eger sendmailse, /etc/mail/access; eger postfix kullaniyorsaniz /usr/local/etc/postfix/access sysadmin = "spam-notify@somedomain.com" Spam aktiviteleri ile ilgili maili alacak sistem yoneticisi. hostname = "enderunix.org" Eger gonderen kisiminda sadece kullanici adi varsa bu hostname gonderen kismina eklenecektir. Mesela from = ise boylece mail adresi from = olacaktir. mail_command = "/usr/bin/mail" Mail binarysinin oldugu dosya. Solaris kullanicilar mail yerine mailx komutunu tercih etmelidirler! makemap_command = "makemap hash /etc/mail/access < /etc/mail/access" Sadece Postfix ve Sendmail kullanicilari icin. statfile = "/usr/local/etc/spamguard.stat"; Stat dosyasi. spamGuard'in kendisinin calismasi icin. wcnt = 40 Warning esik degeri. bcnt = 50 Block esik degeri pcnt = 100 Paranoid esik degeri 6. Hepsi bu kadar simdi KURULUM-SONRASI dokumanini kurulum sonrasi ne yapilmasi gerektigini ogrenmek icin okuyun. http://www.enderunix.org Tue Jul 20 10:04:50 EEST 2004 spamguard-devel/tr/KURULUM-SONRASI0100644000175000000000000000150310077142152015766 0ustar muratwheelEnderUNIX spamGuard v.1.7 icin kurulum sonrasi dokumani: ==================================================================== Bu dosya spamGuard 'i UNIX sistemlerde calistirmak icin gerekli kisimlari icerir. Daha detayli bilgi EnderUNIX'in web sitesinde: (http://www.enderunix.org/spamguard/spamguard-1.6/tr/KURULUM-SONRASI) bulabilirsiniz. Gerekli seyler: ----------------------------------------------- Crontab 'a spamGuard'in calisabilmesi icin gerekli satirlari eklemek icin asagidaki komutu calisitirin: # crontab -e Ve asagidaki satirlari ekleyin: 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/local/bin/spamguard spam-ignore.txt.sample dosyasini da fikir sahibi olmak icin bakiniz. EnderUNIX Software Development Team @ Istanbul/Turkey roots@enderunix.org - http://www.enderunix.org Tue Jul 20 10:05:01 EEST 2004 spamguard-devel/tr/Makefile.am0100644000175000000000000000353507746415455015650 0ustar muratwheel#EnderUNIX spamguard/tr Makefile.am file EXTRA_DIST = BENIOKU BENIOKU.DigitalUnix COPYING DEGISIKLIKLER KURULUM KURULUM-SONRASI YAPILACAKLAR YAZARLAR install-data-local: $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/BENIOKU ${prefix}/share/doc/spamguard/tr/BENIOKU $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/BENIOKU.DigitalUnix ${prefix}/share/doc/spamguard/tr/BENIOKU.DigitalUnix $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/COPYING ${prefix}/share/doc/spamguard/tr/COPYING $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/DEGISIKLIKLER ${prefix}/share/doc/spamguard/tr/DEGISIKLIKLER $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/KURULUM ${prefix}/share/doc/spamguard/tr/KURULUM $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/KURULUM-SONRASI ${prefix}/share/doc/spamguard/tr/KURULUM-SONRASI $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/YAPILACAKLAR ${prefix}/share/doc/spamguard/tr/YAPILACAKLAR $(mkinstalldirs) ${prefix}/share/doc/spamguard/tr $(INSTALL_DATA) $(srcdir)/YAZARLAR ${prefix}/share/doc/spamguard/tr/YAZARLAR uninstall-local: -rm -f ${prefix}/share/doc/spamguard/tr/BENIOKU -rm -f ${prefix}/share/doc/spamguard/tr/BENIOKU.DigitalUnix -rm -f ${prefix}/share/doc/spamguard/tr/COPYING -rm -f ${prefix}/share/doc/spamguard/tr/DEGISIKLIKLER -rm -f ${prefix}/share/doc/spamguard/tr/KURULUM -rm -f ${prefix}/share/doc/spamguard/tr/KURULUM-SONRASI -rm -f ${prefix}/share/doc/spamguard/YAPILACAKLAR -rm -f ${prefix}/share/doc/spamguard/YAZARLAR #This is not a gnu project. So we don't have to obey gnu package needz! AUTOMAKE_OPTIONS = foreign # set the include path found by configure INCLUDES= $(all_includes) spamguard-devel/tr/YAPILACAKLAR0100644000175000000000000000003207614444135015350 0ustar muratwheel- Bocukleri temizlemek :) spamguard-devel/tr/YAZARLAR0100644000175000000000000000056010077142152014735 0ustar muratwheelYazarlar (Alfabetik siraya gore) Ismail YENIGUL Murat Balaban Omer Faruk Sen Katikida bulunanlar: Geoff Mitchell Bizimle bu konuda irtibata gecmek icin bug-report at enderunix dot org adresine mail atabilirsiniz http://www.enderunix.org spamguard-devel/.cvsignore0100644000175000000000000000003507614442476015154 0ustar muratwheelspamguard *.o *.c~ *~ *.core spamguard-devel/AUTHORS0100644000175000000000000000071510077141563014217 0ustar muratwheelMaintainers: (In Alphabetical Order) Ismail YENIGUL Murat Balaban Omer Faruk Sen Contributors: Necati Ersen Siseci Halil Demirezen Geoff Mitchell For questions and comments, and also bug reports, don't hesitate to mail roots at enderunix dot org http://www.enderunix.org spamguard-devel/CHANGELOG0100644000175000000000000000454310077141563014364 0ustar muratwheel * Development version adds/changes the following: * Tue Jul 20 09:38:00 EEST 2004 Version 1.7 released * Tue May 28 18:03:21 EEST 2004 Version 1.7-BETA adds/changes the follwing: - stat bug has been fixed. - #@[] address is ignored for qmail. - paranoid mode checks whether this address is in the badmailfrom file already. - Strip '<' and '>' characters in e-mail addresses. (rmspace). - Lots of security fixes - parser module re-written. many security fixes - autogen.sh re-written to work with FreeBSD * Mon Oct 7 10:58:20 EEST 2002 Version 1.6 adds/changes the following: - The Parser module is now Isoqlog's parser. - Easy to use config file, spamguard.conf. Now the configuration parameters can be set at run time. - Removed MTA subdirs. Installation has become very easy. * Fri Mar 15 06:20:12 EET 2002 Version 1.5 adds/changes the following: - Runs/tested on Solaris, Free/Net/Open BSD, Digital Unix, Linux. - Bug in ignore file processing code is fixed. If you are using version 1.4, we strongly suggest that you upgrade to version 1.5. Because of this, one of the hash tables has been turned into linked list (ignore list). - New Feature: Now, there are three different threshold values, which are treated differently by spamGuard: warning, block and paranoid. - Some code refinement. * Thu Feb 21 02:13:46 EET 2002 Version 1.4 adds/changes the following: - Because of performance issues, linked lists are replaced with hash tables. - Postfix support. - Some more memory leaks are cleaned. * Sun Feb 10 16:19:07 EET 2002 Version 1.3 adds/changes the following: - Generic functions have been seperated from the MTA-dependant code base. - Qmail with syslog support. - Sendmail support. - Added code necessary to save and restore the previous position on maillog file, so that you won't need to rotate maillog. * Tue Feb 5 00:43:45 EET 2002 Version 1.2 adds/changes the following: - Wildcard support in ignore file - Fixed some memory leaks. (Thanks to Geoff Mitchell) - SPAMNUMBER is no longer hard-coded into binary. It's now taken from stdin, so you can experiment freely with your SPAMNUMBERs. * Tue Feb 2 02:30:40 EET 2002 Maintenance Release: 1.1 * Thu Jan 31 03:32:10 EET 2002 First Public Release spamguard-devel/COPYING0100644000175000000000000000354110077141563014202 0ustar muratwheel Copyright (c) 2004 , EnderUNIX SDT All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the EnderUNIX Team nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. EnderUNIX Software Development Team @ Turkiye Tue Jul 20 09:36:38 EEST 2004 spamguard-devel/INSTALL0100644000175000000000000000633310077141563014202 0ustar muratwheelMaking and Installing EnderUNIX spamGuard v.1.7 ==================================================================== This file provides brief instructions on how to build and install spamGuard on UNIX (and UNIX-like) system. More detailed information and instructions can be found in EnderUNIX website: (http://www.enderunix.org/spamguard/spamguard-1.7/INSTALL). It is recommended that you read, or at least skim through, ALL of the instructions in this file before attempting to build the software. Making and Installing ----------------------------------------------- 1. Unpack the software and change directory: % tar xfz spamguard-VERSION.tar.gz % cd spamguard-VERSION (replacing VERSION with the appropriate version string). If you are reading this file, you probably have already done this!:)) 2. ./configure 3. Type: % make If all goes well, all binaries will be compiled. 4. Install the binary. You may need to become the super-user (e.g. root) to do this (depending on where you are installing things): % su root -c 'make install' Binary will be installed in /usr/local/bin. A sample spamguard.conf will be installed in /usr/local/etc. 5. Copy spamguard.conf.sample to some path to your liking. Note that if you specify some other location than /usr/local/etc, you'll need to supply path to spamguard.conf via the -f swicth at run time. logtype = "qmail" Your log type. Possible values are: qmail, sendmail, postfix logfile = "/var/log/qmail/current" Location of your log file. An important thing to note here is that; keep the size of your log file large. If you're using qmail with multilog, you can set this in the qmail-send/log/run file with the s (size) parameter like this: (all in one line) #!/bin/sh exec /usr/local/bin/setuidgid \ qmaill /usr/local/bin/multilog t s5000000 \ /var/log/qmail if you're using syslog, change the rotate size. ignorefile = "/usr/local/etc/spam-ignore.txt" # Location of your ignore file. Ignore file will hold the addresses to ignored by spamguard. badmailfile = "/var/qmail/control/badmailfrom" Your MTA's blacklist'ed senders file. If you're using qmail most probably this will be: /var/qmail/control/badmailfrom; if sendmail : /etc/mail/access; if postfix it'll be /usr/local/etc/postfix/access sysadmin = "spam-notify@somedomain.com" The person who will receive spammer activity reports. hostname = "enderunix.org" If no hostname is found in the sender line, this will be appended to the username. e.g from= will be from = . mail_command = "/usr/bin/mail" Where's your mail/mailx binary. Solaris users should use mailx instead of mail. makemap_command = "makemap hash /etc/mail/access va=0x14000d23c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Unaligned access pid=31946 va=0x14001607c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Unaligned access pid=31946 va=0x14001631c pc=0x3ff8019ce0c ra=0x3ff800d7134 inst=0xa560fff8 Solution: --------- Before running spamGuard, run the command "/usr/bin/uac p 0" (without the quotes). So your crontab entry can be: (all in one line) 0,5,10,15,20,25,30,35,40,45,50,55 * * * * /usr/bin/uac p 0 ; /usr/local/bin/spamguard -w 50 -b 100 -p 2000 Credits: -------- Thanks "Juan Enciso" , for notifying this. spamguard-devel/THANKS0100644000175000000000000000045407517503532014065 0ustar muratwheelGeoff Mitchell Fixed some memory leaks. Juan Enciso Notified us about the change to use spamGuard on Digital UNIX systems. Atilim Boy (aboy@trunix.org) Software logos Baris Simsek (simsek@acikkod.org) gnu style configure scripts and, all people who sent feedback! spamguard-devel/TODO0100644000175000000000000000002610077141563013632 0ustar muratwheel- Forever Fix Bugs :) spamguard-devel/autogen.sh0100755000175000000000000000653310046140626015147 0ustar muratwheel#! /bin/sh #Taken from KDE project with conformance to FreeBSD binary layout! # Global variables... echo "***********************************************************" echo "Make SURE you have installed automake and autoconf packages" echo "***********************************************************" sleep 1; AUTOCONF="autoconf" AUTOHEADER="autoheader" AUTOM4TE="autom4te" AUTOMAKE="automake" ACLOCAL="aclocal" # We don't use variable here for remembering the type ... strings. # local variables are not that portable, but we fear namespace issues with # our includer. The repeated type calls are not that expensive. checkAutoconf() { if test -x "`$WHICH autoconf253`";then AUTOCONF="`$WHICH autoconf253`" elif test -x "`$WHICH autoconf257`" ; then AUTOCONF="`$WHICH autoconf257`" elif test -x "`$WHICH autoconf258`" ; then AUTOCONF="`$WHICH autoconf258`" elif test -x "`$WHICH autoconf259`" ; then AUTOCONF="`$WHICH autoconf259`" elif test -x "`$WHICH autoconf-2.5x`" ; then AUTOCONF="`$WHICH autoconf-2.5x`" elif test -x "`$WHICH autoconf-2.53`" ; then AUTOCONF="`$WHICH autoconf-2.53`" elif test -x "`$WHICH autoconf-2.52`" ; then AUTOCONF="`$WHICH autoconf-2.52`" elif test -x "`$WHICH autoconf2.50`" ; then AUTOCONF="`$WHICH autoconf2.50`" elif test -x "`$WHICH autoconf`";then AUTOCONF="`$WHICH autoconf`" fi } checkAutoheader() { if test -x "`$WHICH autoheader253`";then AUTOCONF="`$WHICH autoheader253`" elif test -x "`$WHICH autoheader258`" ; then AUTOCONF="`$WHICH autoheader258`" elif test -x "`$WHICH autoheader259`" ; then AUTOCONF="`$WHICH autoheader259`" elif test -x "`$WHICH autoheader-2.5x`" ; then AUTOHEADER="`$WHICH autoheader-2.5x`" AUTOM4TE="`$WHICH autom4te-2.5x`" elif test -x "`$WHICH autoheader-2.53`" ; then AUTOHEADER="`$WHICH autoheader-2.53`" AUTOM4TE="`$WHICH autom4te-2.53`" elif test -x "`$WHICH autoheader-2.52`" ; then AUTOHEADER="`$WHICH autoheader-2.52`" elif test -x "`$WHICH autoheader2.50`" ; then AUTOHEADER="`$WHICH autoheader2.50`" elif test -x "`$WHICH autoheader`" ; then AUTOHEADER="`$WHICH autoheader`" fi } checkAutomakeAclocal () { if test -z "$UNSERMAKE"; then if test -x "`$WHICH automake18`" ; then AUTOMAKE="`$WHICH automake18`" ACLOCAL="`$WHICH aclocal18`" elif test -x "`$WHICH automake-1.5`" ; then AUTOMAKE="`$WHICH automake-1.5`" ACLOCAL="`$WHICH aclocal-1.5`" elif test -x "`$WHICH automake-1.6`" ; then AUTOMAKE="`$WHICH automake-1.6`" ACLOCAL="`$WHICH aclocal-1.6`" elif test -x "`$WHICH automake`" ; then AUTOMAKE="`$WHICH automake`" ACLOCAL="`$WHICH aclocal`" fi else AUTOMAKE="$UNSERMAKE" fi } checkWhich () { WHICH="" for i in "type -p" "which" "type" ; do T=`$i sh` test -x "$T" && WHICH="$i" && break done } checkWhich checkAutoconf checkAutoheader checkAutomakeAclocal export WHICH AUTOHEADER AUTOCONF AUTOM4TE AUTOMAKE ACLOCAL echo "Execing $ACLOCAL" $ACLOCAL || echo "Can not find aclocal on your system. Install it" # >/dev/null 2>/dev/null echo "...Done" echo "Execing $AUTOMAKE" $AUTOMAKE -ac || echo "Can not find automake on your system. Install it" # >/dev/null 2>/dev/null echo "...Done" echo "Execing $AUTOCONF" $AUTOCONF || echo "Can not find autoconf on your system. Install it" #>/dev/null 2>/dev/null echo "...Done" spamguard-devel/config.h.in0100644000175000000000000000431307745272541015201 0ustar muratwheel/* config.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `gethostname' function. */ #undef HAVE_GETHOSTNAME /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if your system has a working `malloc' function. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the `strerror' function. */ #undef HAVE_STRERROR /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to `unsigned' if does not define. */ #undef size_t spamguard-devel/configure.in0100644000175000000000000000177407746415455015503 0ustar muratwheel# Process this file with autoconf to produce a configure script. AC_INIT(spamguard, 1.6, core@enderunix.org) AC_CANONICAL_SYSTEM AC_CONFIG_SRCDIR([functions.c]) AM_CONFIG_HEADER([config.h]) #Sadece autoheader icin gerekli. Autoheader'i kullanacaksaniz AM_CONFIG_HEADER #kapatilip AC_CONFIG_HEADER acilacak!!! #AC_CONFIG_HEADER([config.h]) AM_INIT_AUTOMAKE(spamguard, 1.6) # Checks for programs. AC_PROG_CC unset CDPATH dnl make /usr/local the default for the installation AC_PREFIX_DEFAULT(/usr/local) if test "x$prefix" = "xNONE"; then prefix=$ac_default_prefix ac_configure_args="$ac_configure_args --prefix $prefix" fi # Checks for libraries. # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h stdlib.h string.h strings.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_STAT AC_CHECK_FUNCS([gethostname memset strcasecmp strdup strerror strstr]) AC_OUTPUT(Makefile) AC_OUTPUT(tr/Makefile) spamguard-devel/functions.c0100644000175000000000000002522110077141563015322 0ustar muratwheel/* * EnderUNIX Software Development Team, (c) 2002 * Istanbul / Turkiye */ #include #include #include #include #include #include #include #include "loadconfig.h" #include "functions.h" #include "wildmat.h" extern char mail_command[VALSIZE]; extern char makemap_command[VALSIZE]; extern char sysadmin[VALSIZE]; extern char statfile[VALSIZE]; extern char badmailfile[VALSIZE]; extern int wcnt; extern int bcnt; extern int pcnt; extern int w; extern int b; extern int p; /* check if the supplied mail address exist in our "ignored" linked list */ int isIgnored(char *email, char src) { iaddr *l = iaddrlist; for ( ; l != NULL; l = l->next) { if (src & l->src) if (DoMatch(email, l->mail, strlen(l->mail)) == TRUE) return 1; } return 0; } /* Check if the email address if already in list. * If so, increment its hit count; if not, * add it to end of the list */ void check_addr(char *email) { int h; maddr *sym = NULL; if(strncmp(email, "#@[]", 4) == 0) return; /* Calculate hash sum, locate and inc. cnt if email exists, * otherwise place it in spammer_hash */ h = hash(email); for (sym = spammer_hash[h]; sym != NULL; sym = sym->next) if (strcmp(email, sym->mail) == 0) { sym->cnt++; return; } sym = (maddr *)malloc(sizeof(maddr)); /* No need a malloc for mail, because, email's been malloc'ed before */ sym->mail = email; sym->cnt = 1; sym->next = spammer_hash[h]; spammer_hash[h] = sym; return; } void addToIgnored(char *email, char src) { iaddr *new = NULL; new = (iaddr *)malloc(sizeof(iaddr)); new->mail = email; new->src = src; new->next = iaddrlist; iaddrlist = new; } /* remove some unnecessary characters */ int removespaces(char *buf, int len) { char *cp = buf; char *sv = buf; for (; *buf != '\0' && ((buf - sv) < len); buf++) if (*buf == ' ' || *buf == '<' || *buf == '>' || *buf == '\n' || *buf == '\r' || *buf == '\t') continue; else *cp++ = *buf; *cp = '\0'; return cp - sv; } /* notifying system administrator of spammer activity */ int send_notify_mail(char *n) { FILE *inpp; char tmpfile[BUFSIZE]; char mailcmd[BUFSIZE]; int fd, retval, ret; size_t bytes; strncpy(tmpfile, "/tmp/qstspam-XXXXXX", BUFSIZE - 1); if ((fd = mkstemp(tmpfile)) == -1) { puts("Couldn't create temporary file name"); perror("mkstemp"); return errno; } if ((bytes = write(fd, n, strlen(n))) < bytes) { fprintf(stderr, "Couldn't write to temporary file"); return errno; } if ((ret = close(fd)) == -1) { fprintf(stderr, "Couldn't close temporary file"); perror("close"); return errno; } strncpy(mailcmd, mail_command, BUFSIZE - 1); strncat(mailcmd, " -s \"spamGuard notification!\" ", BUFSIZE - 1); strncat(mailcmd, sysadmin, BUFSIZE - 1); strncat(mailcmd, " < ", BUFSIZE - 1); strncat(mailcmd, tmpfile, BUFSIZE - 1); if ((inpp = popen(mailcmd, "r")) == NULL) { fprintf(stderr, "Couldn't send mail"); perror("popen"); return errno; } if ((retval = pclose(inpp)) == -1) { perror("pclose"); return errno; } if ((ret = unlink(tmpfile)) == -1) { perror("unlink"); return errno; } return retval; } unsigned int hash(char *str) { unsigned int h; unsigned char *p = NULL; if (str == NULL) return; h = 0; for (p = (unsigned char *)str; *p != '\0'; p++) h = MULTIPLIER * h + *p; return h % MAXADDR; } void save_pos(hist_stat *h) { FILE *fp; if (h == NULL) return; if ((fp = fopen(statfile, "w")) == NULL) { fprintf(stderr, "Couldn't open %s: %s\n", statfile, strerror(errno)); return; } fprintf(fp, "%d %d", h->inode, h->saved_pos); if ((fclose(fp)) == -1) { fprintf(stderr, "Couldn't close %s: %s\n", statfile, strerror(errno)); return; } } void get_saved_pos(hist_stat *h) { FILE *fp; char inode[16]; char pos[16]; if (h == NULL) return; if ((fp = fopen(statfile, "r")) == NULL) { fprintf(stderr, "Couldn't open %s: %s\n", statfile, strerror(errno)); return; } fscanf(fp, "%15s %15s", inode, pos); if (inode != NULL) h->inode = atoi(inode); if (pos != NULL) h->saved_pos = atoi(pos); if ((fclose(fp)) == -1) { fprintf(stderr, "Couldn't close %s: %s\n", statfile, strerror(errno)); return; } } int makemap(void) { FILE *fp; int retval; if ((fp = popen(makemap_command, "r")) == NULL) { fprintf(stderr, "Couldn't create hash database file\n"); perror("popen"); } if ((retval = pclose(fp)) == -1) { perror("pclose"); return errno; } return retval; } /* loads ignore user list from spam-ignore.txt */ void loadIgnoreList(char *fn, char src) { FILE *fp; char buf[1024]; if ((fp = fopen(fn, "r")) == NULL) { fprintf(stderr, "fopen: %s: %s\n", fn, strerror(errno)); exit(-1); } memset(buf, 0, 1024); while ((fgets(buf, 1024, fp)) != NULL) { removespaces(buf, strlen(buf)); addToIgnored(strdup(buf), src); memset(buf, 0, 1024); } fclose(fp); } /* fills our ignore list. these addresses will not be treated as spammers */ void loadIgnore_sendmail(char *fn, char src) { FILE *fp; char buf[1024]; char *m; if ((fp = fopen(fn, "r")) == NULL) { fprintf(stderr, "fopen: %s: %s\n", fn, strerror(errno)); exit(-1); } memset(buf, 0, 1024); while ((fgets(buf, 1024, fp)) != NULL) { if (buf[0] == '#' || buf[0] == ' ') continue; m = strtok(buf, "\t"); if (m == NULL) continue; removespaces(m, strlen(m)); addToIgnored(strdup(m), src); memset(buf, 0, 1024); } fclose(fp); } /* This function reads the logfile and fills the " from " linked list */ /* traverse "from" linked list and decide whether the hit count per mail address * exceeds the "spammer threshold" */ int qmail_finalize(void) { FILE *fp; maddr *ptr; char mailbuf[2048]; int spamcnt = 0; int i; if ((fp = fopen(badmailfile, "a+")) == NULL) { fprintf(stderr, "fopen: %s: %s\n", badmailfile, strerror(errno)); exit(-1); } for (i = 0; i < MAXADDR; i++) for (ptr = spammer_hash[i]; ptr != NULL; ptr = ptr->next) { /* printf ("mail: %s\n", ptr->mail); */ if ((ptr->cnt < bcnt) && w == 1 && (ptr->cnt >= wcnt) && (!isIgnored(ptr->mail, SRC_ALL))) { printf("Light Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2047, " %s has been spamming your box! (sent %d mails)\n This mail is to notify you that this email address sent more emails than\n your \"warning threshold\", I'm not adding it to %s\n\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } else if (ptr->cnt > bcnt) { if (p == 1 && (ptr->cnt >= pcnt) && (!isIgnored(ptr->mail, SRC_BADMAILFROM))) { spamcnt = 1; fprintf(fp, "%s\n", ptr->mail); printf("Paranoid Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2047, " %s has been spamming your box! (sent %d mails)\n No matter this mail address is matched against your ignore list, or not,\n I'm still adding it to blacklist since s/he sent more mails then\n your paranoid threshold.\n\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } else if (!isIgnored(ptr->mail, SRC_ALL)) { spamcnt = 1; fprintf(fp, "%s\n", ptr->mail); printf("Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2047, " %s has been spamming your box! (sent %d mails)\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } } } fclose(fp); return spamcnt; } int sendmail_finalize(void) { FILE *fp; maddr *ptr; char mailbuf[2048]; int spamcnt = 0; int i; if ((fp = fopen(badmailfile, "a+")) == NULL) { fprintf(stderr, "fopen: %s: %s\n", badmailfile, strerror(errno)); exit(-1); } for (i = 0; i < MAXADDR; i++) for (ptr = spammer_hash[i]; ptr != NULL; ptr = ptr->next) { if ((ptr->cnt < bcnt) && w && (ptr->cnt >= wcnt) && (!isIgnored(ptr->mail, SRC_ALL))) { printf("Light Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2048, " %s has been spamming your box! (sent %d mails)\n This mail is to notify you that this email address sent more emails than\n your \"warning threshold\", I'm not adding it to %s\n\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } else if (ptr->cnt > bcnt) { if (p && (ptr->cnt >= pcnt) && (!isIgnored(ptr->mail, SRC_BADMAILFROM))) { spamcnt = 1; fprintf(fp, "%s\tERROR:\"550: Your address is blocked because of spammer activity [http://www.enderunix.org/spamguard]\"\n", ptr->mail); printf("Paranoid Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2048, " %s has been spamming your box! (sent %d mails)\n No matter this mail address is matched against your ignore list, or not,\n I'm still adding it to blacklist since s/he sent more mails then\n your paranoid threshold.\n\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } else if (!isIgnored(ptr->mail, SRC_ALL) < 0) { spamcnt = 1; fprintf(fp, "%s\tERROR:\"550: Your address is blocked because of spammer activity [http://www.enderunix.org/spamguard]\"\n", ptr->mail); printf("Spammer:%s sent %d mails\n", ptr->mail, ptr->cnt); snprintf(mailbuf, 2048, " %s has been spamming your box! (sent %d mails)\n Source mail address has been added to %s file\n Target successfully nuked!\n\n Regards,\n -EnderUNIX spamGuard %s\n http://www.enderunix.org/spamguard\n", ptr->mail, ptr->cnt, badmailfile, VERSION); mailbuf[2047] = '\0'; send_notify_mail(mailbuf); } } } fclose(fp); return spamcnt; } void print_list(int list) { int i; maddr *m; list = 0; for (i = 0; i < MAXADDR; i++) if (spammer_hash[i] != NULL) for (m = spammer_hash[i]; m != NULL; m = m->next) printf("%s - %d mails\n", m->mail, m->cnt); } spamguard-devel/functions.h0100644000175000000000000000167310072214657015334 0ustar muratwheel#ifndef FUNCTIONS_H #define FUNCTIONS_H #define SRC_IGNOREFILE 0x02 #define SRC_BADMAILFROM 0x04 #define SRC_ALL 0xFF enum { MULTIPLIER = 31, MAXADDR = 5000 }; typedef struct maddr maddr; typedef struct iaddr iaddr; typedef struct hist_stat { int inode; int saved_pos; } hist_stat; struct maddr { char *mail; int cnt; maddr *next; }; struct iaddr { char *mail; char src; iaddr *next; }; /* Hash table with addresses from log file */ maddr *spammer_hash[MAXADDR]; iaddr *iaddrlist ; int isIgnored(char *, char); void check_addr(char *); void addToIgnored(char *, char); int removespaces(char *, int); int send_notify_mail(char *); unsigned int hash(char *); void save_pos(hist_stat *); void get_saved_pos(hist_stat *); int makemap(void); void loadIgnoreList(char *, char); void loadIgnore_sendmail(char *, char); int qmail_finalize(void); int sendmail_finalize(void); void print_list(int); #endif spamguard-devel/loadconfig.c0100644000175000000000000001156510077141563015425 0ustar muratwheel#include #include #include #include #include #include #include #include #include #include "loadconfig.h" extern int errno; extern int w; extern int b; extern int p; void loadconfig(char *cfgfile) /* load spamguard configuration file */ { FILE *fd; char buf[BUFSIZE]; char keyword[KEYSIZE]; char value[VALSIZE]; char *cp1, *cp2; int lenbuf = 0; char *variables[] = { "Invalid", "logtype", "logfile", "ignorefile", "badmailfile", "hostname", "sysadmin", "statfile", "mail_command", "makemap_command", "wcnt", "bcnt", "pcnt" }; int i, j, key, line, keyword_nums = sizeof(variables)/sizeof(char *); if ((fd = fopen(cfgfile, "r")) == NULL) { fprintf(stderr, "loadconfig: cannot open spamguard configuration file %s, exiting...\n", cfgfile); exit(-1); } line = 0; j = 0; while ((fgets(buf, BUFSIZE, fd)) != NULL) { line++; if (buf[0] == '#') continue; if ((lenbuf = strlen(buf)) <= 1) continue; cp1 = buf; cp2 = keyword; while (isspace((int)*cp1) && ((cp1 - buf) < lenbuf)) cp1++; while (isgraph((int)*cp1) && (*cp1 != '=') && (j++ < KEYSIZE - 1) && ((cp1 - buf) < lenbuf)) *cp2++ = *cp1++; *cp2 = '\0'; j = 0; cp2 = value; while ((*cp1 != '\0') && (*cp1 !='\n') && (*cp1 !='=') && ((cp1 - buf) < lenbuf)) cp1++; cp1++; while (isspace((int)*cp1) && ((cp1 - buf) < lenbuf)) cp1++; if (*cp1 == '"') cp1++; while ((*cp1 != '\0') && (*cp1 !='\n') && (*cp1 !='"') && (j++ < VALSIZE - 1) && ((cp1 - buf) < lenbuf)) *cp2++ = *cp1++; *cp2-- = '\0'; j = 0; if (keyword[0] =='\0' || value[0] =='\0') continue; key = 0; for (i = 0; i < keyword_nums; i++) { if ((strncmp(keyword, variables[i], KEYSIZE)) == 0) { key = i; break; } } switch(key) { case 0: fprintf(stderr, "Illegal Keyword: %s\n", keyword); break; case 1: strncpy(logtype, value, VALSIZE); break; case 2: strncpy(logfile, value, VALSIZE); break; case 3: strncpy(ignorefile, value, VALSIZE); break; case 4: strncpy(badmailfile, value, VALSIZE); break; case 5: strncpy(hostname, value, VALSIZE); break; case 6: strncpy(sysadmin, value, VALSIZE); break; case 7: strncpy(statfile, value, VALSIZE); break; case 8: strncpy(mail_command, value, VALSIZE); break; case 9: strncpy(makemap_command, value, VALSIZE); break; case 10: wcnt = atoi(value); w = 1; break; case 11: bcnt = atoi(value); b = 1; break; case 12: pcnt = atoi(value); p = 1; break; } } fclose(fd); } void readconfig(char *cfgfile) { struct stat statbuf; loadconfig(cfgfile); printf("logtype:%s\n", logtype); printf("logfile:%s\n", logfile); printf("ignorefile:%s\n", ignorefile); printf("badmailfile:%s\n", badmailfile); printf("statfile:%s\n", statfile); printf("warning count:%d\n", wcnt); printf("block count:%d\n", bcnt); printf("paranoid count:%d\n", pcnt); /* warning,block,paranoid count values check */ if (b == 0) { printf("You must set block count(bcnt) value in spamguard.conf\n"); exit(-1); } if (w && b && (wcnt >= bcnt)) { printf("Error!: warning count value:%d must be smaller than block count value:%d\n", wcnt, bcnt); exit(-1); } if (w && (wcnt >= pcnt)) { printf("Error!: warning count value:%d must be smaller than paranoid count value:%d\n", wcnt, pcnt); exit(-1); } if (b && (bcnt >= pcnt)) { printf("Error!: block count value:%d must be smaller than paranoid count value:%d\n", bcnt, pcnt); exit(-1); } if ((strlen(hostname)) <= 0 ) gethostname(hostname, VALSIZE); printf("hostname: %s\n", hostname); if ((strcasecmp(logtype, "qmail") != 0) && (strcasecmp(logtype, "sendmail") != 0) && (strcasecmp(logtype, "postfix") != 0)) { printf("Invalid logtype: %s\naccepted logytpes are: " "qmail, sendmail or postfix\n", logtype); exit(-1); } if ((stat(logfile, &statbuf)) == 0) { if((S_ISREG(statbuf.st_mode)) == 0) { fprintf(stderr, "You are using: %s log type " "logfile: %s must be a regular file\n", logtype, logfile); exit(-1); } } else { fprintf(stderr, "You are using: %s log type " "logfile: %s file does not exist!\n", logtype, logfile); exit(-1); } if ((strlen(ignorefile)) <= 0) { printf("You must define a ignorefile\n"); exit(-1); } if ((strlen(badmailfile)) <= 0) { printf("You must define a badmailfile\n"); exit(-1); } if ((strlen(sysadmin)) <= 0) { printf("You must define a sysadmin email address\n"); exit(-1); } if ((strlen(mail_command)) <= 0) { printf("You must set mail_command value\n"); exit(-1); } if (((strcasecmp(logtype, "sendmail") == 0) || (strcasecmp(logtype, "postfix") == 0)) && (strlen(makemap_command) == 0)){ printf("You are using logtype:%s, you must set makemap_command value\n", logtype); exit(-1); } } spamguard-devel/loadconfig.h0100644000175000000000000000077210077141563015430 0ustar muratwheel#ifndef LOADCONFIG_H #define LOADCONFIG_H #include #define TOKENS " \n" #define VERSION "1.7" enum { BUFSIZE = 1024, KEYSIZE = 64, VALSIZE = 256 }; int wcnt; int bcnt; int pcnt; char logtype[VALSIZE]; char logfile[VALSIZE]; char ignorefile[VALSIZE]; char badmailfile[VALSIZE]; char hostname[VALSIZE]; char sysadmin[VALSIZE]; char statfile[VALSIZE]; char mail_command[VALSIZE]; char makemap_command[VALSIZE]; void loadconfig(char *); void readconfig(char *); #endif spamguard-devel/main.c0100644000175000000000000000457010077141563014242 0ustar muratwheel/* * * EnderUnix Software Development Team @ Turkey * (c) 2002 Istanbul, Turkiye * * See COPYING for copyright and copying restrictions * */ #include #include #include #include #include #include #include #include #include #include "wildmat.h" #include "parser.h" #include "loadconfig.h" #include "functions.h" extern char logtype[VALSIZE]; extern char logfile[VALSIZE]; extern char ignorefile[VALSIZE]; extern char badmailfile[VALSIZE]; int w = 0; int b = 0; int p = 0; int main(int argc, char **argv) { int c, f = 0, error = 0; extern char *optarg; extern int optind; char spamguardconf[VALSIZE]; while (!error && (c = getopt(argc,argv,"f:hv")) != -1) { switch (c) { case 'v': printf("EnderUNIX spamGuard Version %s\n", VERSION); exit(0); break; case 'h': printf("Usage: %s [-f spamguard.conf]\n", argv[0]); exit(0); break; case 'f': strncpy(spamguardconf, optarg, VALSIZE - 1); f = 1; break; default: error = 1; puts("Usage: spamGuard [-f spamguard.conf]"); exit(-1); break; } } if (f == 0) readconfig("/usr/local/etc/spamguard.conf"); else readconfig(spamguardconf); iaddrlist = NULL; /* First we open log file and fill our "from" list */ if (strcmp(logtype, "qmail") == 0) { readLogFile(logfile); /* ignore list is our list of priviliged mail users * firstly we read our ignore file */ loadIgnoreList(ignorefile, SRC_IGNOREFILE); /* ... and from qmail's badmailfrom, since we do not want * to have duplicate spammer addresses */ loadIgnoreList(badmailfile, SRC_BADMAILFROM); printf("Spammers:\n"); if (qmail_finalize() > 0) printf("Spammer is detected \n"); else printf("No spammer found yet\n"); } else if ((strcmp(logtype, "sendmail") == 0) || (strcmp(logtype, "postfix") == 0)) { /* postfix and sendmail format is same so we are using both of them in one place */ readLogFile(logfile); loadIgnoreList(ignorefile, SRC_IGNOREFILE); loadIgnore_sendmail(badmailfile, SRC_BADMAILFROM); printf("Spammers:\n"); if (sendmail_finalize() > 0) printf("Spammer is detected \n"); else printf("No spammer found yet\n"); } /* make compilers happy :) */ return 0; } spamguard-devel/parser.c0100644000175000000000000000627310077141563014614 0ustar muratwheel/* * * EnderUnix Software Development Team @ Turkey * (c) 2002 Istanbul, Turkiye * * See COPYING for copyright and copying restrictions * */ #include #include #include #include #include #include #include #include #include #include "wildmat.h" #include "functions.h" #include "loadconfig.h" #include "parser.h" extern char logtype[VALSIZE]; void readLogFile(char *fn) { FILE *fp; char buf[1024]; struct stat st; hist_stat old; hist_stat new; get_saved_pos(&old); if ((fp = fopen(fn, "r")) == NULL) { fprintf(stderr, "fopen: %s: %s\n", fn, strerror(errno)); exit(-1); } /* Get the current values of last read log file's inode number * * and byte offset */ if ((stat(fn, &st)) == -1) { fprintf(stderr, "Couldnt' stat %s: %s\n", fn, strerror(errno)); exit(-1); } /* If both inode numbers are the same, we assume that log file * * has not been changed (i.e rotated, removed), so we can * * go past offset bytes and continue to read new logs */ if (st.st_ino == old.inode) fseek(fp, old.saved_pos, SEEK_SET); if (strcmp(logtype, "qmail") == 0) { while ((fgets(buf, 1024, fp)) != NULL) qmail_parseline(buf); } else if ((strcmp(logtype, "sendmail") == 0) || (strcmp(logtype, "postfix") == 0)) { while ((fgets(buf, 1024, fp)) != NULL) sendmail_parseline(buf); } new.inode = st.st_ino; new.saved_pos = ftell(fp); save_pos(&new); fclose(fp); } void qmail_parseline(char *str) { char *p = str; char email[300]; char domain[128]; char user[128]; int i = 0; int lenstr = strlen(str); if ((p = strstr(str, "from ")) == NULL) return ; if ((p - str) > lenstr) return; p += 6; for (i = 0; (*p != '@') && (*p != '\0') && (*p != '\r') && (*p != '\n') && (i < 127) && ((p - str) < lenstr); i++, p++) user[i] = *p; user[i] = '\0'; if (strlen(user) == 0) return; p++; for (i = 0; (*p != '>') && (*p != '\0') && (*p != '\r') && (*p != '\n') && (i < 127) && ((p - str) < lenstr); i++, p++) domain[i] = *p; domain[i] = '\0'; if (strlen(domain) == 0) return; sprintf(email, "%.128s@%.128s", user, domain); check_addr(strdup(email)); } void sendmail_parseline(char *str) { char *p = str; char domain[128]; char user[128]; char email[300]; int i = 0; int lenstr = strlen(str); int domainflg = 0; if ((p = strstr(str, "from=")) == NULL) return ; if ((p - str) > lenstr) return; p += 5; if (*p == '<') p++; for (i = 0; (*p != ',') && (*p != '>') && (*p != '\0') && (*p != '\r') && (*p != '\n') && (i < 127) && ((p - str) < lenstr); i++, p++) { if (*p == '@') { domainflg = 1; break; } user[i] = *p; } user[i] = '\0'; if (strlen(user) == 0) return; if (domainflg) { p++; for (i = 0; (*p != ',') && (*p != '>') && (*p != '\0') && (*p != '\r') && (*p != '\n') && (i < 127) && ((p - str) < lenstr); i++, p++) domain[i] = *p; domain[i] = '\0'; if (strlen(domain) == 0) return; } else strncpy(domain, hostname, 127); sprintf(email, "%.128s@%.128s", user, domain); check_addr(strdup(email)); } spamguard-devel/parser.h0100644000175000000000000000035607517503267014625 0ustar muratwheel#ifndef PARSER_H #define PARSER_H #include #include #include #include #include void readLogFile(char *); void qmail_parseline(char *); void sendmail_parseline(char *str); #endif spamguard-devel/spam-ignore.txt0100644000175000000000000000001707517503312016123 0ustar muratwheel*@myfriend.com spamguard-devel/spam-ignore.txt.sample0100644000175000000000000000015507515307537017417 0ustar muratwheelpostmaster@* webmaster@*mydomain.* n?spam@domain.* *@myfriend.com.?? *admin*@myserver.com leyla@mecnun.com spamguard-devel/spamguard.conf0100644000175000000000000000126307616510527016005 0ustar muratwheel#spamguard 1.6 Configuration file #logtype = "sendmail" #log type qmail, sendmail, postfix logtype = "qmail" #log type qmail, sendmail, postfix #logfile = "/var/log/maillog" # logfile = "/var/log/qmail/current" # ignorefile = "/usr/local/etc/spam-ignore.txt" # badmailfile = "/var/qmail/control/badmailfrom" # #badmailfile = "/etc/mail/access" # For Sendmail sysadmin = "ismail@enderunix.org" # hostname = "enderunix.org" mail_command = "/usr/bin/mail" makemap_command = "/usr/sbin/makemap hash /etc/mail/access < /etc/mail/access" #sendmail , postfix only wcnt = 40 #warning count bcnt = 100 #block count pcnt = 300 #paranoid count statfile = "/usr/local/etc/spamguard.stat"; spamguard-devel/spamguard.conf.sample0100644000175000000000000000104207550237037017257 0ustar muratwheel#spamguard 1.6 Configuration file logtype = "qmail" #log type qmail, sendmail, postfix logfile = "/var/log/qmail/current" # ignorefile = "/usr/local/etc/spam-ignore.txt" # badmailfile = "/var/qmail/control/badmailfrom" # sysadmin = "spamntyf@esomedomain.org" # hostname = "somedomain.org" mail_command = "/usr/bin/mail" makemap_command = "makemap hash /etc/mail/access < /etc/mail/access" #sendmail , postfix only wcnt = 40 #warning count bcnt = 50 #block count pcnt = 100 #paranoid count statfile = "/usr/local/etc/spamguard.stat"; spamguard-devel/wildmat.c0100644000175000000000000000314310055604243014745 0ustar muratwheel#include "wildmat.h" /* Taken from spamcontrol patch. * * Author: * Dr. Erwin Hoffmann - FEHCom Germany * E-Mail: feh@fehcom.de * */ /* ** Match text and p, return TRUE, FALSE, or ABORT. */ int DoMatch(text, p, plen) char *text; char *p; int plen; { register int last; register int matched; register int reverse; register char * savep = p; register char * savet = text; for ( ; *p && (p - savep) < plen; text++, p++) { if (*text == '\0' && *p != '*') return ABORT; switch (*p) { case '\\': /* Literal match with following character. */ p++; /* FALLTHROUGH */ default: if (*text != *p) return FALSE; continue; case '?': /* Match anything. */ continue; case '*': while (*++p == '*' && (p - savep) < plen) /* Consecutive stars act just like one. */ continue; if (*p == '\0') /* Trailing star matches everything. */ return TRUE; while (*text) if ((matched = DoMatch(text++, p, (plen - (p - savep)))) != FALSE) return matched; return ABORT; case '[': reverse = p[1] == NEGATE_CLASS ? TRUE : FALSE; if (reverse) /* Inverted character class. */ p++; matched = FALSE; if (p[1] == ']' || p[1] == '-') if (*++p == *text) matched = TRUE; for (last = *p; *++p && *p != ']' && (p - savep) < plen; last = *p) /* This next line requires a good C compiler. */ if (*p == '-' && p[1] != ']' ? *text <= *++p && *text >= last : *text == *p) matched = TRUE; if (matched == reverse) return FALSE; continue; } } return *text == '\0'; } spamguard-devel/wildmat.h0100644000175000000000000000042510036262544014755 0ustar muratwheel#ifndef WILDMAT_H #define WILDMAT_H #define TRUE 1 #define FALSE 0 #define ABORT -1 /* What character marks an inverted character class? */ #define NEGATE_CLASS '^' //static int DoMatch(register char *, register char *); int DoMatch( char *, char *, int); #endif