]> jfr.im git - irc/ircd-hybrid/bopm.git/commitdiff
Hooks for sending an email report (but it doesn't actually do anything yet)
authorandy <redacted>
Sat, 19 Jan 2002 17:05:24 +0000 (17:05 +0000)
committerandy <redacted>
Sat, 19 Jan 2002 17:05:24 +0000 (17:05 +0000)
Makefile
config.c
dnsbl.c
dnsbl.h
extern.h
irc.c
scan.c
scan.h

index c739afceec2e2a950e7c7ddb529c8baf4b6fe909..49b5081a43c5b26c1824c93b91f0dcf38737ea4d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ all: bopm
        rm -f *.da
 
 config.o:  config.h                        log.h
-dnsbl.o:            dnsbl.h extern.h irc.h log.h
+dnsbl.o:            dnsbl.h extern.h irc.h log.h        opercmd.h scan.h
 irc.o:     config.h dnsbl.h extern.h irc.h log.h        opercmd.h scan.h
 log.o:                      extern.h       log.h
 main.o:                     extern.h irc.h log.h        opercmd.h scan.h stats.h
index f2313078af030bd8f9ddaf06689bf0c124be6c97..81e4761e025ba33e5450227f6183bb20da7e9550 100644 (file)
--- a/config.c
+++ b/config.c
@@ -47,6 +47,7 @@ char *CONF_KLINE_COMMAND   = 0;
 char *CONF_DNSBL_ZONE      = 0;
 char *CONF_DNSBL_FROM      = 0;
 char *CONF_DNSBL_TO        = 0;
+char *CONF_SENDMAIL        = 0;
 
 int  CONF_SCANPORT         = 0;
 int  CONF_PORT             = 0;
@@ -71,6 +72,7 @@ config_hash hash[] = {
        {"DNSBL_ZONE",          TYPE_STRING,     &CONF_DNSBL_ZONE         },
        {"DNSBL_FROM",          TYPE_STRING,     &CONF_DNSBL_FROM         },
        {"DNSBL_TO",            TYPE_STRING,     &CONF_DNSBL_TO           },
+       {"SENDMAIL",            TYPE_STRING,     &CONF_SENDMAIL           },
 };
 
 
diff --git a/dnsbl.c b/dnsbl.c
index 02788827c25951ea072b0f2c04ff49ca97c93a2d..c5a1028d54f1e570413f2b90c4b3cf5ed6e9f522 100644 (file)
--- a/dnsbl.c
+++ b/dnsbl.c
@@ -31,9 +31,11 @@ along with this program; if not, write to the Free Software
 #include <time.h>
 #include <errno.h>
 
+#include "irc.h"
+#include "opercmd.h"
+#include "scan.h"
 #include "dnsbl.h"
 #include "extern.h"
-#include "irc.h"
 #include "log.h"
 
 extern unsigned int STAT_DNSBL_MATCHES;
@@ -109,3 +111,9 @@ int dnsbl_check(const char *addr, const char *irc_nick,
    STAT_DNSBL_MATCHES++;
    return(1);
 }
+
+/* send an email to report this open proxy */
+void dnsbl_report(struct scan_struct *ss)
+{
+   log("Would be emailing now");
+}
diff --git a/dnsbl.h b/dnsbl.h
index e76b8e37b12ad6e03bf16ac62fdc56a8db1530cd..7be01984ec31ab6ec8a454488ac966b0f41513d4 100644 (file)
--- a/dnsbl.h
+++ b/dnsbl.h
@@ -1,5 +1,7 @@
 #ifndef DNSBL_H
 #define DNSBL_H
+
        int dnsbl_check(const char *addr, const char *irc_nick,
                        const char *irc_user, char *irc_addr);
+       void dnsbl_report(struct scan_struct *ss);
 #endif
index 6cc8ade253b52adf8fb86eea21e949f2c296ddba..5e24359c5a4647027331acbf42babcaee52a5d92 100644 (file)
--- a/extern.h
+++ b/extern.h
@@ -20,6 +20,7 @@
     extern char *CONF_DNSBL_ZONE;
     extern char *CONF_DNSBL_FROM;
     extern char *CONF_DNSBL_TO;
+    extern char *CONF_SENDMAIL;
 
     extern int   CONF_PORT;
     extern int   CONF_SCANPORT;
diff --git a/irc.c b/irc.c
index a06067dde2a87e9a3b173579cc9de7151863cfb9..3dec0ceed9de02b4a5b142b0645dd10ec642e5fb 100644 (file)
--- a/irc.c
+++ b/irc.c
@@ -38,9 +38,9 @@ along with this program; if not, write to the Free Software
 #include "irc.h"
 #include "log.h"
 #include "config.h"
-#include "dnsbl.h"
 #include "opercmd.h"
 #include "scan.h"
+#include "dnsbl.h"
 #include "stats.h"
 #include "extern.h"
 #include "options.h"
@@ -562,8 +562,19 @@ void irc_parse()
 
           if(!strcmp(token[7], "connecting:"))
             { 
+                char conn_notice[513];
                 STAT_NUM_CONNECTS++;
 
+                /* take a copy of the original connect notice now in case
+                 * we need it for evidence later */
+                snprintf(conn_notice, sizeof(conn_notice),
+                         "%s %s %s %s %s %s %s %s %s %s %s", token[0],
+                         token[1], token[2], token[3], token[4], token[5],
+                         token[6], token[7], token[8], token[9], token[10]);
+
+                /* make sure it is null terminated */
+                conn_notice[512] = '\0';
+
                  /* Token 11 is the IP of the remote host 
                   * enclosed in [ ]. We need to remove it from
                   * [ ] and pass it to the scanner. */
@@ -585,7 +596,7 @@ void irc_parse()
                   if(CONF_DNSBL_ZONE && dnsbl_check(addr, irc_nick,
                                                    irc_user, irc_addr))
                     return;
-                  scan_connect(addr, irc_addr, irc_nick, irc_user, 0);
+                  scan_connect(addr, irc_addr, irc_nick, irc_user, 0, conn_notice);
             }
      }
 
diff --git a/scan.c b/scan.c
index e41fdb84fac2ee584393710ff23b5efb5a011ac2..b48b49575d50d0c6bd4cbb693bae43f726ddcedb 100644 (file)
--- a/scan.c
+++ b/scan.c
@@ -35,12 +35,12 @@ along with this program; if not, write to the Free Software
 #include <sys/time.h>
 
 #include "config.h"
-#include "dnsbl.h"
 #include "irc.h"
 #include "log.h"
 #include "opercmd.h"
 #include "scan.h"
 #include "stats.h"
+#include "dnsbl.h"
 #include "extern.h"
 
 
@@ -86,7 +86,8 @@ void scan_memfail()
  * with the connecting IP, where we will begin
  * to establish the proxy testing */
 
-void scan_connect(char *addr, char *irc_addr, char *irc_nick, char *irc_user, int verbose)
+void scan_connect(char *addr, char *irc_addr, char *irc_nick,
+                 char *irc_user, int verbose, char *conn_notice)
 {
 
       int i;                
@@ -130,6 +131,9 @@ void scan_connect(char *addr, char *irc_addr, char *irc_nick, char *irc_user, in
             newconn->irc_user = strdup(irc_user);
            newconn->verbose = verbose;
                  
+           if(conn_notice)
+              newconn->conn_notice = strdup(conn_notice);
+
             newconn->protocol = &(SCAN_PROTOCOLS[i]); /* Give struct a link to information about the protocol
                                                          it will be handling. */
 
@@ -148,6 +152,8 @@ void scan_connect(char *addr, char *irc_addr, char *irc_nick, char *irc_user, in
                  free(newconn->irc_addr);
                  free(newconn->irc_user);
                  free(newconn->irc_nick);
+                if(newconn->conn_notice)
+                   free(newconn->conn_notice);
                  free(newconn);
                  continue;
               }
@@ -260,6 +266,12 @@ void scan_check()
                          {
                            irc_kline(ss->irc_addr);
 
+                          if(CONF_DNSBL_FROM && CONF_DNSBL_TO &&
+                             CONF_SENDMAIL)
+                           {
+                             dnsbl_report(ss);
+                           }
+
                            log("SCAN -> %s: %s!%s@%s (%d)", ss->protocol->type , ss->irc_nick, ss->irc_user, 
                                          ss->irc_addr, ss->protocol->port);
 
@@ -367,6 +379,8 @@ void scan_del(scan_struct *delconn)
                          free(ss->irc_addr);
                          free(ss->irc_nick);
                          free(ss->irc_user);
+                        if(ss->conn_notice)
+                          free(ss->conn_notice);
                          free(ss);
                      }
                    else
@@ -376,6 +390,8 @@ void scan_del(scan_struct *delconn)
                          free(ss->irc_addr);
                          free(ss->irc_nick);
                          free(ss->irc_user);
+                        if(ss->conn_notice)
+                          free(ss->conn_notice);
                          free(ss);
                      }
                    break;
@@ -687,7 +703,7 @@ void do_manual_check(struct command *c)
    if(CONF_DNSBL_ZONE)
       dnsbl_check(ip, "*", "*", c->param);
 
-   scan_connect(ip, c->param, "*", "*", 1);    /* Scan using verbose */
+   scan_connect(ip, c->param, "*", "*", 1, NULL);    /* Scan using verbose */
                                            
 }
 
diff --git a/scan.h b/scan.h
index 6538cc7d914838b66e5adb109ea6ffee4a1e86c7..97838398c64511d06352a63f365ce1d7c657e2d9 100644 (file)
--- a/scan.h
+++ b/scan.h
@@ -26,6 +26,8 @@
           char *irc_addr;              /* Hostname of user on IRC (for kline)              */ 
           char *irc_nick;              /* Nickname of user on IRC (for logging)            */
           char *irc_user;              /* Username of user on IRC (for logging)            */
+         char *conn_notice;           /* original server notice for this connect, used
+                                       * for evidence                                     */
           int fd;                      /* File descriptor of socket                        */
           struct sockaddr_in sockaddr; /* holds information about remote host for socket() */
           time_t create_time;          /* Creation time, for timeout                       */         
@@ -35,7 +37,8 @@
      };
 
      void do_scan_init();
-     void scan_connect(char *addr, char *irc_addr, char *irc_nick, char *irc_user, int verbose);
+     void scan_connect(char *addr, char *irc_addr, char *irc_nick,
+                      char *irc_user, int verbose, char *conn_notice);
      void scan_add(scan_struct *newcon);
      void scan_del(scan_struct *ss);
      void scan_cycle();