autosec-devel Mailing List for Automated Security Tools (Page 3)
Brought to you by:
red0x
You can subscribe to this list here.
2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(30) |
Aug
(53) |
Sep
(4) |
Oct
(39) |
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
|
Feb
|
Mar
(1) |
Apr
(31) |
May
(15) |
Jun
(1) |
Jul
(1) |
Aug
(7) |
Sep
(42) |
Oct
(37) |
Nov
(39) |
Dec
(15) |
2004 |
Jan
(10) |
Feb
(17) |
Mar
(2) |
Apr
(56) |
May
(22) |
Jun
(17) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
2005 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(10) |
2007 |
Jan
(2) |
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: red0x <re...@us...> - 2004-04-23 04:43:53
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15362/src Modified Files: popts.c Log Message: Silly spelling correction... omg Index: popts.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/popts.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** popts.c 13 Apr 2004 03:42:08 -0000 1.12 --- popts.c 23 Apr 2004 04:43:45 -0000 1.13 *************** *** 1,4 **** /*************************************************************************** ! popts.c - options aprsing functions ------------------- begin : Wed Mar 05 2003 --- 1,4 ---- /*************************************************************************** ! popts.c - options parsing functions ------------------- begin : Wed Mar 05 2003 |
From: red0x <re...@us...> - 2004-04-23 04:41:10
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15044/src Modified Files: Makefile.am Makefile.in expand.c Log Message: Added makefile targets for the expansion code. Added an rcsid to expand.c. Index: Makefile.in =================================================================== RCS file: /cvsroot/autosec/sonar/src/Makefile.in,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** Makefile.in 6 Feb 2004 06:20:50 -0000 1.29 --- Makefile.in 23 Apr 2004 04:41:01 -0000 1.30 *************** *** 100,104 **** noinst_HEADERS = util.h popts.h error.h bin_PROGRAMS = sonar ! sonar_SOURCES = sonar.c sonar.h util.c util.h plugin.c plugin.h popts.c popts.h error.c error.h mutex.c mutex.h net.c net.h target.c target.h service.c service.h log.c log.h mem.c mem.h sonar_LDADD = $(DYNAMIC_LD_LIBS) @LIBLTDL@ --- 100,104 ---- noinst_HEADERS = util.h popts.h error.h bin_PROGRAMS = sonar ! sonar_SOURCES = sonar.c sonar.h util.c util.h plugin.c plugin.h popts.c popts.h error.c error.h mutex.c mutex.h net.c expand.c expand.h net.h target.c target.h service.c service.h log.c log.h mem.c mem.h sonar_LDADD = $(DYNAMIC_LD_LIBS) @LIBLTDL@ *************** *** 114,118 **** am_sonar_OBJECTS = sonar.$(OBJEXT) util.$(OBJEXT) plugin.$(OBJEXT) \ popts.$(OBJEXT) error.$(OBJEXT) mutex.$(OBJEXT) net.$(OBJEXT) \ ! target.$(OBJEXT) service.$(OBJEXT) log.$(OBJEXT) mem.$(OBJEXT) sonar_OBJECTS = $(am_sonar_OBJECTS) sonar_DEPENDENCIES = --- 114,119 ---- am_sonar_OBJECTS = sonar.$(OBJEXT) util.$(OBJEXT) plugin.$(OBJEXT) \ popts.$(OBJEXT) error.$(OBJEXT) mutex.$(OBJEXT) net.$(OBJEXT) \ ! expand.$(OBJEXT) target.$(OBJEXT) service.$(OBJEXT) \ ! log.$(OBJEXT) mem.$(OBJEXT) sonar_OBJECTS = $(am_sonar_OBJECTS) sonar_DEPENDENCIES = *************** *** 126,135 **** depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles ! @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/error.Po ./$(DEPDIR)/log.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/mem.Po ./$(DEPDIR)/mutex.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/net.Po ./$(DEPDIR)/plugin.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/popts.Po ./$(DEPDIR)/service.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/sonar.Po ./$(DEPDIR)/target.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/util.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) --- 127,136 ---- depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles ! @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/error.Po ./$(DEPDIR)/expand.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/log.Po ./$(DEPDIR)/mem.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/mutex.Po ./$(DEPDIR)/net.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/plugin.Po ./$(DEPDIR)/popts.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/service.Po ./$(DEPDIR)/sonar.Po \ ! @AMDEP_TRUE@ ./$(DEPDIR)/target.Po ./$(DEPDIR)/util.Po COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) *************** *** 195,198 **** --- 196,200 ---- @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/error.Po@am__quote@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem.Po@am__quote@ Index: expand.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/expand.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** expand.c 23 Apr 2004 04:31:49 -0000 1.3 --- expand.c 23 Apr 2004 04:41:01 -0000 1.4 *************** *** 22,25 **** --- 22,28 ---- #include "expand.h" + static const char rcsid[] = + "\100$ autosec/sonar: $Id$"; + static char *res, *r; static int reslen = 0, curlen = 0; Index: Makefile.am =================================================================== RCS file: /cvsroot/autosec/sonar/src/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** Makefile.am 6 Feb 2004 06:20:50 -0000 1.16 --- Makefile.am 23 Apr 2004 04:41:01 -0000 1.17 *************** *** 6,10 **** noinst_HEADERS = util.h popts.h error.h bin_PROGRAMS = sonar ! sonar_SOURCES = sonar.c sonar.h util.c util.h plugin.c plugin.h popts.c popts.h error.c error.h mutex.c mutex.h net.c net.h target.c target.h service.c service.h log.c log.h mem.c mem.h sonar_LDADD = $(DYNAMIC_LD_LIBS) @LIBLTDL@ --- 6,10 ---- noinst_HEADERS = util.h popts.h error.h bin_PROGRAMS = sonar ! sonar_SOURCES = sonar.c sonar.h util.c util.h plugin.c plugin.h popts.c popts.h error.c error.h mutex.c mutex.h net.c expand.c expand.h net.h target.c target.h service.c service.h log.c log.h mem.c mem.h sonar_LDADD = $(DYNAMIC_LD_LIBS) @LIBLTDL@ |
From: red0x <re...@us...> - 2004-04-23 04:31:58
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13879/src Modified Files: expand.c expand.h Log Message: Credit where credit is due. Plus a few documentation and style questions/fixes. Index: expand.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/expand.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** expand.c 23 Apr 2004 04:08:11 -0000 1.2 --- expand.c 23 Apr 2004 04:31:49 -0000 1.3 *************** *** 3,8 **** ------------------- begin : Mon Apr 12 2004 ! copyright : (C) 2002 by red0x ! email : re...@us... rcsid : $Id$ ***************************************************************************/ --- 3,8 ---- ------------------- begin : Mon Apr 12 2004 ! copyright : (C) 2004 by pharkas ! email : ph...@us... rcsid : $Id$ ***************************************************************************/ *************** *** 23,136 **** static char *res, *r; ! static int reslen=0, curlen=0; ! char *expand_target(char *format, target_t *target, int port) { /* pointers within the format and res string, respectively */ char *f, *portname; int i; ! /* * we're freeing the previous result, so hopefully the caller realizes * that the return value is only good until the next call of * expand_target() */ ! if(res!=NULL) free(res); ! reslen=sizeof(format)*MALLOC_INC; ! res=(char*)malloc(sizeof(char)*reslen); ! f=format; ! r=res; ! ! while(*f!='\0') { ! if(*f=='%') { ! switch(*(++f)) ! { /* hostname:portname */ ! case 'T': ! /* skip over the 'T' */ ! f++; ! r+=print_hostname(r, target); ! checksize(1); ! *r++=':'; ! curlen++; ! r+=print_portname(r, port); ! break; /* ip:portnum */ ! case 't': ! f++; ! r+=print_ip(r, target); ! checksize(1); ! *r++=':'; ! curlen++; ! r+=print_port(r, port); ! break; /* ip */ ! case 'i': ! f++; ! r+=print_ip(r, target); ! break; /* hostname */ ! case 'h': ! f+=2; ! break; /* port number */ ! case 'p': ! f+=2; ! ! break; /* port name */ ! case 'P': ! f+=2; ! break; /* year */ ! case 'y': ! f+=2; ! break; ! /* month (numeric)*/ ! case 'm': ! f+=2; ! break; ! /* date */ ! case 'd': ! f+=2; ! break; /* hour */ ! case 'H': ! f+=2; ! break; /* minutes */ ! case 'M': ! f+=2; ! break; /* seconds */ ! case 'S': ! f+=2; ! break; ! default: ! checksize(2); ! *(r)='%'; ! *(++r)=*f++; ! r++; ! curlen+=2; ! break; } } ! else { checksize(1); ! *(r++)=*(f++); curlen++; } --- 23,139 ---- static char *res, *r; ! static int reslen = 0, curlen = 0; ! char * ! expand_target(char *format, target_t * target, int port) { /* pointers within the format and res string, respectively */ char *f, *portname; int i; ! /* * we're freeing the previous result, so hopefully the caller realizes * that the return value is only good until the next call of * expand_target() + * red0x: pharkas, make sure you document this well in the API document + * as well as the plugin writer's manual. */ ! if(res != NULL) free(res); ! reslen = sizeof(format) * MALLOC_INC; ! res = (char *) malloc(sizeof(char) * reslen); ! f = format; ! r = res; ! ! while(*f != '\0') { ! if(*f == '%') { ! switch (*(++f)) ! { /* hostname:portname */ ! case 'T': ! /* skip over the 'T' */ ! f++; ! r += print_hostname(r, target); ! checksize(1); ! *r++ = ':'; ! curlen++; ! r += print_portname(r, port); ! break; /* ip:portnum */ ! case 't': ! f++; ! r += print_ip(r, target); ! checksize(1); ! *r++ = ':'; ! curlen++; ! r += print_port(r, port); ! break; /* ip */ ! case 'i': ! f++; ! r += print_ip(r, target); ! break; /* hostname */ ! case 'h': ! f += 2; ! break; /* port number */ ! case 'p': ! f += 2; ! ! break; /* port name */ ! case 'P': ! f += 2; ! break; /* year */ ! case 'y': ! f += 2; ! break; ! /* month (numeric) */ ! case 'm': ! f += 2; ! break; ! /* day (numeric?) */ ! case 'd': ! f += 2; ! break; /* hour */ ! case 'H': ! f += 2; ! break; /* minutes */ ! case 'M': ! f += 2; ! break; /* seconds */ ! case 'S': ! f += 2; ! break; ! default: ! checksize(2); ! *(r) = '%'; ! *(++r) = *f++; ! r++; ! curlen += 2; ! break; } } ! else { checksize(1); ! *(r++) = *(f++); curlen++; } *************** *** 139,204 **** /* terminate the string */ checksize(1); ! *(res+curlen+1)='\0'; return res; } ! static void checksize(int i) { ! if(curlen+i>=reslen) { ! while(curlen+i>=(reslen*=MALLOC_INC)) { /* TODO: use safe realloc */ ! res=(char*)realloc(res, reslen); ! /* res may have been relocated in memory- make sure r is still ! * at the right place */ ! r=res+curlen; } } ! //curlen+=i; } ! int countdigits(int d) { ! int num=1; ! while((d=d/10)>0) num++; return num; } ! int print_hostname(char *result, target_t *t) { ! int i=strlen(t->entry); checksize(i); ! snprintf(result, i+1, "%s", t->entry); ! curlen+=i+1; ! *(result+i)='\0'; return i; } /* TODO: have this print the actual IP */ ! int print_ip(char *result, target_t *t) { return print_hostname(result, t); } ! int print_portname(char *result, int portnum) { ! int i=countdigits(portnum); checksize(i); ! snprintf(result, i+1, "%d", portnum); ! curlen+=i+1; ! *(result+i)='\0'; return i; } ! int print_port(char *result, int portnum) { ! int i=countdigits(portnum); checksize(i); ! snprintf(result, i+1, "%d", portnum); ! curlen+=i+1; ! *(result+i)='\0'; return i; } ! int main() { target_t t; ! char *name="test"; ! t.entry=name; printf("|%s|\n", expand_target("a b c %d %e %T %f %% %T", &t, 80)); ! return 0; } --- 142,228 ---- /* terminate the string */ checksize(1); ! *(res + curlen + 1) = '\0'; return res; } ! static void ! checksize(int i) ! { ! if(curlen + i >= reslen) ! { ! while(curlen + i >= (reslen *= MALLOC_INC)) ! { /* TODO: use safe realloc */ ! res = (char *) realloc(res, reslen); ! /* res may have been relocated in memory- make sure r is still at ! * the right place */ ! r = res + curlen; } } ! // curlen+=i; } ! int ! countdigits(int d) ! { ! int num = 1; ! while((d = d / 10) > 0) num++; return num; } ! int ! print_hostname(char *result, target_t * t) ! { ! int i = strlen(t->entry); checksize(i); ! snprintf(result, i + 1, "%s", t->entry); ! curlen += i + 1; ! *(result + i) = '\0'; return i; } /* TODO: have this print the actual IP */ ! int ! print_ip(char *result, target_t * t) ! { return print_hostname(result, t); } ! int ! print_portname(char *result, int portnum) ! { ! int i = countdigits(portnum); checksize(i); ! snprintf(result, i + 1, "%d", portnum); ! curlen += i + 1; ! *(result + i) = '\0'; return i; } ! int ! print_port(char *result, int portnum) ! { ! int i = countdigits(portnum); checksize(i); ! snprintf(result, i + 1, "%d", portnum); ! curlen += i + 1; ! *(result + i) = '\0'; return i; } ! /* red0x: I'm wrapping this in ifdef's for later testing */ ! #ifdef TEST_EXPAND ! ! int ! main() ! { target_t t; ! char *name = "test"; ! t.entry = name; printf("|%s|\n", expand_target("a b c %d %e %T %f %% %T", &t, 80)); ! return 0; } + + #endif /* TEST_EXPAND */ Index: expand.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/expand.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** expand.h 23 Apr 2004 04:06:10 -0000 1.1 --- expand.h 23 Apr 2004 04:31:49 -0000 1.2 *************** *** 1,10 **** /*************************************************************************** ! target.h Target string expansion header file ------------------- begin : Mon Apr 12 2004 ! copyright : (C) 2002 by red0x ! email : re...@us... ***************************************************************************/ ! /*************************************************************************** * * --- 1,10 ---- /*************************************************************************** ! expand.h Command line formating expander header file ------------------- begin : Mon Apr 12 2004 ! copyright : (C) 2004 by pharkas ! email : ph...@us... ***************************************************************************/ ! /*************************************************************************** * * *************** *** 25,37 **** #include "plugin.h" #define MALLOC_INC 1.5 ! char *expand_target(char*,target_t*,int); static void checksize(int); int countdigits(int); ! int print_hostname(char*,target_t*); ! int print_ip(char*,target_t*); ! int print_port(char*,int); ! int print_portname(char*,int); #endif --- 25,38 ---- #include "plugin.h" + /* red0x: what does this alter? */ #define MALLOC_INC 1.5 ! char *expand_target(char *, target_t *, int); static void checksize(int); int countdigits(int); ! int print_hostname(char *, target_t *); ! int print_ip(char *, target_t *); ! int print_port(char *, int); ! int print_portname(char *, int); #endif |
From: Jacob F. <ph...@us...> - 2004-04-23 04:08:19
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10516 Modified Files: expand.c Log Message: What was that? Broken code? Nothing to see here...move along Index: expand.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/expand.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** expand.c 23 Apr 2004 04:06:10 -0000 1.1 --- expand.c 23 Apr 2004 04:08:11 -0000 1.2 *************** *** 167,171 **** int i=strlen(t->entry); checksize(i); ! snprintf(result, i+1, "%s", hostname); curlen+=i+1; *(result+i)='\0'; --- 167,171 ---- int i=strlen(t->entry); checksize(i); ! snprintf(result, i+1, "%s", t->entry); curlen+=i+1; *(result+i)='\0'; |
From: Jacob F. <ph...@us...> - 2004-04-23 04:06:18
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10285 Added Files: expand.c expand.h Log Message: Target expansion code --- NEW FILE: expand.c --- /*************************************************************************** expand.c - Command line formating expander ------------------- begin : Mon Apr 12 2004 copyright : (C) 2002 by red0x email : re...@us... rcsid : $Id: expand.c,v 1.1 2004/04/23 04:06:10 pharkas Exp $ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /** @file expand.c * Expands printf-style characters in a given string */ #include "expand.h" static char *res, *r; static int reslen=0, curlen=0; char *expand_target(char *format, target_t *target, int port) { /* pointers within the format and res string, respectively */ char *f, *portname; int i; /* * we're freeing the previous result, so hopefully the caller realizes * that the return value is only good until the next call of * expand_target() */ if(res!=NULL) free(res); reslen=sizeof(format)*MALLOC_INC; res=(char*)malloc(sizeof(char)*reslen); f=format; r=res; while(*f!='\0') { if(*f=='%') { switch(*(++f)) { /* hostname:portname */ case 'T': /* skip over the 'T' */ f++; r+=print_hostname(r, target); checksize(1); *r++=':'; curlen++; r+=print_portname(r, port); break; /* ip:portnum */ case 't': f++; r+=print_ip(r, target); checksize(1); *r++=':'; curlen++; r+=print_port(r, port); break; /* ip */ case 'i': f++; r+=print_ip(r, target); break; /* hostname */ case 'h': f+=2; break; /* port number */ case 'p': f+=2; break; /* port name */ case 'P': f+=2; break; /* year */ case 'y': f+=2; break; /* month (numeric)*/ case 'm': f+=2; break; /* date */ case 'd': f+=2; break; /* hour */ case 'H': f+=2; break; /* minutes */ case 'M': f+=2; break; /* seconds */ case 'S': f+=2; break; default: checksize(2); *(r)='%'; *(++r)=*f++; r++; curlen+=2; break; } } else { checksize(1); *(r++)=*(f++); curlen++; } } /* terminate the string */ checksize(1); *(res+curlen+1)='\0'; return res; } static void checksize(int i) { if(curlen+i>=reslen) { while(curlen+i>=(reslen*=MALLOC_INC)) { /* TODO: use safe realloc */ res=(char*)realloc(res, reslen); /* res may have been relocated in memory- make sure r is still * at the right place */ r=res+curlen; } } //curlen+=i; } int countdigits(int d) { int num=1; while((d=d/10)>0) num++; return num; } int print_hostname(char *result, target_t *t) { int i=strlen(t->entry); checksize(i); snprintf(result, i+1, "%s", hostname); curlen+=i+1; *(result+i)='\0'; return i; } /* TODO: have this print the actual IP */ int print_ip(char *result, target_t *t) { return print_hostname(result, t); } int print_portname(char *result, int portnum) { int i=countdigits(portnum); checksize(i); snprintf(result, i+1, "%d", portnum); curlen+=i+1; *(result+i)='\0'; return i; } int print_port(char *result, int portnum) { int i=countdigits(portnum); checksize(i); snprintf(result, i+1, "%d", portnum); curlen+=i+1; *(result+i)='\0'; return i; } int main() { target_t t; char *name="test"; t.entry=name; printf("|%s|\n", expand_target("a b c %d %e %T %f %% %T", &t, 80)); return 0; } --- NEW FILE: expand.h --- /*************************************************************************** target.h Target string expansion header file ------------------- begin : Mon Apr 12 2004 copyright : (C) 2002 by red0x email : re...@us... ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ /** \file expand.h * header file for target string expansion */ #ifndef TARGET_H #define TARGET_H #include <stdlib.h> #include "mem.h" #include "plugin.h" #define MALLOC_INC 1.5 char *expand_target(char*,target_t*,int); static void checksize(int); int countdigits(int); int print_hostname(char*,target_t*); int print_ip(char*,target_t*); int print_port(char*,int); int print_portname(char*,int); #endif |
From: red0x <re...@us...> - 2004-04-23 02:36:03
|
Update of /cvsroot/autosec/sonar/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30296/plugins Modified Files: rfc793.c Log Message: Added placeholder for pharkas' string expansion routine. grep for 'PHARKAS'. Index: rfc793.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.c,v retrieving revision 1.48 retrieving revision 1.49 diff -C2 -d -r1.48 -r1.49 *** rfc793.c 13 Apr 2004 03:42:07 -0000 1.48 --- rfc793.c 23 Apr 2004 02:35:55 -0000 1.49 *************** *** 751,754 **** --- 751,760 ---- my_host->stats.packets_recvd++; + /* + * PHARKAS + * Call your function like this + */ + //mthis->foobar(char*string_to_expand, tcp->th_sport, my_host); + num_res++; if(mthis->opts.iVerbose > 1) |
From: red0x <re...@us...> - 2004-04-13 03:56:07
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24331/src Modified Files: error.c log.c log.h mem.c mem.h mutex.c mutex.h net.c plugin.c plugin.h popts.c popts.h service.c service.h sonar.c sonar.h target.c target.h types.h util.c util.h Log Message: Massive code 'indent' Index: mem.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/mem.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mem.h 6 Feb 2004 06:20:50 -0000 1.1 --- mem.h 13 Apr 2004 03:42:08 -0000 1.2 *************** *** 18,22 **** * File contains memory wrappers */ ! #include <stdlib.h> #include <assert.h> --- 18,22 ---- * File contains memory wrappers */ ! #include <stdlib.h> #include <assert.h> *************** *** 25,27 **** void *Malloc(size_t size); void *Realloc(void *ptr, size_t size); - --- 25,26 ---- Index: log.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/log.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** log.c 9 Apr 2004 15:26:33 -0000 1.8 --- log.c 13 Apr 2004 03:42:08 -0000 1.9 *************** *** 30,80 **** * \param msg Format string to output */ ! void log_write(int flags, char *msg, ...) { ! va_list ap; ! int i; ! va_start(ap, msg); #ifdef DEBUG ! if(flags & LOG_DBUG) ! { ! fprintf(stderr, "DEBUG: "); ! vfprintf(stderr, msg, ap); ! return; ! } #endif ! if(flags & LOG_CONSOLE) { - /* if we are forked, or quiet, dont do this */ - if(!mthis.opts.bFork && mthis.opts.iVerbose >= 0) - { #ifdef DEBUG ! fprintf(stderr, "CONSOLE: "); ! #endif ! vfprintf(stderr, msg, ap); ! } } ! if(flags & LOG_SLOG) { ! /* only print in syslog if we are forked */ ! if(mthis.opts.bFork) ! { ! /*openlog("sonar", LOG_PID, LOG_DAEMON);*/ ! vsyslog(LOG_DAEMON | LOG_NOTICE, msg, ap); ! /*closelog();*/ ! } } ! if(flags & LOG_PLUGINS) { ! for(i = 0; i < num_out; i++) ! { ! if(output_list[i].plug != NULL) ! if(output_list[i].plug->selected ! && output_list[i].plug->ready) ! output_list[i].plug-> ! plugin_output(msg, &ap); ! } } ! va_end(ap); } --- 30,80 ---- * \param msg Format string to output */ ! void ! log_write(int flags, char *msg, ...) { ! va_list ap; ! int i; ! va_start(ap, msg); #ifdef DEBUG ! if(flags & LOG_DBUG) ! { ! fprintf(stderr, "DEBUG: "); ! vfprintf(stderr, msg, ap); ! return; ! } #endif ! if(flags & LOG_CONSOLE) ! { ! /* if we are forked, or quiet, dont do this */ ! if(!mthis.opts.bFork && mthis.opts.iVerbose >= 0) { #ifdef DEBUG ! fprintf(stderr, "CONSOLE: "); ! #endif ! vfprintf(stderr, msg, ap); } ! } ! if(flags & LOG_SLOG) ! { ! /* only print in syslog if we are forked */ ! if(mthis.opts.bFork) { ! /* openlog("sonar", LOG_PID, LOG_DAEMON); */ ! vsyslog(LOG_DAEMON | LOG_NOTICE, msg, ap); ! /* closelog(); */ } ! } ! if(flags & LOG_PLUGINS) ! { ! for(i = 0; i < num_out; i++) { ! if(output_list[i].plug != NULL) ! if(output_list[i].plug->selected ! && output_list[i].plug->ready) ! output_list[i].plug->plugin_output(msg, &ap); } ! } ! va_end(ap); } Index: sonar.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/sonar.h,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** sonar.h 11 Apr 2004 04:47:49 -0000 1.32 --- sonar.h 13 Apr 2004 03:42:08 -0000 1.33 *************** *** 42,46 **** {"debug", 0, NULL, 'b'}, \ {"plugin_list", 0, NULL, 'l'}, \ ! int h_errno; --- 42,46 ---- {"debug", 0, NULL, 'b'}, \ {"plugin_list", 0, NULL, 'l'}, \ ! int h_errno; *************** *** 49,53 **** void sonar_status_report(sonar_t mthis); int sonar_rawoutput(char *msg, ...); ! int sonar_sweep(target_t *targets); void default_context(void *in); --- 49,53 ---- void sonar_status_report(sonar_t mthis); int sonar_rawoutput(char *msg, ...); ! int sonar_sweep(target_t * targets); void default_context(void *in); Index: service.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/service.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** service.h 4 Nov 2003 23:48:40 -0000 1.2 --- service.h 13 Apr 2004 03:42:08 -0000 1.3 *************** *** 24,30 **** /*#include "target.h"*/ ! int sonar_resolve_service(char *serv, target_t *result); ! int sonar_resolve_service_r(char *low, char *high, target_t *result); ! #endif //_SERVICE_H_ --- 24,30 ---- /*#include "target.h"*/ ! int sonar_resolve_service(char *serv, target_t * result); ! int sonar_resolve_service_r(char *low, char *high, target_t * result); ! #endif // _SERVICE_H_ Index: plugin.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** plugin.h 11 Apr 2004 04:44:18 -0000 1.43 --- plugin.h 13 Apr 2004 03:42:08 -0000 1.44 *************** *** 110,119 **** typedef struct stats_s stats_t; ! struct stats_s { ! unsigned int packets_sent; ! unsigned int packets_recvd; ! unsigned short ttl; ! double rtt_min, rtt_max, rtt_avg; }; --- 110,119 ---- typedef struct stats_s stats_t; ! struct stats_s { ! unsigned int packets_sent; ! unsigned int packets_recvd; ! unsigned short ttl; ! double rtt_min, rtt_max, rtt_avg; }; *************** *** 122,143 **** struct target_s { ! /// next target in list ! target_t *next; ! /// user specified entry ! char *entry; ! /// list of ports to scan ! int ports[MAX_PORTS]; ! /// address info, including family, protocol, and socket type ! struct addrinfo *addrinfo; ! /// netmask ! unsigned int netmask; ! /// extra hosts involved in this (ie, w/netmask) ! unsigned int extra_hosts; ! /// broadcast address ! unsigned short broadcast; ! /// number of ports in this host ! uint32_t num_ports; ! /// statistics ! stats_t stats; }; --- 122,143 ---- struct target_s { ! // / next target in list ! target_t *next; ! // / user specified entry ! char *entry; ! // / list of ports to scan ! int ports[MAX_PORTS]; ! // / address info, including family, protocol, and socket type ! struct addrinfo *addrinfo; ! // / netmask ! unsigned int netmask; ! // / extra hosts involved in this (ie, w/netmask) ! unsigned int extra_hosts; ! // / broadcast address ! unsigned short broadcast; ! // / number of ports in this host ! uint32_t num_ports; ! // / statistics ! stats_t stats; }; *************** *** 147,170 **** typedef struct sonar_options_s { ! /// Delay after running this type of scan (advanced option) int iPostDelay; ! /// Delay after each host int iHostDelay; ! /// Timeout per host int iTimeout; ! /// do we have broadcast addresses in the targets? int bBroadcast; ! /// Verbosity level (0 to 5) int iVerbose; ! /// Fork into daemon mode? (0/1) int bFork; ! /// Command line char *sCommandLine; ! /// Number of scanning cycles to run unsigned int iCount; ! /// Random order of hosts? int bRandom; ! }sonar_options_t; /** \struct plugin_s --- 147,170 ---- typedef struct sonar_options_s { ! // / Delay after running this type of scan (advanced option) int iPostDelay; ! // / Delay after each host int iHostDelay; ! // / Timeout per host int iTimeout; ! // / do we have broadcast addresses in the targets? int bBroadcast; ! // / Verbosity level (0 to 5) int iVerbose; ! // / Fork into daemon mode? (0/1) int bFork; ! // / Command line char *sCommandLine; ! // / Number of scanning cycles to run unsigned int iCount; ! // / Random order of hosts? int bRandom; ! } sonar_options_t; /** \struct plugin_s *************** *** 174,226 **** typedef struct plugin_s { ! /// unique ID assigned at run time ! uint32_t pluginID; ! /// plugin api interface version, lower versions _may_ be supported ! uint8_t version; ! /// plugin type (INPUT_PLUGIN | OUTPUT_PLUGIN for an I/O plugin) ! uint8_t type; ! /// last error from this plugin ! int16_t *err; ! /// ready to use flag, not modified by sonar ! uint8_t ready:4, ! /// The plugin was selected ! selected:4; ! /// Plugin character (ie, -sI, -sA, -sL, -oL) ! char plugin_char; ! /// Short name (ie, "icmp scan", "log file output") ! char *shortname; ! /// Long name (ie, "ICMP Scanning Plugin: requires root...") ! char *longname; ! /// Initialize this plugin ! void *(*plugin_init) (void *in_data); ! /// Destroy this plugin ! int (*plugin_destroy) (void); ! /// Open the input/output/network source ! int (*plugin_open) (void *c_data, int i_data); ! /// Close the input/output/network source ! int (*plugin_close) (void); ! /// Get next host, returned in hostname, only for input plugins ! /// Set next host, for network plugins ! int (*plugin_next) (char *hostname); ! /// Do the sweep (network plugins) ! int (*plugin_sweep) (target_t *targets); ! /// Output plugin's general message output function ! int (*plugin_output) (char *msg, va_list * ap); ! /// output plugins result output function ! int (*plugin_results) (target_t *result, unsigned int num); ! /// prints, via sonar_t->output(), line(s) to add to sonar_usage() ! void (*plugin_usage) (void); ! /// prints, via sonar_t->output(), line(s) to add to the status report ! void (*plugin_status) (void); ! /// Return the last error ! int (*plugin_last_error) (void); } plugin_t; --- 174,226 ---- typedef struct plugin_s { ! // / unique ID assigned at run time ! uint32_t pluginID; ! // / plugin api interface version, lower versions _may_ be supported ! uint8_t version; ! // / plugin type (INPUT_PLUGIN | OUTPUT_PLUGIN for an I/O plugin) ! uint8_t type; ! // / last error from this plugin ! int16_t *err; ! // / ready to use flag, not modified by sonar ! uint8_t ready:4, ! // / The plugin was selected ! selected:4; ! // / Plugin character (ie, -sI, -sA, -sL, -oL) ! char plugin_char; ! // / Short name (ie, "icmp scan", "log file output") ! char *shortname; ! // / Long name (ie, "ICMP Scanning Plugin: requires root...") ! char *longname; ! // / Initialize this plugin ! void *(*plugin_init) (void *in_data); ! // / Destroy this plugin ! int (*plugin_destroy) (void); ! // / Open the input/output/network source ! int (*plugin_open) (void *c_data, int i_data); ! // / Close the input/output/network source ! int (*plugin_close) (void); ! // / Get next host, returned in hostname, only for input plugins ! // / Set next host, for network plugins ! int (*plugin_next) (char *hostname); ! // / Do the sweep (network plugins) ! int (*plugin_sweep) (target_t * targets); ! // / Output plugin's general message output function ! int (*plugin_output) (char *msg, va_list * ap); ! // / output plugins result output function ! int (*plugin_results) (target_t * result, unsigned int num); ! // / prints, via sonar_t->output(), line(s) to add to sonar_usage() ! void (*plugin_usage) (void); ! // / prints, via sonar_t->output(), line(s) to add to the status report ! void (*plugin_status) (void); ! // / Return the last error ! int (*plugin_last_error) (void); } plugin_t; *************** *** 234,280 **** typedef struct sonar_s { ! /// Major version number ! uint8_t ver_major, ! /// Minor version number ! ver_minor, ! /// Revision number ! revision, ! /// Plugin API version 1.X (so for 1.4, set this to 4) ! api; ! /// Pointer to a memory copier from sonar (XXX: remove) ! void (*memput) (char **dest, const char *src, const int len); ! ! /// Pointer to the Messsage output (ie, with a timestamp) function from sonar ! void (*message) (char *msg, ...); ! ! /// let the resolving function live in sonar, so each network plugin wont have to write its own ! /// unless it wants to ! struct addrinfo * (*resolve) (const char *host, const char *serv, int family, ! int socktype); ! /// Pointer to sonar's output to console function (no timestamp) ! int (*output) (char *msg, ...); ! /// Pointer to usage function, for error reports ! void (*usage) (const char *); ! /// Pointer to a function to get root priveleges ! int (*getprivs) (void); ! /// Pointer to a function to drop root priveleges ! int (*dropprivs) (uid_t); ! /// find a target, for updating ! target_t *(*find_target) (struct sonar_s *this, struct addrinfo *ai); ! /// Name of file we are (for permissions checking) ! char *my_name; ! /// list of attack vectors ! target_t *vectors; ! /// number of targets ! unsigned int num_targets; ! /// number of ports ! unsigned int num_ports; ! /// Useful global options sonar_options_t opts; } sonar_t; --- 234,282 ---- typedef struct sonar_s { ! // / Major version number ! uint8_t ver_major, ! // / Minor version number ! ver_minor, ! // / Revision number ! revision, ! // / Plugin API version 1.X (so for 1.4, set this to 4) ! api; ! // / Pointer to a memory copier from sonar (XXX: remove) ! void (*memput) (char **dest, const char *src, const int len); ! // / Pointer to the Messsage output (ie, with a timestamp) function from ! // sonar ! void (*message) (char *msg, ...); ! // / let the resolving function live in sonar, so each network plugin ! // wont have to write its own ! // / unless it wants to ! struct addrinfo *(*resolve) (const char *host, const char *serv, ! int family, int socktype); ! // / Pointer to sonar's output to console function (no timestamp) ! int (*output) (char *msg, ...); ! // / Pointer to usage function, for error reports ! void (*usage) (const char *); ! // / Pointer to a function to get root priveleges ! int (*getprivs) (void); ! // / Pointer to a function to drop root priveleges ! int (*dropprivs) (uid_t); ! // / find a target, for updating ! target_t *(*find_target) (struct sonar_s * this, struct addrinfo * ai); ! // / Name of file we are (for permissions checking) ! char *my_name; ! ! // / list of attack vectors ! target_t *vectors; ! // / number of targets ! unsigned int num_targets; ! // / number of ports ! unsigned int num_ports; ! ! // / Useful global options sonar_options_t opts; } sonar_t; *************** *** 285,292 **** typedef struct plugin_list_s { ! /// Pointer to a plugin_t structure ! plugin_t *plug; ! /// Handle to library opened with \c lt_dlopen(3) ! void *handle; } plugin_list_t; --- 287,294 ---- typedef struct plugin_list_s { ! // / Pointer to a plugin_t structure ! plugin_t *plug; ! // / Handle to library opened with \c lt_dlopen(3) ! void *handle; } plugin_list_t; *************** *** 299,303 **** int plugin_command_handler(char opt, char *optarg); void plugin_message_hook(char *msg, va_list * ap); ! void clear_opts(sonar_options_t*); --- 301,305 ---- int plugin_command_handler(char opt, char *optarg); void plugin_message_hook(char *msg, va_list * ap); ! void clear_opts(sonar_options_t *); *************** *** 448,450 **** */ ! #endif //_PLUGIN_H --- 450,452 ---- */ ! #endif // _PLUGIN_H Index: net.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/net.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** net.c 28 Feb 2004 08:57:14 -0000 1.3 --- net.c 13 Apr 2004 03:42:08 -0000 1.4 *************** *** 34,54 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! struct addrinfo *host_serv(const char *host, const char *serv, int family, ! int socktype) { ! int n; ! struct addrinfo hints, *res; ! bzero(&hints, sizeof(struct addrinfo)); ! hints.ai_flags = AI_CANONNAME; /* always return canonical name */ ! hints.ai_family = family; /* AF_UNSPEC, AF_INET, AF_INET6, etc. */ ! hints.ai_socktype = socktype; /* 0, SOCK_STREAM, SOCK_DGRAM, etc. */ ! if((n = getaddrinfo(host, serv, &hints, &res)) != 0) ! return (NULL); ! return (res); /* return pointer to first on linked list */ } --- 34,54 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! struct addrinfo * ! host_serv(const char *host, const char *serv, int family, int socktype) { ! int n; ! struct addrinfo hints, *res; ! bzero(&hints, sizeof(struct addrinfo)); ! hints.ai_flags = AI_CANONNAME; /* always return canonical name */ ! hints.ai_family = family; /* AF_UNSPEC, AF_INET, AF_INET6, etc. */ ! hints.ai_socktype = socktype; /* 0, SOCK_STREAM, SOCK_DGRAM, etc. */ ! if((n = getaddrinfo(host, serv, &hints, &res)) != 0) ! return (NULL); ! return (res); /* return pointer to first on linked list */ } *************** *** 62,82 **** */ ! struct addrinfo *Host_serv(const char *host, const char *serv, int family, ! int socktype) { ! int n; ! struct addrinfo hints, *res; ! bzero(&hints, sizeof(struct addrinfo)); ! hints.ai_flags = AI_CANONNAME; /* always return canonical name */ ! hints.ai_family = family; /* 0, AF_INET, AF_INET6, etc. */ ! hints.ai_socktype = socktype; /* 0, SOCK_STREAM, SOCK_DGRAM, etc. */ ! if((n = getaddrinfo(host, serv, &hints, &res)) != 0) ! err_quit("host_serv error for %s, %s: %s", ! (host == NULL) ? "(no hostname)" : host, ! (serv == NULL) ? "(no service name)" : serv, ! gai_strerror(n)); ! return (res); /* return pointer to first on linked list */ } --- 62,82 ---- */ ! struct addrinfo * ! Host_serv(const char *host, const char *serv, int family, int socktype) { ! int n; ! struct addrinfo hints, *res; ! bzero(&hints, sizeof(struct addrinfo)); ! hints.ai_flags = AI_CANONNAME; /* always return canonical name */ ! hints.ai_family = family; /* 0, AF_INET, AF_INET6, etc. */ ! hints.ai_socktype = socktype; /* 0, SOCK_STREAM, SOCK_DGRAM, etc. */ ! if((n = getaddrinfo(host, serv, &hints, &res)) != 0) ! err_quit("host_serv error for %s, %s: %s", ! (host == NULL) ? "(no hostname)" : host, ! (serv == NULL) ? "(no service name)" : serv, ! gai_strerror(n)); ! return (res); /* return pointer to first on linked list */ } Index: mem.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/mem.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mem.c 6 Feb 2004 06:20:50 -0000 1.1 --- mem.c 13 Apr 2004 03:42:08 -0000 1.2 *************** *** 22,47 **** #include "error.h" ! void *Calloc(size_t nmemb, size_t size) { ! void *ptr = calloc(nmemb, size); ! if(!ptr) ! err_sys("calloc failed\n"); ! return ptr; } ! void *Malloc(size_t size) { ! void *ptr = malloc(size); ! if(!ptr) ! err_sys("Malloc failed\n"); ! return ptr; } ! void *Realloc(void *ptr, size_t size) { ! void *ptr2; ! ptr2 = realloc(ptr, size); ! if(!ptr) ! err_sys("realloc failed\n"); ! return ptr2; } --- 22,50 ---- #include "error.h" ! void * ! Calloc(size_t nmemb, size_t size) { ! void *ptr = calloc(nmemb, size); ! if(!ptr) ! err_sys("calloc failed\n"); ! return ptr; } ! void * ! Malloc(size_t size) { ! void *ptr = malloc(size); ! if(!ptr) ! err_sys("Malloc failed\n"); ! return ptr; } ! void * ! Realloc(void *ptr, size_t size) { ! void *ptr2; ! ptr2 = realloc(ptr, size); ! if(!ptr) ! err_sys("realloc failed\n"); ! return ptr2; } Index: plugin.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.c,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** plugin.c 11 Apr 2004 04:44:18 -0000 1.34 --- plugin.c 13 Apr 2004 03:42:08 -0000 1.35 *************** *** 51,67 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /*woutput(char *msg, ...); extern int verbose;*/ ! static int plugin_add(int type, plugin_t * p_data, sonar_t * mthis, void *hptr); /// list of input plugins ! plugin_list_t input_list[MAX_INP]; ! uint32_t input_buf[MAX_INP]; /// list of output plugins ! plugin_list_t output_list[MAX_OUT]; /// list of network plugins ! plugin_list_t network_list[MAX_NET]; /// plugin id system PID --- 51,68 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /*woutput(char *msg, ...); extern int verbose;*/ ! static int plugin_add(int type, plugin_t * p_data, sonar_t * mthis, ! void *hptr); /// list of input plugins ! plugin_list_t input_list[MAX_INP]; ! uint32_t input_buf[MAX_INP]; /// list of output plugins ! plugin_list_t output_list[MAX_OUT]; /// list of network plugins ! plugin_list_t network_list[MAX_NET]; /// plugin id system PID *************** *** 70,76 **** unsigned long int num_inp, /// number of output plugins ! num_out, /// number of network plugins ! num_net; /** @name Plugin API Internals --- 71,77 ---- unsigned long int num_inp, /// number of output plugins ! num_out, /// number of network plugins ! num_net; /** @name Plugin API Internals *************** *** 88,92 **** * @return 1 if the system is ready */ ! static int inline plugin_ready() { // are they all defined? --- 89,94 ---- * @return 1 if the system is ready */ ! static int inline ! plugin_ready() { // are they all defined? *************** *** 103,112 **** * @param plugin_list plugin_list_t pointer */ ! static void inline plugin_init(plugin_list_t * plugin_list) { // set the plugin to NULL plugin_list->plug = NULL; ! plugin_list->handle = NULL; ! memset(input_buf, 0, MAX_INP * sizeof(uint32_t)); } --- 105,115 ---- * @param plugin_list plugin_list_t pointer */ ! static void inline ! plugin_init(plugin_list_t * plugin_list) { // set the plugin to NULL plugin_list->plug = NULL; ! plugin_list->handle = NULL; ! memset(input_buf, 0, MAX_INP * sizeof(uint32_t)); } *************** *** 116,123 **** * @return A new, unique plugin ID */ ! static int inline plugin_newid() { ! return (unsigned long int) ++first_pid; ! /* (first_pid += ((unsigned int)(200.0 * rand() / (RAND_MAX + 64.0))));*/ } --- 119,127 ---- * @return A new, unique plugin ID */ ! static int inline ! plugin_newid() { ! return (unsigned long int) ++first_pid; ! /* (first_pid += ((unsigned int)(200.0 * rand() / (RAND_MAX + 64.0)))); */ } *************** *** 139,147 **** * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! int plugin_start(sonar_t * mthis) { if(!input_list) { ! err_sys("Input Array not Initialized: %s line %d", __FILE__, __LINE__); return PLUGIN_ERROR; } --- 143,153 ---- * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! int ! plugin_start(sonar_t * mthis) { if(!input_list) { ! err_sys("Input Array not Initialized: %s line %d", __FILE__, ! __LINE__); return PLUGIN_ERROR; } *************** *** 149,153 **** if(!output_list) { ! err_sys("Output Array not Initialized: %s line %d", __FILE__, __LINE__); return PLUGIN_ERROR; } --- 155,160 ---- if(!output_list) { ! err_sys("Output Array not Initialized: %s line %d", __FILE__, ! __LINE__); return PLUGIN_ERROR; } *************** *** 155,159 **** if(!network_list) { ! err_sys("Network Array not Initialized: %s line %d", __FILE__,__LINE__); return PLUGIN_ERROR; } --- 162,167 ---- if(!network_list) { ! err_sys("Network Array not Initialized: %s line %d", __FILE__, ! __LINE__); return PLUGIN_ERROR; } *************** *** 169,173 **** * @return PLUGIN_OK */ ! int plugin_end() { #ifdef DEBUG --- 177,182 ---- * @return PLUGIN_OK */ ! int ! plugin_end() { #ifdef DEBUG *************** *** 186,190 **** * @todo Lock the plugin library while checking permissions, to avoid a race */ ! int plugin_loadall(sonar_t * mthis) { /* directory to search defined as PLUGINDIR */ --- 195,200 ---- * @todo Lock the plugin library while checking permissions, to avoid a race */ ! int ! plugin_loadall(sonar_t * mthis) { /* directory to search defined as PLUGINDIR */ *************** *** 198,202 **** /* try to get the owner and mode of sonar */ if((my_buf = get_stats(mthis->my_name)) == NULL) ! err_sys("could not stat %s", mthis->my_name); log_write(LOG_DBUG, " opendir(%s);\n", PLUGINDIR); --- 208,212 ---- /* try to get the owner and mode of sonar */ if((my_buf = get_stats(mthis->my_name)) == NULL) ! err_sys("could not stat %s", mthis->my_name); log_write(LOG_DBUG, " opendir(%s);\n", PLUGINDIR); *************** *** 213,225 **** int len = strlen(entry->d_name); log_write(LOG_DBUG, " found %s\n", entry->d_name); ! /* all plugins must have this in their names, at the ! beginning */ if(len < strlen(PLUGIN_HEADER)) continue; ! /* this code filters out other libraries ! needed once we went libtool */ if(strncmp(entry->d_name, PLUGIN_HEADER, ! strlen(PLUGIN_HEADER)) != 0) ! continue; /* not the one */ if((entry->d_name[len - 3] == '.') && (entry->d_name[len - 2] == 's') && --- 223,234 ---- int len = strlen(entry->d_name); log_write(LOG_DBUG, " found %s\n", entry->d_name); ! /* all plugins must have this in their names, at the beginning */ if(len < strlen(PLUGIN_HEADER)) continue; ! /* this code filters out other libraries needed once we went ! * libtool */ if(strncmp(entry->d_name, PLUGIN_HEADER, ! strlen(PLUGIN_HEADER)) != 0) ! continue; /* not the one */ if((entry->d_name[len - 3] == '.') && (entry->d_name[len - 2] == 's') && *************** *** 241,245 **** { log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s is world writable! not loading!", str); continue; } --- 250,255 ---- { log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s is world writable! not loading!", ! str); continue; } *************** *** 251,258 **** if(stat_buf.st_uid != 0) { ! log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s owned by someone else (%d, not %d)! " ! "not loading!", ! str, stat_buf.st_uid, my_buf->st_uid); continue; } --- 261,268 ---- if(stat_buf.st_uid != 0) { ! log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s owned by someone else (%d, not %d)! " ! "not loading!", ! str, stat_buf.st_uid, my_buf->st_uid); continue; } *************** *** 262,266 **** /* end check */ lt_dlinit(); ! log_write(LOG_DBUG," lt_dlopen(%s); => ",str); if((plugin = lt_dlopen(str)) == NULL) --- 272,276 ---- /* end check */ lt_dlinit(); ! log_write(LOG_DBUG, " lt_dlopen(%s); => ", str); if((plugin = lt_dlopen(str)) == NULL) *************** *** 268,273 **** char *dl_error_msg = (char *) lt_dlerror(); log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, ! "could not load %s: %s\n", str, dl_error_msg); continue; } --- 278,283 ---- char *dl_error_msg = (char *) lt_dlerror(); log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, ! "could not load %s: %s\n", str, dl_error_msg); continue; } *************** *** 286,291 **** { log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG," Could not load " ! "%s:\nplugin_init failed\n", str); } else --- 296,301 ---- { log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, " Could not load " ! "%s:\nplugin_init failed\n", str); } else *************** *** 293,308 **** log_write(LOG_DBUG, " %p (ok)\n", plug); /* only support from version API_SUPPORT on up */ ! if(plug->version > API_VER || plug->version < API_SUPPORT) { ! log_write(LOG_CONSOLE | LOG_SLOG, ! " Warning: Plugin \"%s\" wanted an unsupported" ! " api, version \'%d\', not loading\n", ! plug->shortname, plug->version); lt_dlclose(plugin); continue; } ! log_write(LOG_DBUG, " plugin_add(%d, %p, %p, %p);\n", ! plug, plug->type, plug, mthis, plugin); plugin_add(plug->type, plug, mthis, plugin); } --- 303,318 ---- log_write(LOG_DBUG, " %p (ok)\n", plug); /* only support from version API_SUPPORT on up */ ! if(plug->version > API_VER || plug->version < API_SUPPORT) { ! log_write(LOG_CONSOLE | LOG_SLOG, ! " Warning: Plugin \"%s\" wanted an unsupported" ! " api, version \'%d\', not loading\n", ! plug->shortname, plug->version); lt_dlclose(plugin); continue; } ! log_write(LOG_DBUG, " plugin_add(%d, %p, %p, %p);\n", ! plug, plug->type, plug, mthis, plugin); plugin_add(plug->type, plug, mthis, plugin); } *************** *** 313,317 **** log_write(LOG_DBUG, " FAILED!\n"); log_write(LOG_CONSOLE | LOG_SLOG, " could not load " ! "plugin_init in %s:\n%s\n", str, dl_error_msg); } } --- 323,327 ---- log_write(LOG_DBUG, " FAILED!\n"); log_write(LOG_CONSOLE | LOG_SLOG, " could not load " ! "plugin_init in %s:\n%s\n", str, dl_error_msg); } } *************** *** 334,344 **** * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! int plugin_killall(void) { int err = PLUGIN_OK; ! log_write(LOG_DBUG, " plugin_killall();\n"); ! ! //get all input, output, network plugins ! //call the plugin_destroy function for(; num_inp > 0; num_inp--) { --- 344,355 ---- * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! int ! plugin_killall(void) { int err = PLUGIN_OK; ! log_write(LOG_DBUG, " plugin_killall();\n"); ! ! // get all input, output, network plugins ! // call the plugin_destroy function for(; num_inp > 0; num_inp--) { *************** *** 346,359 **** assert(input_list[num_inp - 1].plug != NULL); assert(input_list[num_inp - 1].plug->plugin_destroy != NULL); ! //if plugin is also an output plugin, let that call its destroy function if(!(input_list[num_inp - 1].plug->type & OUTPUT_PLUGIN)) { log_write(LOG_DBUG, " unloading %s\n", ! input_list[num_inp - 1].plug->shortname); log_write(LOG_DBUG, " input_list[%d].plug->plugin_destroy();\n", ! num_inp - 1); if((my_err = input_list[num_inp - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded\n"); --- 357,371 ---- assert(input_list[num_inp - 1].plug != NULL); assert(input_list[num_inp - 1].plug->plugin_destroy != NULL); ! // if plugin is also an output plugin, let that call its destroy ! // function if(!(input_list[num_inp - 1].plug->type & OUTPUT_PLUGIN)) { log_write(LOG_DBUG, " unloading %s\n", ! input_list[num_inp - 1].plug->shortname); log_write(LOG_DBUG, " input_list[%d].plug->plugin_destroy();\n", ! num_inp - 1); if((my_err = input_list[num_inp - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded\n"); *************** *** 371,385 **** assert(output_list[num_out - 1].plug->plugin_close != NULL); ! //if plugin is also a network plugin, let that call it destroy function if(!(output_list[num_out - 1].plug->type & NETWORK_PLUGIN)) { log_write(LOG_DBUG, " unloading %s\n", ! output_list[num_out - 1].plug->shortname); log_write(LOG_DBUG, " output_list[%d].plug->plugin_destroy();\n", ! num_out - 1); ! if(output_list[num_out -1].plug->ready) output_list[num_out - 1].plug->plugin_close(); if((my_err = output_list[num_out - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded"); --- 383,398 ---- assert(output_list[num_out - 1].plug->plugin_close != NULL); ! // if plugin is also a network plugin, let that call it destroy ! // function if(!(output_list[num_out - 1].plug->type & NETWORK_PLUGIN)) { log_write(LOG_DBUG, " unloading %s\n", ! output_list[num_out - 1].plug->shortname); log_write(LOG_DBUG, " output_list[%d].plug->plugin_destroy();\n", ! num_out - 1); ! if(output_list[num_out - 1].plug->ready) output_list[num_out - 1].plug->plugin_close(); if((my_err = output_list[num_out - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded"); *************** *** 396,404 **** assert(network_list[num_net - 1].plug->plugin_destroy != NULL); log_write(LOG_DBUG, " unloading %s\n", ! network_list[num_net - 1].plug->shortname); log_write(LOG_DBUG, " network_list[%d].plug->plugin_destroy();\n", ! num_net - 1); if((my_err = network_list[num_net - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded\n"); --- 409,417 ---- assert(network_list[num_net - 1].plug->plugin_destroy != NULL); log_write(LOG_DBUG, " unloading %s\n", ! network_list[num_net - 1].plug->shortname); log_write(LOG_DBUG, " network_list[%d].plug->plugin_destroy();\n", ! num_net - 1); if((my_err = network_list[num_net - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { log_write(LOG_DBUG, " plugin not unloaded\n"); *************** *** 422,426 **** * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! static int plugin_add(int type, plugin_t * p_data, sonar_t * mthis, void *hptr) { if(!plugin_ready()) --- 435,440 ---- * @return PLUGIN_OK if ok, PLUGIN_ERROR otherwise */ ! static int ! plugin_add(int type, plugin_t * p_data, sonar_t * mthis, void *hptr) { if(!plugin_ready()) *************** *** 429,437 **** return PLUGIN_ERROR; } ! ! assert(p_data != NULL); ! assert(mthis != NULL); ! assert(hptr != NULL); ! if(type & INPUT_PLUGIN) { --- 443,451 ---- return PLUGIN_ERROR; } ! ! assert(p_data != NULL); ! assert(mthis != NULL); ! assert(hptr != NULL); ! if(type & INPUT_PLUGIN) { *************** *** 440,445 **** input_list[num_inp].handle = hptr; input_list[num_inp].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " input_list[%d].plug->pluginID = %d\n", num_inp, ! input_list[num_inp].plug->pluginID); num_inp++; if(num_inp > MAX_INP) --- 454,459 ---- input_list[num_inp].handle = hptr; input_list[num_inp].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " input_list[%d].plug->pluginID = %d\n", num_inp, ! input_list[num_inp].plug->pluginID); num_inp++; if(num_inp > MAX_INP) *************** *** 455,460 **** output_list[num_out].handle = hptr; output_list[num_out].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " output_list[%d].plug->pluginID = %d\n", num_out, ! output_list[num_out].plug->pluginID); num_out++; if(num_out > MAX_OUT) --- 469,474 ---- output_list[num_out].handle = hptr; output_list[num_out].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " output_list[%d].plug->pluginID = %d\n", ! num_out, output_list[num_out].plug->pluginID); num_out++; if(num_out > MAX_OUT) *************** *** 470,475 **** network_list[num_net].handle = hptr; network_list[num_net].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " network_list[%d].plug->pluginID = %d\n", num_net, ! network_list[num_net].plug->pluginID); num_net++; if(num_net > MAX_NET) --- 484,489 ---- network_list[num_net].handle = hptr; network_list[num_net].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " network_list[%d].plug->pluginID = %d\n", ! num_net, network_list[num_net].plug->pluginID); num_net++; if(num_net > MAX_NET) *************** *** 495,503 **** * at the status screen */ ! void plugin_status_hook(void) { unsigned int plug; ! //get all input, output, network plugins ! //call the plugin_status function for(plug = 0; plug < num_inp; plug++) --- 509,518 ---- * at the status screen */ ! void ! plugin_status_hook(void) { unsigned int plug; ! // get all input, output, network plugins ! // call the plugin_status function for(plug = 0; plug < num_inp; plug++) *************** *** 540,549 **** * @param ap va_list of arguments */ ! void plugin_message_hook(char *msg, va_list * ap) { unsigned int plug; int err_val = 0; ! //get all output plugins ! //call the plugin_output function for(plug = 0; plug < num_out; plug++) --- 555,565 ---- * @param ap va_list of arguments */ ! void ! plugin_message_hook(char *msg, va_list * ap) { unsigned int plug; int err_val = 0; ! // get all output plugins ! // call the plugin_output function for(plug = 0; plug < num_out; plug++) *************** *** 566,582 **** //@} ! void clear_opts(sonar_options_t *in) { assert(in != NULL); ! memset((void*)in,0,sizeof(sonar_options_t)); ! in->iPostDelay=0; ! in->iHostDelay=0; ! in->iTimeout=5; ! in->iVerbose=1; ! in->bFork=0; ! in->sCommandLine=NULL; ! in->iCount=1; ! in->bRandom=0; ! in->bBroadcast=0; } - --- 582,598 ---- //@} ! void ! clear_opts(sonar_options_t * in) { assert(in != NULL); ! memset((void *) in, 0, sizeof(sonar_options_t)); ! in->iPostDelay = 0; ! in->iHostDelay = 0; ! in->iTimeout = 5; ! in->iVerbose = 1; ! in->bFork = 0; ! in->sCommandLine = NULL; ! in->iCount = 1; ! in->bRandom = 0; ! in->bBroadcast = 0; } Index: service.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/service.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** service.c 28 Feb 2004 12:01:17 -0000 1.5 --- service.c 13 Apr 2004 03:42:08 -0000 1.6 *************** *** 31,119 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! int sonar_resolve_service(char *serv, target_t *target) { ! struct servent *service; ! int num = atoi(serv), port = 0; ! log_write(LOG_DBUG, " looking up \'%s\' service\n", serv); ! setservent(0); ! service = getservbyname(serv, NULL); ! if(!service) // if not, { ! log_write(LOG_DBUG, " service not found by name: %s\n", serv); ! // try by number ! service = getservbyport(htons(num), NULL); ! if(!service) // still not? ! { ! log_write(LOG_DBUG, " service not found by port: %d\n", ! num); ! // see if its in range ! if(num >= 0 && num <= 65535) ! { ! log_write(LOG_DBUG, " setting port #%d\n", ! num); ! target->ports[num] = 1; ! port = num; ! } ! else // nope? error ! { ! err_msg("port out of range, skipping"); ! return 0; ! } - } - else // got it by number - { - log_write(LOG_DBUG, " found service by number: %s\n", - service->s_name); - port = ntohs(service->s_port); - if(port < 0 || port > 65535) - { - err_msg("port out of range, skipping"); - return 0; - } - target->ports[port] = 1; - } } ! else // got it by name { ! log_write(LOG_DBUG, " found service by name. port: %u, name: " ! "%s\n", ! ntohs(service->s_port), service->s_name); ! port = ntohs(service->s_port); ! if(port < 0 || port > 65535) ! { ! err_msg("port out of range, skipping"); ! return 0; ! } ! target->ports[port] = 1; } ! endservent(); ! return port; } ! int sonar_resolve_service_r(char *low, char *high, target_t *result) { ! int i, fin, moyen, ret = 0; ! assert(low != NULL); ! assert(high != NULL); ! moyen = sonar_resolve_service(low, result); ! fin = sonar_resolve_service(high, result); ! if(moyen < 0 || fin < 0) ! { ! err_msg("ports out of range, bailing"); ! return 0; ! } ! // fill in the gaps in the range ! for(i = moyen; i < fin; i++) ! { ! result->ports[i] = 1; ! ret++; ! } ! ret++; ! return ret; } --- 31,118 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! int ! sonar_resolve_service(char *serv, target_t * target) { ! struct servent *service; ! int num = atoi(serv), port = 0; ! log_write(LOG_DBUG, " looking up \'%s\' service\n", serv); ! setservent(0); ! service = getservbyname(serv, NULL); ! if(!service) // if not, ! { ! log_write(LOG_DBUG, " service not found by name: %s\n", serv); ! // try by number ! service = getservbyport(htons(num), NULL); ! if(!service) // still not? { ! log_write(LOG_DBUG, " service not found by port: %d\n", num); ! // see if its in range ! if(num >= 0 && num <= 65535) ! { ! log_write(LOG_DBUG, " setting port #%d\n", num); ! target->ports[num] = 1; ! port = num; ! } ! else // nope? error ! { ! err_msg("port out of range, skipping"); ! return 0; ! } } ! else // got it by number { ! log_write(LOG_DBUG, " found service by number: %s\n", ! service->s_name); ! port = ntohs(service->s_port); ! if(port < 0 || port > 65535) ! { ! err_msg("port out of range, skipping"); ! return 0; ! } ! target->ports[port] = 1; } ! } ! else // got it by name ! { ! log_write(LOG_DBUG, " found service by name. port: %u, name: " ! "%s\n", ntohs(service->s_port), service->s_name); ! port = ntohs(service->s_port); ! if(port < 0 || port > 65535) ! { ! err_msg("port out of range, skipping"); ! return 0; ! } ! target->ports[port] = 1; ! } ! endservent(); ! return port; } ! int ! sonar_resolve_service_r(char *low, char *high, target_t * result) { ! int i, fin, moyen, ret = 0; ! assert(low != NULL); ! assert(high != NULL); ! moyen = sonar_resolve_service(low, result); ! fin = sonar_resolve_service(high, result); ! if(moyen < 0 || fin < 0) ! { ! err_msg("ports out of range, bailing"); ! return 0; ! } ! // fill in the gaps in the range ! for(i = moyen; i < fin; i++) ! { ! result->ports[i] = 1; ! ret++; ! } ! ret++; ! return ret; } Index: sonar.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/sonar.c,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** sonar.c 11 Apr 2004 02:20:48 -0000 1.43 --- sonar.c 13 Apr 2004 03:42:08 -0000 1.44 *************** *** 45,49 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; //these are contained in plugin.c --- 45,49 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; [...1228 lines suppressed...] ! assert(network_list[plug].plug != NULL); ! assert(network_list[plug].plug->plugin_sweep != NULL); ! } ! // only run this sweep if the plugin is ready ! if(network_list[plug].plug->ready == true ! && network_list[plug].plug->selected == true) ! { ! status = network_list[plug].plug->plugin_sweep(targets); #ifdef DEBUG ! err_msg("network_list[%d].plug->plugin_sweep(%p); => %d", plug, ! targets, status); #endif ! /* XXX: add some sort of error reporting here */ } ! if(status != PLUGIN_OK) ! return status; ! } ! return SONAR_OK; } Index: mutex.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/mutex.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mutex.h 14 May 2003 06:23:03 -0000 1.1 --- mutex.h 13 Apr 2004 03:42:08 -0000 1.2 *************** *** 26,32 **** typedef struct { ! pthread_mutex_t mutex; ! char id[80]; ! char *locked_by; } sonar_mutex_t; --- 26,32 ---- typedef struct { ! pthread_mutex_t mutex; ! char id[80]; ! char *locked_by; } sonar_mutex_t; Index: types.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/types.h,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** types.h 28 Apr 2003 23:11:32 -0000 1.20 --- types.h 13 Apr 2004 03:42:08 -0000 1.21 *************** *** 28,36 **** #ifndef __USE_BSD ! #define __USE_BSD //for portability #endif #ifndef __FAVOR_BSD ! #define __FAVOR_BSD //for portability #endif --- 28,36 ---- #ifndef __USE_BSD ! #define __USE_BSD // for portability #endif #ifndef __FAVOR_BSD ! #define __FAVOR_BSD // for portability #endif *************** *** 61,65 **** #ifdef HAVE_SYS_TIME_H #include <sys/time.h> ! #endif //HAVE_SYS_TIME_H #include <time.h> #else --- 61,65 ---- #ifdef HAVE_SYS_TIME_H #include <sys/time.h> ! #endif // HAVE_SYS_TIME_H #include <time.h> #else *************** *** 67,75 **** #ifdef HAVE_SYS_TIME_H #include <sys/time.h> ! #endif //HAVE_SYS_TIME_H #else #include <time.h> ! #endif //TM_IN_SYS_TIME ! #endif //TIME_WITH_SYS_TIME /** --- 67,75 ---- #ifdef HAVE_SYS_TIME_H #include <sys/time.h> ! #endif // HAVE_SYS_TIME_H #else #include <time.h> ! #endif // TM_IN_SYS_TIME ! #endif // TIME_WITH_SYS_TIME /** *************** *** 81,91 **** { /** Socket Family */ ! unsigned short family, /** Destination Port */ ! dport; /** IP Address */ ! unsigned int addr; /** Padding (zeros) */ ! unsigned char zero[8]; }; --- 81,91 ---- { /** Socket Family */ ! unsigned short family, /** Destination Port */ ! dport; /** IP Address */ ! unsigned int addr; /** Padding (zeros) */ ! unsigned char zero[8]; }; Index: util.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/util.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** util.c 8 Apr 2004 21:09:40 -0000 1.28 --- util.c 13 Apr 2004 03:42:08 -0000 1.29 *************** *** 42,46 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /** --- 42,46 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /** *************** *** 49,55 **** * @param err Error to report */ ! void sonar_usage(const char *err) { ! sonar_opt_usage(-1, "error", (char *) err); } --- 49,56 ---- * @param err Error to report */ ! void ! sonar_usage(const char *err) { ! sonar_opt_usage(-1, "error", (char *) err); } *************** *** 62,70 **** * @todo Deprecate using this */ ! void bput(char **dest, const char *src, const int len) { ! *dest = (char *) Malloc(len + 2); ! memset(*dest, 0, len + 2); ! strncpy(*dest, src, len); // return dest; } --- 63,72 ---- * @todo Deprecate using this */ ! void ! bput(char **dest, const char *src, const int len) { ! *dest = (char *) Malloc(len + 2); ! memset(*dest, 0, len + 2); ! strncpy(*dest, src, len); // return dest; } *************** *** 77,95 **** * @param out Double pointer to destination */ ! void sonar_commandline(char *argv[], int argc, char **out) { ! int i, len = 0; ! for(i = 0; i < argc; i++) ! len += strlen(argv[i]) + 1; ! *out = (char *) Malloc(len + 2); ! memset(*out, 0, len + 2); ! for(i = 0; i < argc; i++) ! { ! strncat(*out, argv[i], strlen(argv[i])); ! strcat(*out, " "); ! } } --- 79,98 ---- * @param out Double pointer to destination */ ! void ! sonar_commandline(char *argv[], int argc, char **out) { ! int i, len = 0; ! for(i = 0; i < argc; i++) ! len += strlen(argv[i]) + 1; ! *out = (char *) Malloc(len + 2); ! memset(*out, 0, len + 2); ! for(i = 0; i < argc; i++) ! { ! strncat(*out, argv[i], strlen(argv[i])); ! strcat(*out, " "); ! } } *************** *** 100,236 **** * @param msg Format specifier like printf */ ! void sonar_msg(char *msg, ...) { ! va_list ap; ! char *buf; ! ! va_start(ap, msg); ! buf = (char *) Malloc(128); ! memset(buf, 0, 128); ! va_start(ap, msg); ! vsnprintf(buf, 127, msg, ap); ! ! if(mthis.opts.bFork) ! log_write(LOG_PLUGINS | LOG_SLOG, buf); ! else ! log_write(LOG_PLUGINS | LOG_CONSOLE, buf); ! free(buf); ! va_end(ap); } ! RETSIGTYPE sig_int(int i) { ! switch(i) ! { ! case SIGINT: ! err_msg("caught SIGINT, cleaning up..\n"); ! break; ! case SIGTERM: ! err_msg("caught SIGTERM, cleaning up..\n"); ! break; ! case SIGHUP: ! err_msg("caught SIGHUP, restarting..\n"); ! sonar_sweep(); ! break; ! case SIGSEGV: ! err_msg("oops! sonar segmentation fault.\n"); ! /*plugin_killall();*/ ! abort(); ! break; ! } ! /*plugin_killall();*/ ! ! exit(0); } ! struct stat *get_stats(const char *file) { ! struct stat *buf; ! char *path = NULL, *token, *str, cwd[PATH_MAX]; ! assert(file != NULL); ! buf = (struct stat *) Malloc(sizeof(struct stat)); ! ! log_write(LOG_DBUG, " get_stats: checking for %s\n", file); ! // if we have the full path ! if(stat(file, buf) == 0) ! return buf; ! log_write(LOG_DBUG, " get_stats: not found, checking in $PATH\n"); ! path = getenv("PATH"); ! // check in the paths ! if(path) ! { ! log_write(LOG_DBUG, " get_stats: $PATH=\"%s\"\n", path); ! token = strtok(path, ":"); ! while(token != NULL) ! { ! // check this location for file ! int tok = strlen(token); ! int pth = strlen(file); ! int len = tok + pth + 2; ! str = (char *) Malloc(len); ! memset(str, 0, len); ! // build the path name ! strncpy(str, token, tok); ! strncat(str, "/", 1); ! strncat(str, file, pth); ! log_write(LOG_DBUG, " get_stats: trying %s\n", str); ! ! // try to stat ! if(stat(str, buf) == 0) ! return buf; ! // not found, clear the mem ! memset(str, 0, len); ! // free the mem ! free(str); ! // next token ! token = strtok(NULL, ":"); ! } ! } ! // not found in path? check current working dir ! memset(cwd, 0, PATH_MAX); ! getcwd(cwd, PATH_MAX - 1); ! log_write(LOG_DBUG, " get_stats: trying cwd\n"); ! // we can get the cwd ! if(cwd) { ! // check here for file ! int pth = strlen(file); ! int lcw = strlen(cwd); ! int len = pth + lcw + 2; ! str = (char *) Malloc(len); ! memset(str, 0, len); ! // build the path name ! strncpy(str, cwd, lcw); ! strncat(str, "/", 1); ! strncat(str, file, pth); ! log_write(LOG_DBUG, " get_stats: trying %s\n", str); ! // try to stat ! if(stat(str, buf) == 0) ! return buf; ! // not found, clear mem ! memset(str, 0, len); ! // free ! free(str); } ! log_write(LOG_DBUG, " could not find/stat %s\n", file); ! return NULL; } ! RETSIGTYPE sig_chld(int sig) { ! pid_t pid; ! int stat; ! ! pid = wait(&stat); #if RETSIGTYPE == void ! return; #else ! return (0); #endif } --- 103,243 ---- * @param msg Format specifier like printf */ ! void ! sonar_msg(char *msg, ...) { ! va_list ap; ! char *buf; ! ! va_start(ap, msg); ! buf = (char *) Malloc(128); ! memset(buf, 0, 128); ! va_start(ap, msg); ! vsnprintf(buf, 127, msg, ap); ! ! if(mthis.opts.bFork) ! log_write(LOG_PLUGINS | LOG_SLOG, buf); ! else ! log_write(LOG_PLUGINS | LOG_CONSOLE, buf); ! free(buf); ! va_end(ap); } ! RETSIGTYPE ! sig_int(int i) { ! switch (i) ! { ! case SIGINT: ! err_msg("caught SIGINT, cleaning up..\n"); ! break; ! case SIGTERM: ! err_msg("caught SIGTERM, cleaning up..\n"); ! break; ! case SIGHUP: ! err_msg("caught SIGHUP, restarting..\n"); ! sonar_sweep(); ! break; ! case SIGSEGV: ! err_msg("oops! sonar segmentation fault.\n"); ! /* plugin_killall(); */ ! abort(); ! break; ! } ! /* plugin_killall(); */ ! ! exit(0); } ! struct stat * ! get_stats(const char *file) { ! struct stat *buf; ! char *path = NULL, *token, *str, cwd[PATH_MAX]; ! assert(file != NULL); ! buf = (struct stat *) Malloc(sizeof(struct stat)); ! log_write(LOG_DBUG, " get_stats: checking for %s\n", file); ! // if we have the full path ! if(stat(file, buf) == 0) ! return buf; ! log_write(LOG_DBUG, " get_stats: not found, checking in $PATH\n"); ! path = getenv("PATH"); ! // check in the paths ! if(path) ... [truncated message content] |
Update of /cvsroot/autosec/sonar/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24331/plugins Modified Files: error.c inp_rand.c log_file.c log_file.h log_xml.c log_xml.h network_icmp.c network_icmp.h rfc793.c rfc793.h Log Message: Massive code 'indent' Index: rfc793.h =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.h,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** rfc793.h 31 Mar 2004 11:53:20 -0000 1.29 --- rfc793.h 13 Apr 2004 03:42:07 -0000 1.30 *************** *** 35,43 **** #ifndef ICMP_DEST_UNREACH ! #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ #endif #ifndef ICMP_PORT_UNREACH ! #define ICMP_PORT_UNREACH 3 /* Port Unreachable */ #endif --- 35,43 ---- #ifndef ICMP_DEST_UNREACH ! #define ICMP_DEST_UNREACH 3 /* Destination Unreachable */ #endif #ifndef ICMP_PORT_UNREACH ! #define ICMP_PORT_UNREACH 3 /* Port Unreachable */ #endif *************** *** 120,141 **** struct tcp_timestamp { ! uint8_t kind; /* TCPOPT_TIMESTAMP */ ! uint8_t len; /* 10 */ ! uint32_t tsval; /* my timestamp */ ! uint32_t tsecho; /* server's timestamp */ }; struct recv_t { ! /// socket to listen on (must already be open) int socket, errs; ! /// number of hosts and ports we pinged uint32_t hosts; ! uint32_t ports; ! /// set the number of responses uint32_t responses; ! /// start time clock_t start; ! /// max wait time (timeout function) clock_t max; }; --- 120,141 ---- struct tcp_timestamp { ! uint8_t kind; /* TCPOPT_TIMESTAMP */ ! uint8_t len; /* 10 */ ! uint32_t tsval; /* my timestamp */ ! uint32_t tsecho; /* server's timestamp */ }; struct recv_t { ! // / socket to listen on (must already be open) int socket, errs; ! // / number of hosts and ports we pinged uint32_t hosts; ! uint32_t ports; ! // / set the number of responses uint32_t responses; ! // / start time clock_t start; ! // / max wait time (timeout function) clock_t max; }; *************** *** 155,157 **** ! #endif //_RFC793_H_ --- 155,157 ---- ! #endif // _RFC793_H_ Index: inp_rand.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/inp_rand.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** inp_rand.c 8 Apr 2004 19:11:02 -0000 1.10 --- inp_rand.c 13 Apr 2004 03:42:07 -0000 1.11 *************** *** 24,29 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! /// Plugin's plugin_t structure, built by plugin_init static plugin_t pthis; --- 24,29 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; ! /// Plugin's plugin_t structure, built by plugin_init static plugin_t pthis; *************** *** 36,40 **** static char my_hostname[BUF_SIZE]; static unsigned int num_hosts; ! static int plugin_destroy(void); static int plugin_open(void *c_data, int i_data); --- 36,40 ---- static char my_hostname[BUF_SIZE]; static unsigned int num_hosts; ! static int plugin_destroy(void); static int plugin_open(void *c_data, int i_data); *************** *** 45,222 **** static void plugin_status(void); static unsigned int get_random(void); ! ! void *plugin_init(void *in_data) { ! assert(in_data != NULL); ! //useless reference, to avoid a warning ! if(rcsid); ! ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! { ! fprintf(stderr, "Plugin API must be 6 or higher, update sonar or downgrade this plugin\n"); ! } ! pthis.type = INPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.selected = false; ! pthis.version = 6; /* set API version 5 */ ! pthis.plugin_char = 'R'; ! pthis.shortname = "random"; ! pthis.longname = "Random Input Plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = &plugin_next; ! // this is not needed for net plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! ! srand((unsigned int ) time(NULL) ^ (unsigned int) &mthis); ! ! memset(my_hostname, 0, BUF_SIZE); ! /* default to one host */ ! num_hosts = 1; ! return &pthis; ! } ! static int plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! ! memset(my_hostname, 0, 16); ! return my_errno; } ! static int plugin_open(void *c_data, int i_data) { ! /* return the buffer size */ ! if(c_data) ! { #ifdef DEBUG ! printf("opts: \'%s\'\n", c_data); #endif ! num_hosts = atoi(c_data); ! if(num_hosts <= 0) ! num_hosts = 1; ! } ! pthis.ready = true; ! return BUF_SIZE -1; } ! static int plugin_close(void) { ! memset(my_hostname, 0, BUF_SIZE); ! return PLUGIN_OK; } ! static int plugin_next(char *hostname) { ! static unsigned int returned = 0; ! static char *myname; ! char myport[PORT_SIZE]; ! unsigned long int addr, len; ! unsigned int port; ! struct in_addr ia; ! ! assert(hostname != NULL); ! ! if(returned >= num_hosts) ! return PLUGIN_ERROR; ! returned++; ! ! memset(myport, 0, PORT_SIZE); ! addr = (unsigned long int) get_random(); ! port = get_random() % 65535; ! snprintf(myport, PORT_SIZE, "%u", port); ! ! ia.s_addr = addr; ! myname = inet_ntoa(ia); ! ! len = strlen(myname); ! memcpy(hostname, myname, len); ! strncat(hostname, ":", 1); ! strncat(hostname, myport, strlen(myport)); ! if(mthis->opts.iVerbose > 0) ! mthis->message("Scanning %s\n", hostname); ! ! return PLUGIN_OK; } ! static void plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("random input loaded::(%d)\n", num_hosts); } ! static unsigned int get_random(void) { ! FILE *fp; ! unsigned int ret; ! if((fp = fopen("/dev/urandom", "r")) != NULL) ! { ! if((fread(&ret, sizeof(unsigned int), 1, fp)) == 1) ! { ! fclose(fp); ! return ret; ! } ! } ! if((fp = fopen("/dev/random", "r")) != NULL) ! { ! if(fread(&ret, sizeof(unsigned int), 1, fp) == 1) ! { ! fclose(fp); ! return ret; ! } ! } ! srand((unsigned int) clock()); ! ret = 0x1008 + (unsigned int) (0xfffe * rand() / (RAND_MAX + 1.0)); ! return ret; } ! static void plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n Random input plugin\n"); ! mthis->output( ! " Usage: -iR,[number]\n"); ! mthis->output( ! "\t number: number of hostnames to return\n"); } ! static int plugin_last_error(void) { ! return my_errno; } --- 45,230 ---- static void plugin_status(void); static unsigned int get_random(void); ! ! void * ! plugin_init(void *in_data) { ! assert(in_data != NULL); ! // useless reference, to avoid a warning ! if(rcsid) ; ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! { ! fprintf(stderr, ! "Plugin API must be 6 or higher, update sonar or downgrade this plugin\n"); ! } ! pthis.type = INPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.selected = false; ! pthis.version = 6; /* set API version 5 */ ! pthis.plugin_char = 'R'; ! pthis.shortname = "random"; ! pthis.longname = "Random Input Plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = &plugin_next; ! // this is not needed for net plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! srand((unsigned int) time(NULL) ^ (unsigned int) &mthis); ! ! memset(my_hostname, 0, BUF_SIZE); ! /* default to one host */ ! num_hosts = 1; ! ! return &pthis; ! } ! ! static int ! plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! ! memset(my_hostname, 0, 16); ! return my_errno; } ! static int ! plugin_open(void *c_data, int i_data) { ! /* return the buffer size */ ! if(c_data) ! { #ifdef DEBUG ! printf("opts: \'%s\'\n", c_data); #endif ! num_hosts = atoi(c_data); ! if(num_hosts <= 0) ! num_hosts = 1; ! } ! pthis.ready = true; ! return BUF_SIZE - 1; } ! static int ! plugin_close(void) { ! memset(my_hostname, 0, BUF_SIZE); ! return PLUGIN_OK; } ! static int ! plugin_next(char *hostname) { ! static unsigned int returned = 0; ! static char *myname; ! char myport[PORT_SIZE]; ! unsigned long int addr, len; ! unsigned int port; ! struct in_addr ia; ! ! assert(hostname != NULL); ! ! if(returned >= num_hosts) ! return PLUGIN_ERROR; ! returned++; ! ! memset(myport, 0, PORT_SIZE); ! addr = (unsigned long int) get_random(); ! port = get_random() % 65535; ! snprintf(myport, PORT_SIZE, "%u", port); ! ! ia.s_addr = addr; ! myname = inet_ntoa(ia); ! ! len = strlen(myname); ! memcpy(hostname, myname, len); ! strncat(hostname, ":", 1); ! strncat(hostname, myport, strlen(myport)); ! if(mthis->opts.iVerbose > 0) ! mthis->message("Scanning %s\n", hostname); ! ! return PLUGIN_OK; } ! static void ! plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("random input loaded::(%d)\n", num_hosts); } ! static unsigned int ! get_random(void) { ! FILE *fp; ! unsigned int ret; ! if((fp = fopen("/dev/urandom", "r")) != NULL) ! { ! if((fread(&ret, sizeof(unsigned int), 1, fp)) == 1) ! { ! fclose(fp); ! return ret; ! } ! } ! if((fp = fopen("/dev/random", "r")) != NULL) ! { ! if(fread(&ret, sizeof(unsigned int), 1, fp) == 1) ! { ! fclose(fp); ! return ret; ! } ! } ! srand((unsigned int) clock()); ! ret = 0x1008 + (unsigned int) (0xfffe * rand() / (RAND_MAX + 1.0)); ! return ret; } ! static void ! plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n Random input plugin\n"); ! mthis->output(" Usage: -iR,[number]\n"); ! mthis->output("\t number: number of hostnames to return\n"); } ! static int ! plugin_last_error(void) { ! return my_errno; } Index: network_icmp.h =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/network_icmp.h,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** network_icmp.h 30 Mar 2004 22:04:24 -0000 1.33 --- network_icmp.h 13 Apr 2004 03:42:07 -0000 1.34 *************** *** 82,105 **** struct recv_t { ! /// socket to listen on (must already be open) ! int socket; ! /// number of hosts we pinged ! unsigned int hosts; ! /// set the number of responses ! unsigned int responses; ! /// start time ! unsigned int start; ! /// max wait time (timeout function) ! unsigned int max; }; typedef struct icmp_options_s { ! uint8_t ttl; ! uint8_t debug; ! uint32_t size; ! }icmp_options_t; void *plugin_init(void *in_data); ! #endif //_ICMP_PLUG_H_ --- 82,105 ---- struct recv_t { ! // / socket to listen on (must already be open) ! int socket; ! // / number of hosts we pinged ! unsigned int hosts; ! // / set the number of responses ! unsigned int responses; ! // / start time ! unsigned int start; ! // / max wait time (timeout function) ! unsigned int max; }; typedef struct icmp_options_s { ! uint8_t ttl; ! uint8_t debug; ! uint32_t size; ! } icmp_options_t; void *plugin_init(void *in_data); ! #endif // _ICMP_PLUG_H_ Index: log_xml.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/log_xml.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** log_xml.c 8 Apr 2004 23:28:16 -0000 1.11 --- log_xml.c 13 Apr 2004 03:42:07 -0000 1.12 *************** *** 25,29 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /// Plugin's plugin_t structure, built by plugin_init --- 25,29 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /// Plugin's plugin_t structure, built by plugin_init *************** *** 43,47 **** static int plugin_close(void); static int plugin_output(char *msg, va_list * ap); ! static int plugin_results(target_t *result, unsigned int num); static void plugin_usage(void); static void plugin_status(void); --- 43,47 ---- static int plugin_close(void); static int plugin_output(char *msg, va_list * ap); ! static int plugin_results(target_t * result, unsigned int num); static void plugin_usage(void); static void plugin_status(void); *************** *** 56,374 **** */ ! void *plugin_init(void *in_data) { ! assert(in_data != NULL); ! //useless reference, to avoid a warning ! if(rcsid); ! ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! err_quit("Plugin API must be 6 or higher, update sonar"); ! pthis.type = OUTPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.version = 6; /* set API version 6 */ ! pthis.plugin_char = 'X'; ! pthis.shortname = "xml"; ! pthis.longname = "XML Log File output plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = NULL; ! // this is not needed for I/O plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = &plugin_output; ! pthis.plugin_results = &plugin_results; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! my_file = NULL; ! my_fp = NULL; ! return &pthis; } ! static int plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! my_file = NULL; ! my_fp = NULL; ! return PLUGIN_UNLOADED; } ! static int plugin_open(void *c_data, int i_data) { ! char *file_opts; // pointer to additional opts after filename ! char *append_or_overwrite = NULL; // indicates append or overwrite option ! int filename_len = i_data; // set length assuming no further options - - pthis.selected = true; // we were selected, whether the right arguments are present or not ! if (!c_data || i_data == 0) ! return PLUGIN_NOFILE; ! file_opts = strchr(c_data, ','); ! if (file_opts != NULL) ! { ! *file_opts++ = 0; // NULL delimit previous string, and advance ! // ! // if there was a comma, then don't include the comma and the ! // characters after it as part of the filename ! // ! filename_len = strlen(c_data); ! // ! // if an 'a' is found, then set the appropriate char option for fopen ! // other options may be filtered out with further if statements ! // ! if (*file_opts == 'a') ! append_or_overwrite = strdup("a"); ! else ! append_or_overwrite = strdup("w+"); ! } ! else ! append_or_overwrite = strdup("w+"); ! // check to see if my_file points to prev allocated data? ! my_file = strndup(c_data, filename_len); #ifdef DEBUG ! printf("fopen(\"%s\", \"%s\");\n", my_file, append_or_overwrite); #endif ! my_fp = fopen(my_file, append_or_overwrite); ! free(append_or_overwrite); ! if(my_fp == NULL) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("Could not open file"); ! pthis.ready = false; ! return PLUGIN_NOFILE; ! } ! pthis.ready = true; ! return PLUGIN_OK; } ! static int plugin_close(void) { ! fprintf(my_fp, "</sonar-scan>\n"); ! fclose(my_fp); ! free(my_file); ! return PLUGIN_OK; } ! static int plugin_output(char *msg, va_list * ap) { ! struct tm *tm; ! char buf[60]; ! time_t now; ! int tries = 0; ! ! /* sanity checks */ ! if(!pthis.ready) ! { ! *(pthis.err) = PLUGIN_NOPEN; ! err_msg("output plugin not ready"); ! return PLUGIN_NOPEN; ! } ! while(!my_fp && tries < 3) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("output plugin not ready, retrying"); ! my_fp = fopen(my_file, "a"); /* reopen it instead of dying */ ! /*return PLUGIN_NOFILE;*/ ! tries++; ! } ! if(!my_fp) ! return PLUGIN_NOFILE; /* we tried */ ! if(!header) ! { ! now = time(NULL); ! if (!(tm = localtime(&now))) ! err_sys("could not get localtime\n"); ! if (strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M %Z", tm) <= 0) ! err_sys("Could not format localtime\n"); ! fprintf(my_fp, "<?xml version=\"1.0\" ?>\n"); ! fprintf(my_fp, "<!-- %s %s initiated at %s as %s -->\n", PACKAGE, VERSION, buf, mthis->opts.sCommandLine); ! fprintf(my_fp, "<sonar-scan>\n"); ! header++; ! } ! fprintf(my_fp, "<!-- "); ! vfprintf(my_fp, msg, *ap); ! fprintf(my_fp, " -->\n"); ! return PLUGIN_OK; } ! static int null_result(target_t *result) { ! /* as of right now, there is no way to report dead hosts */ ! fprintf(my_fp, ! "\t<deadhost hostname=\"unreported-in-this-version\" />\n"); ! return PLUGIN_OK; } ! static int plugin_results(target_t *result, unsigned int num_hosts) { ! struct sockaddr_in *sa = NULL; ! struct sockaddr_in6 *sa6 = NULL; ! char ip6sa_format[] = "%x%x%x%x:%x%x%x%x:%x%x%x%x:%x%x%x%x\0"; ! char buf[256]; ! /*struct sockaddr_un *un;*/ ! ! int i, j; ! ! for(j = 0; j< num_hosts; j++) ! { ! assert(result != NULL); ! if(result->addrinfo == NULL) ! { ! null_result(result); ! continue; ! } ! ! memset(buf, 0, 256); ! fprintf(my_fp, ! "\t<host hostname=\"%s\" rtt=\"%0.2f\"" ! "ttl=\"%d\" mask=\"%d\"", ! result->addrinfo->ai_canonname, ! result->stats.rtt_avg, result->stats.ttl, ! result->netmask); ! switch(result->addrinfo->ai_family) ! { ! case PF_INET: ! sa = (struct sockaddr_in*) ! result->addrinfo->ai_addr; ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! inet_ntoa(sa->sin_addr), "ipv4"); ! break; ! case PF_INET6: ! sa6 = (struct sockaddr_in6 *) ! result->addrinfo->ai_addr; ! snprintf(buf, 255, ip6sa_format, ! sa6->sin6_addr.s6_addr[0], ! sa6->sin6_addr.s6_addr[1], ! sa6->sin6_addr.s6_addr[2], ! sa6->sin6_addr.s6_addr[3], ! sa6->sin6_addr.s6_addr[4], ! sa6->sin6_addr.s6_addr[5], ! sa6->sin6_addr.s6_addr[6], ! sa6->sin6_addr.s6_addr[7], ! sa6->sin6_addr.s6_addr[8], ! sa6->sin6_addr.s6_addr[9], ! sa6->sin6_addr.s6_addr[10], ! sa6->sin6_addr.s6_addr[11], ! sa6->sin6_addr.s6_addr[12], ! sa6->sin6_addr.s6_addr[13], ! sa6->sin6_addr.s6_addr[14], ! sa6->sin6_addr.s6_addr[15]); ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! buf, "ipv6"); ! break; ! /*case PF_UNIX: ! un = (struct sockaddr_un*) ! result->ainfo->ai_addr; ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! un->sun_path, "unix"); ! break;*/ ! default: ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! "unknown-type", "unknown"); ! }; ! ! /* print the port info */ ! for(i =0; i < 65536; i++) ! { ! switch(result->ports[i]) ! { ! case PORT_OPENED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"open\"/>\n", i); ! break; ! case PORT_CLOSED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"closed\"/>\n", i); ! break; ! case PORT_FILTERED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"filtered\"/>\n", i); ! break; ! case PORT_UNFILTERED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"unfiltered\"/>\n", i); ! break; ! } ! } ! fprintf(my_fp, ! "\t\t<stats sent=\"%d\" recvd=\"%d\" dropped=\"%d\" ", ! result->stats.packets_sent, result->stats.packets_recvd, ! result->stats.packets_sent ! - result->stats.packets_recvd); ! fprintf(my_fp, ! " rtt_min=\"%.2f\" rtt_max=\"%.2f\" rtt_avg=\"%.2f\" " ! "/>\n", result->stats.rtt_min, result->stats.rtt_max, ! result->stats.rtt_avg); ! fprintf(my_fp, "\t</host>\n"); ! fflush(my_fp); ! result = result->next; ! } ! return PLUGIN_OK; } ! static void plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n XML output plugin\n"); ! mthis->output(" Usage: -oX,<filename>,[o/a]\n"); ! mthis->output(" [o/a]: either 'o' or 'a', for overwrite, or append\n"); ! mthis->output(" overwrite is default\n"); ! /*exit(-1);*/ } ! static void plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("standard XML output loaded::(%s)\n", ! my_file); } ! static int plugin_last_error(void) { ! return my_errno; } --- 56,374 ---- */ ! void * ! plugin_init(void *in_data) { ! assert(in_data != NULL); ! // useless reference, to avoid a warning ! if(rcsid) ; ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! err_quit("Plugin API must be 6 or higher, update sonar"); ! pthis.type = OUTPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.version = 6; /* set API version 6 */ ! pthis.plugin_char = 'X'; ! pthis.shortname = "xml"; ! pthis.longname = "XML Log File output plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = NULL; ! // this is not needed for I/O plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = &plugin_output; ! pthis.plugin_results = &plugin_results; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! my_file = NULL; ! my_fp = NULL; ! ! return &pthis; } ! static int ! plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! my_file = NULL; ! my_fp = NULL; ! return PLUGIN_UNLOADED; } ! static int ! plugin_open(void *c_data, int i_data) { ! char *file_opts; // pointer to additional opts after filename ! char *append_or_overwrite = NULL; // indicates append or overwrite ! // option ! int filename_len = i_data; // set length assuming no further options ! pthis.selected = true; // we were selected, whether the right ! // arguments are present or not ! if(!c_data || i_data == 0) ! return PLUGIN_NOFILE; ! file_opts = strchr(c_data, ','); ! if(file_opts != NULL) ! { ! *file_opts++ = 0; // NULL delimit previous string, and advance ! // ! // if there was a comma, then don't include the comma and the ! // characters after it as part of the filename ! // ! filename_len = strlen(c_data); ! // ! // if an 'a' is found, then set the appropriate char option for fopen ! // other options may be filtered out with further if statements ! // ! if(*file_opts == 'a') ! append_or_overwrite = strdup("a"); ! else ! append_or_overwrite = strdup("w+"); ! } ! else ! append_or_overwrite = strdup("w+"); ! ! // check to see if my_file points to prev allocated data? ! my_file = strndup(c_data, filename_len); #ifdef DEBUG ! printf("fopen(\"%s\", \"%s\");\n", my_file, append_or_overwrite); #endif ! my_fp = fopen(my_file, append_or_overwrite); ! free(append_or_overwrite); ! if(my_fp == NULL) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("Could not open file"); ! pthis.ready = false; ! return PLUGIN_NOFILE; ! } ! pthis.ready = true; ! return PLUGIN_OK; } ! static int ! plugin_close(void) { ! fprintf(my_fp, "</sonar-scan>\n"); ! fclose(my_fp); ! free(my_file); ! return PLUGIN_OK; } ! static int ! plugin_output(char *msg, va_list * ap) { ! struct tm *tm; ! char buf[60]; ! time_t now; ! int tries = 0; ! ! /* sanity checks */ ! if(!pthis.ready) ! { ! *(pthis.err) = PLUGIN_NOPEN; ! err_msg("output plugin not ready"); ! return PLUGIN_NOPEN; ! } ! while(!my_fp && tries < 3) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("output plugin not ready, retrying"); ! my_fp = fopen(my_file, "a"); /* reopen it instead of dying */ ! /* return PLUGIN_NOFILE; */ ! tries++; ! } ! if(!my_fp) ! return PLUGIN_NOFILE; /* we tried */ ! if(!header) ! { ! now = time(NULL); ! if(!(tm = localtime(&now))) ! err_sys("could not get localtime\n"); ! if(strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M %Z", tm) <= 0) ! err_sys("Could not format localtime\n"); ! fprintf(my_fp, "<?xml version=\"1.0\" ?>\n"); ! fprintf(my_fp, "<!-- %s %s initiated at %s as %s -->\n", PACKAGE, ! VERSION, buf, mthis->opts.sCommandLine); ! fprintf(my_fp, "<sonar-scan>\n"); ! header++; ! } ! fprintf(my_fp, "<!-- "); ! vfprintf(my_fp, msg, *ap); ! fprintf(my_fp, " -->\n"); ! return PLUGIN_OK; } ! static int ! null_result(target_t * result) { ! /* as of right now, there is no way to report dead hosts */ ! fprintf(my_fp, ! "\t<deadhost hostname=\"unreported-in-this-version\" />\n"); ! return PLUGIN_OK; } ! static int ! plugin_results(target_t * result, unsigned int num_hosts) { ! struct sockaddr_in *sa = NULL; ! struct sockaddr_in6 *sa6 = NULL; ! char ip6sa_format[] = "%x%x%x%x:%x%x%x%x:%x%x%x%x:%x%x%x%x\0"; ! char buf[256]; ! /* struct sockaddr_un *un; */ ! ! int i, j; ! ! for(j = 0; j < num_hosts; j++) ! { ! assert(result != NULL); ! if(result->addrinfo == NULL) ! { ! null_result(result); ! continue; ! } ! ! memset(buf, 0, 256); ! fprintf(my_fp, ! "\t<host hostname=\"%s\" rtt=\"%0.2f\"" ! "ttl=\"%d\" mask=\"%d\"", ! result->addrinfo->ai_canonname, ! result->stats.rtt_avg, result->stats.ttl, result->netmask); ! switch (result->addrinfo->ai_family) ! { ! case PF_INET: ! sa = (struct sockaddr_in *) result->addrinfo->ai_addr; ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! inet_ntoa(sa->sin_addr), "ipv4"); ! break; ! case PF_INET6: ! sa6 = (struct sockaddr_in6 *) result->addrinfo->ai_addr; ! snprintf(buf, 255, ip6sa_format, ! sa6->sin6_addr.s6_addr[0], ! sa6->sin6_addr.s6_addr[1], ! sa6->sin6_addr.s6_addr[2], ! sa6->sin6_addr.s6_addr[3], ! sa6->sin6_addr.s6_addr[4], ! sa6->sin6_addr.s6_addr[5], ! sa6->sin6_addr.s6_addr[6], ! sa6->sin6_addr.s6_addr[7], ! sa6->sin6_addr.s6_addr[8], ! sa6->sin6_addr.s6_addr[9], ! sa6->sin6_addr.s6_addr[10], ! sa6->sin6_addr.s6_addr[11], ! sa6->sin6_addr.s6_addr[12], ! sa6->sin6_addr.s6_addr[13], ! sa6->sin6_addr.s6_addr[14], sa6->sin6_addr.s6_addr[15]); ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", buf, "ipv6"); ! break; ! /* case PF_UNIX: un = (struct sockaddr_un*) ! * result->ainfo->ai_addr; fprintf(my_fp, " address=\"%s\" ! * addr-type=\"%s\">\n", un->sun_path, "unix"); break; */ ! default: ! fprintf(my_fp, ! " address=\"%s\" addr-type=\"%s\">\n", ! "unknown-type", "unknown"); ! }; ! ! /* print the port info */ ! for(i = 0; i < 65536; i++) ! { ! switch (result->ports[i]) ! { ! case PORT_OPENED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " "state=\"open\"/>\n", i); ! break; ! case PORT_CLOSED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " "state=\"closed\"/>\n", i); ! break; ! case PORT_FILTERED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"filtered\"/>\n", i); ! break; ! case PORT_UNFILTERED: ! fprintf(my_fp, ! "\t\t<port number=\"%d\" " ! "state=\"unfiltered\"/>\n", i); ! break; ! } ! } ! fprintf(my_fp, ! "\t\t<stats sent=\"%d\" recvd=\"%d\" dropped=\"%d\" ", ! result->stats.packets_sent, result->stats.packets_recvd, ! result->stats.packets_sent - result->stats.packets_recvd); ! fprintf(my_fp, ! " rtt_min=\"%.2f\" rtt_max=\"%.2f\" rtt_avg=\"%.2f\" " ! "/>\n", result->stats.rtt_min, result->stats.rtt_max, ! result->stats.rtt_avg); ! fprintf(my_fp, "\t</host>\n"); ! fflush(my_fp); ! result = result->next; ! } ! return PLUGIN_OK; } ! static void ! plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n XML output plugin\n"); ! mthis->output(" Usage: -oX,<filename>,[o/a]\n"); ! mthis->output(" [o/a]: either 'o' or 'a', for overwrite, or append\n"); ! mthis->output(" overwrite is default\n"); ! /* exit(-1); */ } ! static void ! plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("standard XML output loaded::(%s)\n", my_file); } ! static int ! plugin_last_error(void) { ! return my_errno; } Index: log_file.h =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/log_file.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** log_file.h 4 Nov 2003 23:47:17 -0000 1.5 --- log_file.h 13 Apr 2004 03:42:07 -0000 1.6 *************** *** 45,47 **** ! #endif //_BARE_H_ --- 45,47 ---- ! #endif // _BARE_H_ Index: network_icmp.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/network_icmp.c,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** network_icmp.c 8 Apr 2004 21:09:07 -0000 1.44 --- network_icmp.c 13 Apr 2004 03:42:07 -0000 1.45 *************** *** 32,36 **** #endif ! static const char rcsid[] = "\100$ autosec/sonar: $Id$"; static unsigned char done = 0; --- 32,37 ---- #endif ! static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; [...2118 lines suppressed...] ! case SIGSEGV: ! err_msg("oops! ACK scan seg faulted.\n"); ! abort(); ! break; ! } ! /* just close the thread and be done with it */ ! pthread_exit(NULL); } /* out = out - in */ ! static void ! tvsub(struct timeval *out, struct timeval *in) { ! if((out->tv_usec -= in->tv_usec) < 0) ! { ! out->tv_sec--; ! out->tv_usec += 1000000; ! } ! out->tv_sec -= in->tv_sec; } Index: rfc793.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.c,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** rfc793.c 12 Apr 2004 23:46:31 -0000 1.47 --- rfc793.c 13 Apr 2004 03:42:07 -0000 1.48 *************** *** 32,36 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; static int my_socket, err_socket; --- 32,36 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; [...1494 lines suppressed...] ! return "host precedence violation"; ! case ICMP_UNREACH_PRECEDENCE_CUTOFF: ! return "precedence cutoff"; } return "unknown"; } ! static RETSIGTYPE ! sig_handler(int i) { ! switch (i) { ! case SIGSEGV: err_msg("oops! ACK scan seg faulted.\n"); abort(); break; ! } ! /* just close the thread and be done with it */ pthread_exit(NULL); } Index: log_file.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/log_file.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** log_file.c 8 Apr 2004 23:28:17 -0000 1.26 --- log_file.c 13 Apr 2004 03:42:07 -0000 1.27 *************** *** 40,44 **** static int plugin_close(void); static int plugin_output(char *msg, va_list * ap); ! static int plugin_results(target_t *result, unsigned int num); static void plugin_usage(void); static void plugin_status(void); --- 40,44 ---- static int plugin_close(void); static int plugin_output(char *msg, va_list * ap); ! static int plugin_results(target_t * result, unsigned int num); static void plugin_usage(void); static void plugin_status(void); *************** *** 46,50 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /** @fn plugin_init(void *in_data) --- 46,50 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; /** @fn plugin_init(void *in_data) *************** *** 55,355 **** */ ! void *plugin_init(void *in_data) { ! { ! assert(in_data != NULL); ! } ! //useless reference, to avoid a warning ! if(rcsid); ! ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! err_quit("Plugin API must be 6 or higher, update sonar"); ! pthis.type = OUTPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.version = 6; /* set API version 6 */ ! pthis.selected = false; ! pthis.plugin_char = 'L'; ! pthis.shortname = "log_file"; ! pthis.longname = "Log File output plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = NULL; ! // this is not needed for I/O plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = &plugin_output; ! pthis.plugin_results = &plugin_results; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! my_file = NULL; ! my_fp = NULL; ! return &pthis; } ! static int plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! my_file = NULL; ! my_fp = NULL; ! return PLUGIN_UNLOADED; } ! static int plugin_open(void *c_data, int i_data) { ! char *file_opts; // pointer to additional opts after filename ! char *append_or_overwrite = NULL; // indicates append or overwrite option ! int filename_len = i_data; // set length assuming no further options - - pthis.selected = true; // we were selected, whether the right arguments are present or not ! if (!c_data || i_data == 0) ! return PLUGIN_NOFILE; ! file_opts = strchr(c_data, ','); ! if (file_opts != NULL) ! { ! *file_opts++ = 0; // NULL delimit previous string, and advance ! // ! // if there was a comma, then don't include the comma and the ! // characters after it as part of the filename ! // ! filename_len = strlen(c_data); ! // ! // if an 'a' is found, then set the appropriate char option for fopen ! // other options may be filtered out with further if statements ! // ! if (*file_opts == 'a') ! append_or_overwrite = strdup("a"); ! else ! append_or_overwrite = strdup("w+"); ! } ! else ! append_or_overwrite = strdup("w+"); ! // check to see if my_file points to prev allocated data? ! my_file = strndup(c_data, filename_len); #ifdef DEBUG ! printf("fopen(\"%s\", \"%s\");\n", my_file, append_or_overwrite); #endif ! my_fp = fopen(my_file, append_or_overwrite); ! free(append_or_overwrite); ! if(!my_fp) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("Could not open file"); ! pthis.ready = false; ! return PLUGIN_NOFILE; ! } ! pthis.ready = true; ! return PLUGIN_OK; } ! static int plugin_close(void) { ! fclose(my_fp); ! free(my_file); ! return PLUGIN_OK; } ! static int plugin_output(char *msg, va_list * ap) { ! struct tm *gmt; ! time_t ltime; ! char *mtime; ! int tries = 0; ! //sanity checks ! if(!pthis.ready) ! { ! *(pthis.err) = PLUGIN_NOPEN; ! err_msg("output plugin not ready"); ! return PLUGIN_NOPEN; ! } ! while(!my_fp && tries < 3) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("output plugin not ready, retrying"); ! my_fp = fopen(my_file, "a"); /* reopen it instead of dying */ ! /*return PLUGIN_NOFILE;*/ ! tries++; ! } ! if(!my_fp) ! return PLUGIN_NOFILE; /* we tried */ ! time(<ime); ! gmt = localtime(<ime); ! mtime = asctime(gmt); ! mtime[strlen(mtime) - 1] = '\0'; ! fprintf(my_fp, "[%s] ", mtime); ! ! vfprintf(my_fp, msg, *ap); ! fflush(my_fp); ! return PLUGIN_OK; } ! static int null_result(target_t *result) { ! /* there is no way to report the hostname if we didn't get any responses :( */ ! fprintf(my_fp, "Got no responses\n"); ! ! return PLUGIN_OK; } ! static int plugin_results(target_t *result, unsigned int num) { ! struct sockaddr_in *sa = NULL; ! struct sockaddr_in6 *sa6 = NULL; ! char ip6sa_format[] = "%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x\0"; ! char buf[256]; ! int i, j; ! ! for(j = 0; j < num; j++) ! { ! assert(result != NULL); ! if(result->addrinfo == NULL) ! { ! null_result(result); ! continue; ! } ! ! memset(buf, 0, 256); ! fprintf(my_fp, "Host %s[", result->addrinfo->ai_canonname); ! switch(result->addrinfo->ai_family) ! { ! case PF_INET: ! sa = (struct sockaddr_in*) ! result->addrinfo->ai_addr; ! fprintf(my_fp, "%s] results:", ! inet_ntoa(sa->sin_addr)); ! break; ! case PF_INET6: ! sa6 = (struct sockaddr_in6 *) ! result->addrinfo->ai_addr; ! snprintf(buf, 255, ip6sa_format, ! sa6->sin6_addr.s6_addr[0], ! sa6->sin6_addr.s6_addr[1], ! sa6->sin6_addr.s6_addr[2], ! sa6->sin6_addr.s6_addr[3], ! sa6->sin6_addr.s6_addr[4], ! sa6->sin6_addr.s6_addr[5], ! sa6->sin6_addr.s6_addr[6], ! sa6->sin6_addr.s6_addr[7], ! sa6->sin6_addr.s6_addr[8], ! sa6->sin6_addr.s6_addr[9], ! sa6->sin6_addr.s6_addr[10], ! sa6->sin6_addr.s6_addr[11], ! sa6->sin6_addr.s6_addr[12], ! sa6->sin6_addr.s6_addr[13], ! sa6->sin6_addr.s6_addr[14], ! sa6->sin6_addr.s6_addr[15]); ! fprintf(my_fp, "%s] results:", buf); ! break; ! default: ! fprintf(my_fp, "unknown] results:"); ! }; ! fprintf(my_fp, " rtt=%0.2f ttl=%d mask=%d\n", ! result->stats.rtt_min, result->stats.ttl, ! result->netmask); ! /* print the port info */ ! for(i =0; i < 65536; i++) ! { ! switch(result->ports[i]) ! { ! case PORT_OPENED: ! fprintf(my_fp, ! " port %d state: " ! "open range: %0.2f ttl: %u\n", ! i, result->stats.rtt_avg, ! result->stats.ttl); ! break; ! case PORT_CLOSED: ! fprintf(my_fp, ! " port %d state: closed " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, ! result->stats.ttl); ! break; ! case PORT_FILTERED: ! fprintf(my_fp, ! " port %d state: filtered " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, ! result->stats.ttl); ! break; ! case PORT_UNFILTERED: ! fprintf(my_fp, ! " port %d state: unfiltered " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, ! result->stats.ttl); ! break; ! } ! } ! fprintf(my_fp, " stats: sent: %d, recvd: %d, dropped: %d\n", ! result->stats.packets_sent, ! result->stats.packets_recvd, ! result->stats.packets_sent - ! result->stats.packets_recvd); ! fprintf(my_fp, ! " rtt (min/max/avg): %.2f/%.2f/%.2f ms\n", ! result->stats.rtt_min, result->stats.rtt_max, ! result->stats.rtt_avg); ! result = result->next; ! } ! return PLUGIN_OK; } ! static void plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n Logfile output plugin\n"); ! mthis->output(" Usage: -oL,<filename>,[o/a]\n"); ! mthis->output(" [o/a]: either 'o' or 'a', for overwrite, or append\n"); ! mthis->output(" overwrite is default\n"); ! /*exit(-1);*/ } ! static void plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("standard logfile output loaded::(%s)\n", ! my_file); } ! static int plugin_last_error(void) { ! return my_errno; } --- 55,357 ---- */ ! void * ! plugin_init(void *in_data) { ! { ! assert(in_data != NULL); ! } ! // useless reference, to avoid a warning ! if(rcsid) ; ! // this is assumed ! mthis = (sonar_t *) in_data; ! if(mthis->api < 6) ! err_quit("Plugin API must be 6 or higher, update sonar"); ! pthis.type = OUTPUT_PLUGIN; ! pthis.err = &my_errno; ! pthis.ready = false; ! pthis.version = 6; /* set API version 6 */ ! pthis.selected = false; ! pthis.plugin_char = 'L'; ! pthis.shortname = "log_file"; ! pthis.longname = "Log File output plugin"; ! pthis.plugin_init = &plugin_init; ! pthis.plugin_destroy = &plugin_destroy; ! pthis.plugin_open = &plugin_open; ! pthis.plugin_close = &plugin_close; ! pthis.plugin_next = NULL; ! // this is not needed for I/O plugins ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = &plugin_output; ! pthis.plugin_results = &plugin_results; ! pthis.plugin_usage = &plugin_usage; ! pthis.plugin_status = &plugin_status; ! pthis.plugin_last_error = &plugin_last_error; ! my_errno = PLUGIN_LOADED; ! my_file = NULL; ! my_fp = NULL; ! ! return &pthis; } ! static int ! plugin_destroy(void) { ! mthis = NULL; ! pthis.type = 0; ! pthis.err = NULL; ! pthis.ready = false; ! pthis.plugin_init = NULL; ! pthis.plugin_destroy = NULL; ! pthis.plugin_open = NULL; ! pthis.plugin_close = NULL; ! pthis.plugin_next = NULL; ! pthis.plugin_sweep = NULL; ! pthis.plugin_output = NULL; ! pthis.plugin_results = NULL; ! pthis.plugin_usage = NULL; ! pthis.plugin_status = NULL; ! pthis.plugin_last_error = NULL; ! my_errno = PLUGIN_UNLOADED; ! my_file = NULL; ! my_fp = NULL; ! return PLUGIN_UNLOADED; } ! static int ! plugin_open(void *c_data, int i_data) { ! char *file_opts; // pointer to additional opts after filename ! char *append_or_overwrite = NULL; // indicates append or overwrite ! // option ! int filename_len = i_data; // set length assuming no further options ! pthis.selected = true; // we were selected, whether the right ! // arguments are present or not ! if(!c_data || i_data == 0) ! return PLUGIN_NOFILE; ! file_opts = strchr(c_data, ','); ! if(file_opts != NULL) ! { ! *file_opts++ = 0; // NULL delimit previous string, and advance ! // ! // if there was a comma, then don't include the comma and the ! // characters after it as part of the filename ! // ! filename_len = strlen(c_data); ! // ! // if an 'a' is found, then set the appropriate char option for fopen ! // other options may be filtered out with further if statements ! // ! if(*file_opts == 'a') ! append_or_overwrite = strdup("a"); ! else ! append_or_overwrite = strdup("w+"); ! } ! else ! append_or_overwrite = strdup("w+"); ! ! // check to see if my_file points to prev allocated data? ! my_file = strndup(c_data, filename_len); #ifdef DEBUG ! printf("fopen(\"%s\", \"%s\");\n", my_file, append_or_overwrite); #endif ! my_fp = fopen(my_file, append_or_overwrite); ! free(append_or_overwrite); ! if(!my_fp) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("Could not open file"); ! pthis.ready = false; ! return PLUGIN_NOFILE; ! } ! pthis.ready = true; ! return PLUGIN_OK; } ! static int ! plugin_close(void) { ! fclose(my_fp); ! free(my_file); ! return PLUGIN_OK; } ! static int ! plugin_output(char *msg, va_list * ap) { ! struct tm *gmt; ! time_t ltime; ! char *mtime; ! int tries = 0; ! // sanity checks ! if(!pthis.ready) ! { ! *(pthis.err) = PLUGIN_NOPEN; ! err_msg("output plugin not ready"); ! return PLUGIN_NOPEN; ! } ! while(!my_fp && tries < 3) ! { ! *(pthis.err) = PLUGIN_NOFILE; ! err_msg("output plugin not ready, retrying"); ! my_fp = fopen(my_file, "a"); /* reopen it instead of dying */ ! /* return PLUGIN_NOFILE; */ ! tries++; ! } ! if(!my_fp) ! return PLUGIN_NOFILE; /* we tried */ ! time(<ime); ! gmt = localtime(<ime); ! mtime = asctime(gmt); ! mtime[strlen(mtime) - 1] = '\0'; ! fprintf(my_fp, "[%s] ", mtime); ! ! vfprintf(my_fp, msg, *ap); ! fflush(my_fp); ! return PLUGIN_OK; } ! static int ! null_result(target_t * result) { ! /* there is no way to report the hostname if we didn't get any responses ! * :( */ ! fprintf(my_fp, "Got no responses\n"); ! ! return PLUGIN_OK; } ! static int ! plugin_results(target_t * result, unsigned int num) { ! struct sockaddr_in *sa = NULL; ! struct sockaddr_in6 *sa6 = NULL; ! char ip6sa_format[] = "%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x:%x\0"; ! char buf[256]; ! int i, j; ! ! for(j = 0; j < num; j++) ! { ! assert(result != NULL); ! if(result->addrinfo == NULL) ! { ! null_result(result); ! continue; ! } ! ! memset(buf, 0, 256); ! fprintf(my_fp, "Host %s[", result->addrinfo->ai_canonname); ! switch (result->addrinfo->ai_family) ! { ! case PF_INET: ! sa = (struct sockaddr_in *) result->addrinfo->ai_addr; ! fprintf(my_fp, "%s] results:", inet_ntoa(sa->sin_addr)); ! break; ! case PF_INET6: ! sa6 = (struct sockaddr_in6 *) result->addrinfo->ai_addr; ! snprintf(buf, 255, ip6sa_format, ! sa6->sin6_addr.s6_addr[0], ! sa6->sin6_addr.s6_addr[1], ! sa6->sin6_addr.s6_addr[2], ! sa6->sin6_addr.s6_addr[3], ! sa6->sin6_addr.s6_addr[4], ! sa6->sin6_addr.s6_addr[5], ! sa6->sin6_addr.s6_addr[6], ! sa6->sin6_addr.s6_addr[7], ! sa6->sin6_addr.s6_addr[8], ! sa6->sin6_addr.s6_addr[9], ! sa6->sin6_addr.s6_addr[10], ! sa6->sin6_addr.s6_addr[11], ! sa6->sin6_addr.s6_addr[12], ! sa6->sin6_addr.s6_addr[13], ! sa6->sin6_addr.s6_addr[14], sa6->sin6_addr.s6_addr[15]); ! fprintf(my_fp, "%s] results:", buf); ! break; ! default: ! fprintf(my_fp, "unknown] results:"); ! }; ! fprintf(my_fp, " rtt=%0.2f ttl=%d mask=%d\n", ! result->stats.rtt_min, result->stats.ttl, result->netmask); ! /* print the port info */ ! for(i = 0; i < 65536; i++) ! { ! switch (result->ports[i]) ! { ! case PORT_OPENED: ! fprintf(my_fp, ! " port %d state: " ! "open range: %0.2f ttl: %u\n", ! i, result->stats.rtt_avg, result->stats.ttl); ! break; ! case PORT_CLOSED: ! fprintf(my_fp, ! " port %d state: closed " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, result->stats.ttl); ! break; ! case PORT_FILTERED: ! fprintf(my_fp, ! " port %d state: filtered " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, result->stats.ttl); ! break; ! case PORT_UNFILTERED: ! fprintf(my_fp, ! " port %d state: unfiltered " ! "range: %0.2f ttl: %u\n", i, ! result->stats.rtt_avg, result->stats.ttl); ! break; ! } ! } ! fprintf(my_fp, " stats: sent: %d, recvd: %d, dropped: %d\n", ! result->stats.packets_sent, ! result->stats.packets_recvd, ! result->stats.packets_sent - result->stats.packets_recvd); ! fprintf(my_fp, ! " rtt (min/max/avg): %.2f/%.2f/%.2f ms\n", ! result->stats.rtt_min, result->stats.rtt_max, ! result->stats.rtt_avg); ! result = result->next; ! } ! return PLUGIN_OK; } ! static void ! plugin_usage(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! mthis->output("\n Logfile output plugin\n"); ! mthis->output(" Usage: -oL,<filename>,[o/a]\n"); ! mthis->output(" [o/a]: either 'o' or 'a', for overwrite, or append\n"); ! mthis->output(" overwrite is default\n"); ! /* exit(-1); */ } ! static void ! plugin_status(void) { ! assert(mthis != NULL); ! assert(mthis->output != NULL); ! if(pthis.ready && pthis.selected) ! mthis->output("standard logfile output loaded::(%s)\n", my_file); } ! static int ! plugin_last_error(void) { ! return my_errno; } Index: error.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/error.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** error.c 28 Feb 2004 08:00:55 -0000 1.3 --- error.c 13 Apr 2004 03:42:07 -0000 1.4 *************** *** 45,49 **** static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; //extern int daemon_proc; /* set nonzero by daemon_init() */ --- 45,49 ---- static const char rcsid[] = ! "\100$ autosec/sonar: $Id$"; //extern int daemon_proc; /* set nonzero by daemon_init() */ *************** *** 56,67 **** * Print a message and return. */ ! void err_ret(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_INFO, fmt, ap); ! va_end(ap); ! return; } --- 56,68 ---- * Print a message and return. */ ! void ! err_ret(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_INFO, fmt, ap); ! va_end(ap); ! return; } *************** *** 69,80 **** * Print a message and terminate. */ ! void err_sys(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_ERR, fmt, ap); ! va_end(ap); ! exit(1); } --- 70,82 ---- * Print a message and terminate. */ ! void ! err_sys(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_ERR, fmt, ap); ! va_end(ap); ! exit(1); } *************** *** 82,94 **** * Print a message, dump core, and terminate. */ ! void err_dump(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_ERR, fmt, ap); ! va_end(ap); ! abort(); /* dump core and terminate */ ! exit(1); /* shouldn't get here */ } --- 84,97 ---- * Print a message, dump core, and terminate. */ ! void ! err_dump(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(1, LOG_ERR, fmt, ap); ! va_end(ap); ! abort(); /* dump core and terminate */ ! exit(1); /* shouldn't get here */ } *************** *** 96,107 **** * Print a message and return. */ ! void err_msg(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(0, LOG_INFO, fmt, ap); ! va_end(ap); ! return; } --- 99,111 ---- * Print a message and return. */ ! void ! err_msg(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(0, LOG_INFO, fmt, ap); ! va_end(ap); ! return; } *************** *** 109,120 **** * Print a message and terminate. */ ! void err_quit(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(0, LOG_ERR, fmt, ap); ! va_end(ap); ! exit(1); } --- 113,125 ---- * Print a message and terminate. */ ! void ! err_quit(const char *fmt, ...) { ! va_list ap; ! va_start(ap, fmt); ! err_doit(0, LOG_ERR, fmt, ap); ! va_end(ap); ! exit(1); } *************** *** 122,154 **** * Caller specifies "errnoflag" and "level". */ ! static void err_doit(int errnoflag, int level, const char *fmt, va_list ap) { ! int errno_save, n; ! char buf[MAXLINE]; ! errno_save = errno; /* value caller might want printed */ ! ! #ifdef HAVE_VSNPRINTF ! vsnprintf(buf, sizeof(buf), fmt, ap); /* this is safe */ ! #else ! vsprintf(buf, fmt, ap); /* this is not safe */ ! #endif ! ! n = strlen(buf); ! if(errnoflag) ! snprintf(buf + n, sizeof(buf) - n, ": %s", ! strerror(errno_save)); ! strcat(buf, "\n"); ! if(mthis.sCon.bFork) ! { ! syslog(level, buf); ! } ! else ! { ! fflush(stdout); /* in case stdout and stderr are the same */ ! fputs(buf, stderr); ! fflush(stderr); ! } ! return; } --- 127,159 ---- * Caller specifies "errnoflag" and "level". */ ! static void ! err_doit(int errnoflag, int level, const char *fmt, va_list ap) { ! int errno_save, n; ! char buf[MAXLINE]; ! errno_save = errno; /* value caller might want printed */ ! #ifdef HAVE_VSNPRINTF ! vsnprintf(buf, sizeof(buf), fmt, ap); /* this is safe */ ! #else ! vsprintf(buf, fmt, ap); /* this is not safe */ ! #endif ! ! n = strlen(buf); ! if(errnoflag) ! snprintf(buf + n, sizeof(buf) - n, ": %s", strerror(errno_save)); ! strcat... [truncated message content] |
From: Jacob F. <ph...@us...> - 2004-04-13 00:00:25
|
Update of /cvsroot/autosec/sonar/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21337/plugins Modified Files: rfc793.c Log Message: Found and commented out some potentially dead code Index: rfc793.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.c,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** rfc793.c 9 Apr 2004 15:41:36 -0000 1.46 --- rfc793.c 12 Apr 2004 23:46:31 -0000 1.47 *************** *** 467,471 **** unsigned int j; int total_size = sizeof(struct tcphdr); ! int my_ports[65547]; uint32_t addr, one=1; --- 467,473 ---- unsigned int j; int total_size = sizeof(struct tcphdr); ! //XXX: ! //was my_ports meant for something? if not it's not doing anything useful ! //int my_ports[65547]; uint32_t addr, one=1; *************** *** 481,485 **** gethostname(name, 255); ai = mthis->resolve(name, NULL, PF_INET, 0); ! memcpy(my_ports, target->ports, 65537 * sizeof(int)); for(j = 0; j <= target->extra_hosts; j++) { --- 483,488 ---- gethostname(name, 255); ai = mthis->resolve(name, NULL, PF_INET, 0); ! //XXX: delete? ! //memcpy(my_ports, target->ports, 65537 * sizeof(int)); for(j = 0; j <= target->extra_hosts; j++) { *************** *** 539,542 **** --- 542,546 ---- } + nt.dport=-1; for(i = 0; i < 65536; i++) { *************** *** 569,574 **** target->stats.packets_sent++; free(packet); /* fresh copy of port list */ ! memcpy(target->ports, my_ports, 65537 * sizeof(int)); } --- 573,579 ---- target->stats.packets_sent++; free(packet); + //XXX: delete? /* fresh copy of port list */ ! //memcpy(target->ports, my_ports, 65537 * sizeof(int)); } |
From: Jacob F. <ph...@us...> - 2004-04-12 23:59:44
|
Update of /cvsroot/autosec/sonar/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21213/doc Modified Files: sonar_plugin_man.tex Log Message: s/are/as/ Index: sonar_plugin_man.tex =================================================================== RCS file: /cvsroot/autosec/sonar/doc/sonar_plugin_man.tex,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** sonar_plugin_man.tex 8 Apr 2004 21:57:32 -0000 1.1 --- sonar_plugin_man.tex 12 Apr 2004 23:45:51 -0000 1.2 *************** *** 17,21 **** \chapter{Plugin Functions} Depending on what type of plugin you are writing, you must specify certain required functions and fill them in. ! Input, Output, and Networking plugins have different requirements that we will outline below. Because of the structure of sonar's plugin API, you need not name your functions are they are named below, and in fact, I encourage you to choose a more descriptive name for your functions. However, you must provide a function that will perform the main task of the functions. Each plugin is assumed to return PLUGIN\_OK on success if it has an \emph{int} return type. \section{Input Plugins} \subsection{plugin\_open} --- 17,23 ---- \chapter{Plugin Functions} Depending on what type of plugin you are writing, you must specify certain required functions and fill them in. ! Input, Output, and Networking plugins have different requirements that we will ! outline below. Because of the structure of sonar's plugin API, you need not name ! your functions as they are named below, and in fact, I encourage you to choose a more descriptive name for your functions. However, you must provide a function that will perform the main task of the functions. Each plugin is assumed to return PLUGIN\_OK on success if it has an \emph{int} return type. \section{Input Plugins} \subsection{plugin\_open} |
From: Jacob F. <ph...@us...> - 2004-04-12 23:58:09
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20972/src Modified Files: popts.c Log Message: Changed flags displayed in the plugin listing Index: popts.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/popts.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** popts.c 11 Apr 2004 02:31:26 -0000 1.10 --- popts.c 12 Apr 2004 23:44:16 -0000 1.11 *************** *** 118,122 **** { plug=input_list[i].plug; ! fprintf(stderr, "IN -s%c %15s %30s\n",plug->plugin_char, plug->shortname,plug->longname); } --- 118,122 ---- { plug=input_list[i].plug; ! fprintf(stderr, "IN -i%c %15s %30s\n",plug->plugin_char, plug->shortname,plug->longname); } *************** *** 124,128 **** { plug=output_list[i].plug; ! fprintf(stderr, "OUT -s%c %15s %30s\n",plug->plugin_char, plug->shortname,plug->longname); } --- 124,128 ---- { plug=output_list[i].plug; ! fprintf(stderr, "OUT -o%c %15s %30s\n",plug->plugin_char, plug->shortname,plug->longname); } |
From: Jacob F. <ph...@us...> - 2004-04-11 21:03:44
|
Update of /cvsroot/autosec/sonar/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23688 Modified Files: sonar.1.in Log Message: --host_timeout is now --delay Index: sonar.1.in =================================================================== RCS file: /cvsroot/autosec/sonar/doc/sonar.1.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** sonar.1.in 11 Apr 2004 02:21:28 -0000 1.3 --- sonar.1.in 11 Apr 2004 20:50:01 -0000 1.4 *************** *** 129,133 **** Set the time to delay between cycles. .TP ! .B \-\-host_timeout=mseconds Timeout for scans, per host .I (default: 5000) --- 129,133 ---- Set the time to delay between cycles. .TP ! .B \-\-delay=mseconds Timeout for scans, per host .I (default: 5000) |
From: <no...@so...> - 2004-04-11 20:42:31
|
The following NEW bug has been ADDED. ======================================================================= http://autosec.sourceforge.net/helpDesk/mantis/view_bug_page.php?f_id=47 ======================================================================= Reporter: pharkas Handler: ======================================================================= Project: sonar Bug ID: 0000047 Category: Feature Requests Reproducibility: N/A Severity: minor Priority: normal Status: new ======================================================================= Date Submitted: 04-11-04 13:42 PDT Last Modified: 04-11-04 13:42 PDT ======================================================================= Summary: Command line target expansion Description: A printf-style expansion of command line parameters would be nice to have. Here's the parameters so far: %t - host name:port name %t - ip:port number %i - ip %h - host name %p - port number %P - port name %y - year %m - month (numeric) %d - date %H - hour %M - minutes %S - seconds ======================================================================= |
From: <no...@so...> - 2004-04-11 20:10:38
|
A BUGNOTE has been added to this bug. ======================================================================= http://autosec.sourceforge.net/helpDesk/mantis/view_bug_page.php?f_id=0000046 ======================================================================= Reporter: pharkas Handler: ======================================================================= Project: sonar Bug ID: 0000046 Category: Code Cleanup Reproducibility: N/A Severity: tweak Priority: low Status: new ======================================================================= Date Submitted: 04-10-04 21:51 PDT Last Modified: 04-11-04 13:10 PDT ======================================================================= Summary: target_t.ports array is huge Description: The ports array in every target_t struct is statically allocated to 65536 ints which takes up a lot of memory. We could cut this in half by changing it to chars ======================================================================= ----------------------------------------------------------------------- pharkas - 04-11-04 13:10 PDT ----------------------------------------------------------------------- On second thought it'd be better to abstract out the ports to methods so that we don't have to make every plugin deal with the ports. This is especially important if we ever want to move to a dynamic structure in the future. That's a much bigger project than s/int/char/, so i'm going to hold off on it until after the target expansion is done |
From: red0x <re...@us...> - 2004-04-11 07:55:44
|
Update of /cvsroot/autosec/sonar In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16105 Modified Files: ChangeLog Log Message: Changelog was out of date Index: ChangeLog =================================================================== RCS file: /cvsroot/autosec/sonar/ChangeLog,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** ChangeLog 6 Dec 2003 00:49:04 -0000 1.42 --- ChangeLog 11 Apr 2004 07:42:08 -0000 1.43 *************** *** 1,3 **** ! 2003-12-06 re...@us... <red0x@xpider> * src/plugin.h: Updated documentation --- 1,284 ---- ! 2004-04-11 pharkas <pharkas@xpider> ! ! * src/sonar.h: ! Forgot to check this in earlier - added --plugin_list to the options array ! ! * src/plugin.c, src/plugin.h, src/target.c, src/target.h: [...1355 lines suppressed...] ! New file. ! ! * src/queue.h: Import version 0.4 ! ! * src/queue.h: New file. ! ! * src/Makefile.in, src/queue.cpp: Import version 0.4 ! ! * src/Makefile.in, src/queue.cpp: New file. ! ! * AUTHORS, CONTRIB, COPYING, ChangeLog, INSTALL, TODO, configure, configure.in, install-sh: ! Import version 0.4 ! ! * AUTHORS, CONTRIB, COPYING, ChangeLog, INSTALL, TODO, configure, configure.in, install-sh: ! New file. ! ! * .cvsignore, README, config.h.in: Import version 0.4 ! ! * .cvsignore, README, config.h.in: New file. |
From: Jacob F. <ph...@us...> - 2004-04-11 05:01:29
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25887/src Modified Files: sonar.h Log Message: Forgot to check this in earlier - added --plugin_list to the options array Index: sonar.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/sonar.h,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** sonar.h 28 Feb 2004 12:43:40 -0000 1.31 --- sonar.h 11 Apr 2004 04:47:49 -0000 1.32 *************** *** 41,44 **** --- 41,45 ---- {"delay", 1, NULL, 'h'}, \ {"debug", 0, NULL, 'b'}, \ + {"plugin_list", 0, NULL, 'l'}, \ int h_errno; |
From: Jacob F. <ph...@us...> - 2004-04-11 04:57:53
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25286/src Modified Files: target.c target.h plugin.c plugin.h Log Message: Changed the way the default ports are pulled from /etc/services - they're only pulled once and then copied to every new target, rather than scanning /etc/services every time for every new target. Index: plugin.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.c,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** plugin.c 9 Apr 2004 07:03:28 -0000 1.33 --- plugin.c 11 Apr 2004 04:44:18 -0000 1.34 *************** *** 31,34 **** --- 31,35 ---- #include "plugin.h" + #include "target.h" #include "util.h" #include "error.h" *************** *** 192,195 **** --- 193,199 ---- void *(*plugin_init) (void *); struct stat *my_buf; + + /* fill the port array from /etc/services */ + load_default_ports_array(); /* try to get the owner and mode of sonar */ if((my_buf = get_stats(mthis->my_name)) == NULL) Index: target.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/target.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** target.h 17 Jan 2004 03:12:32 -0000 1.6 --- target.h 11 Apr 2004 04:44:18 -0000 1.7 *************** *** 28,31 **** --- 28,32 ---- target_t *sonar_find_target(sonar_t *this, struct addrinfo *ai); int sonar_add_target(sonar_t * this, char *entry); + void load_default_ports_array(); #ifdef DEBUG Index: target.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/target.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** target.c 8 Apr 2004 21:10:41 -0000 1.16 --- target.c 11 Apr 2004 04:44:18 -0000 1.17 *************** *** 36,39 **** --- 36,40 ---- extern sonar_t mthis; + static int portmask[MAX_PORTS]; static const char rcsid[] = *************** *** 46,60 **** int sonar_add_target(sonar_t * this, char *entry) { ! struct addrinfo *addr; ! target_t *target, *ent; char *hostname; char *ports; char *mask; ! int len,i=0; unsigned int num_ports = 0, num_hosts = 0; int imask = 32; ! assert(this != NULL); ! assert(entry != NULL); len = strlen(entry); --- 47,61 ---- int sonar_add_target(sonar_t * this, char *entry) { ! struct addrinfo *addr; ! target_t *target, *ent; char *hostname; char *ports; char *mask; ! int len,i=0; unsigned int num_ports = 0, num_hosts = 0; int imask = 32; ! assert(this != NULL); ! assert(entry != NULL); len = strlen(entry); *************** *** 252,256 **** if(!*target) *target = Malloc(sizeof(target_t)); ! memset((*target)->ports, PORT_DONTSCAN, 65537); /* get default ports from /etc/services */ if(!ports) --- 253,257 ---- if(!*target) *target = Malloc(sizeof(target_t)); ! memset((*target)->ports, PORT_DONTSCAN, MAX_PORTS); /* get default ports from /etc/services */ if(!ports) *************** *** 263,267 **** { log_write(LOG_DBUG, " setting all ports to scan\n"); ! for( i = 0; i < 65536; i++) { (*target)->ports[i] = PORT_SCAN; --- 264,268 ---- { log_write(LOG_DBUG, " setting all ports to scan\n"); ! for( i = 0; i < MAX_PORTS; i++) { (*target)->ports[i] = PORT_SCAN; *************** *** 299,311 **** } static int load_default_ports(target_t **target) { ! struct servent *se; assert(*target != NULL); (*target)->num_ports = 0; ! while((se = getservent()) != NULL) { ! (*target)->ports[se->s_port] = PORT_SCAN; ! (*target)->num_ports++; } endservent(); --- 300,320 ---- } + void load_default_ports_array() { + struct servent *se; + memset(portmask,PORT_DONTSCAN,MAX_PORTS); + while((se = getservent()) != NULL) + portmask[se->s_port] = PORT_SCAN; + } + static int load_default_ports(target_t **target) { ! int i; assert(*target != NULL); (*target)->num_ports = 0; ! for(i=0;i<MAX_PORTS;i++) { ! (*target)->ports[i] = portmask[i]; ! if(portmask[i] == PORT_SCAN) ! (*target)->num_ports++; } endservent(); Index: plugin.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.h,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** plugin.h 9 Apr 2004 07:03:28 -0000 1.42 --- plugin.h 11 Apr 2004 04:44:18 -0000 1.43 *************** *** 96,99 **** --- 96,101 ---- //@} + #define MAX_PORTS 65537 + #define PORT_DONTSCAN 0 *************** *** 125,129 **** char *entry; /// list of ports to scan ! int ports[65537]; /// address info, including family, protocol, and socket type struct addrinfo *addrinfo; --- 127,131 ---- char *entry; /// list of ports to scan ! int ports[MAX_PORTS]; /// address info, including family, protocol, and socket type struct addrinfo *addrinfo; |
From: <no...@so...> - 2004-04-11 04:51:40
|
The following NEW bug has been ADDED. ======================================================================= http://autosec.sourceforge.net/helpDesk/mantis/view_bug_page.php?f_id=46 ======================================================================= Reporter: pharkas Handler: ======================================================================= Project: sonar Bug ID: 0000046 Category: Code Cleanup Reproducibility: N/A Severity: tweak Priority: low Status: new ======================================================================= Date Submitted: 04-10-04 21:51 PDT Last Modified: 04-10-04 21:51 PDT ======================================================================= Summary: target_t.ports array is huge Description: The ports array in every target_t struct is statically allocated to 65536 ints which takes up a lot of memory. We could cut this in half by changing it to chars ======================================================================= |
From: Jacob F. <ph...@us...> - 2004-04-11 02:45:15
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7553/src Modified Files: popts.c Log Message: The plugin list took up too much space. This looks much cleaner. Index: popts.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/popts.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** popts.c 11 Apr 2004 02:20:47 -0000 1.9 --- popts.c 11 Apr 2004 02:31:26 -0000 1.10 *************** *** 110,143 **** sonar_opt_header(); ! fprintf(stderr, "\nInput Plugins\n"); ! fprintf(stderr, "Char Name Description\n"); ! fprintf(stderr, "---- ---------------- --------------------------\n"); for(i=0;i<num_inp;i++) { plug=input_list[i].plug; ! fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, ! plug->longname); } - fprintf(stderr, "\n"); - - fprintf(stderr, "Output Plugins\n"); - fprintf(stderr, "Char Name Description\n"); - fprintf(stderr, "---- ---------------- --------------------------\n"); for(i=0;i<num_out;i++) { plug=output_list[i].plug; ! fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, ! plug->longname); } - fprintf(stderr, "\n"); - - fprintf(stderr, "Network Plugins\n"); - fprintf(stderr, "Char Name Description\n"); - fprintf(stderr, "---- ---------------- --------------------------\n"); for(i=0;i<num_net;i++) { plug=network_list[i].plug; ! fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, ! plug->longname); } fprintf(stderr, "\n"); --- 110,135 ---- sonar_opt_header(); ! fprintf(stderr, "\n Currently Loaded Plugins\n"); ! fprintf(stderr, "Type Cmd Name Description" ! "\n"); ! fprintf(stderr, "---- --- ---------------- -------------------------------" ! "\n"); for(i=0;i<num_inp;i++) { plug=input_list[i].plug; ! fprintf(stderr, "IN -s%c %15s %30s\n",plug->plugin_char, ! plug->shortname,plug->longname); } for(i=0;i<num_out;i++) { plug=output_list[i].plug; ! fprintf(stderr, "OUT -s%c %15s %30s\n",plug->plugin_char, ! plug->shortname,plug->longname); } for(i=0;i<num_net;i++) { plug=network_list[i].plug; ! fprintf(stderr, "NET -s%c %15s %30s\n",plug->plugin_char, ! plug->shortname,plug->longname); } fprintf(stderr, "\n"); |
From: Jacob F. <ph...@us...> - 2004-04-11 02:35:03
|
Update of /cvsroot/autosec/sonar/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5901 Modified Files: sonar.1.in Log Message: Added plugin list command line option to man Index: sonar.1.in =================================================================== RCS file: /cvsroot/autosec/sonar/doc/sonar.1.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** sonar.1.in 3 Feb 2004 01:56:31 -0000 1.2 --- sonar.1.in 11 Apr 2004 02:21:28 -0000 1.3 *************** *** 73,76 **** --- 73,79 ---- Use the named input plugin. No input plugins are supported yet. .TP + .B \-l, \-\-plugin_list + List all loaded plugins. + .TP .B \-o, \-\-output_plugin=plugin Use the specified output plugin. Still outputs to stdout. |
From: Jacob F. <ph...@us...> - 2004-04-11 02:34:30
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5776 Modified Files: popts.c popts.h sonar.c Log Message: Added plugin listing to the command line options Index: popts.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/popts.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** popts.h 29 Jan 2004 23:43:52 -0000 1.3 --- popts.h 11 Apr 2004 02:20:48 -0000 1.4 *************** *** 34,37 **** --- 34,39 ---- #endif + #include "plugin.h" + #define PLUGIN_SELECT 2 #define INPUT_SELECT 3 *************** *** 39,45 **** --- 41,49 ---- #define PLUGIN_OPTION 5 + void sonar_opt_header(); void sonar_opt_usage(int exitcode, char *error, char *addl); void sonar_opt_help(int exitcode); + void sonar_opt_pluginlist(); Index: popts.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/popts.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** popts.c 28 Feb 2004 12:43:40 -0000 1.8 --- popts.c 11 Apr 2004 02:20:47 -0000 1.9 *************** *** 34,60 **** "\100$ autosec/sonar: $Id$"; ! void sonar_opt_usage(int exitcode, char *error, ! char *addl) ! { #ifndef DEBUG ! fprintf(stderr, ! "%s - red0x <re...@us...>\nBugs: <%s>\n", ! PACKAGE_STRING, PACKAGE_BUGREPORT); #else ! fprintf(stderr, ! "%s debug - red0x <re...@us...>\nBugs: <%s>\n", ! PACKAGE_STRING, PACKAGE_BUGREPORT); #endif ! fprintf(stderr, "FREE for NON-COMMERCIAL USE\n"); ! fprintf(stderr, "Usage: %s [options] <scan-type> <target(s)>\n", ! PACKAGE_NAME); fprintf(stderr, " options: [-f|--fork] [-v|--verbose] [-q|--quiet] " "[-r|--randomize]\n"); fprintf(stderr, "\t[--scan_delay=seconds] [-c|--count cycles] " "[-s|--scan_type plugin]\n"); ! fprintf(stderr, "\t[-i|--input plugin] [-o|--output plugin] " ! "[-p|--plugin_opt option_string]\n"); ! fprintf(stderr, "\t[--post_delay=mseconds] [--timeout=mseconds]\n"); ! fprintf(stderr, "\t[-?|--help] [--usage]\n"); if(error) fprintf(stderr, "%s: %s\n", error, addl); --- 34,67 ---- "\100$ autosec/sonar: $Id$"; ! extern plugin_list_t network_list[]; ! extern plugin_list_t input_list[]; ! extern plugin_list_t output_list[]; ! extern int num_net, num_inp, num_out; ! ! void sonar_opt_header() { #ifndef DEBUG ! fprintf(stderr, "%s - red0x <re...@us...>\nBugs: <%s>\n", ! PACKAGE_STRING, PACKAGE_BUGREPORT); #else ! fprintf(stderr, "%s debug - red0x <re...@us...>\nBugs: <%s>" ! "\n", PACKAGE_STRING, PACKAGE_BUGREPORT); #endif ! fprintf(stderr, "FREE for NON-COMMERCIAL USE\n"); ! ! } ! ! void sonar_opt_usage(int exitcode, char *error, ! char *addl) ! { ! sonar_opt_header(); fprintf(stderr, " options: [-f|--fork] [-v|--verbose] [-q|--quiet] " "[-r|--randomize]\n"); fprintf(stderr, "\t[--scan_delay=seconds] [-c|--count cycles] " "[-s|--scan_type plugin]\n"); ! fprintf(stderr, "\t[-i|--input plugin] [-l|--plugin_list] " ! "[-o|--output plugin]\n"); ! fprintf(stderr, "\t[-p|--plugin_opt option_string] [--post_delay=mseconds]" ! "\n"); ! fprintf(stderr, "\t[--timeout=mseconds] [-?|--help] [--usage]\n"); if(error) fprintf(stderr, "%s: %s\n", error, addl); *************** *** 64,77 **** void sonar_opt_help(int exitcode) { ! #ifndef DEBUG ! fprintf(stderr, ! "%s - red0x <re...@us...>\nBugs: <%s>\n", ! PACKAGE_STRING, PACKAGE_BUGREPORT); ! #else ! fprintf(stderr, ! "%s debug - red0x <re...@us...>\nBugs: <%s>\n", ! PACKAGE_STRING, PACKAGE_BUGREPORT); ! #endif ! fprintf(stderr, "FREE for NON-COMMERCIAL USE\n"); fprintf(stderr, "Usage: sonar [options] <scan-type> <target(s)>\n"); fprintf(stderr, " -f, --fork fork into background " --- 71,75 ---- void sonar_opt_help(int exitcode) { ! sonar_opt_header(); fprintf(stderr, "Usage: sonar [options] <scan-type> <target(s)>\n"); fprintf(stderr, " -f, --fork fork into background " *************** *** 91,94 **** --- 89,93 ---- fprintf(stderr, " -i, --input=plugin input plugin to " "use\n"); + fprintf(stderr, " -l, --plugin_list list loaded plugins\n"); fprintf(stderr, " -o, --output=plugin output plugin to " "use\n"); *************** *** 104,105 **** --- 103,144 ---- exit(exitcode); } + + void sonar_opt_pluginlist() { + int i; + plugin_t *plug; + + sonar_opt_header(); + + fprintf(stderr, "\nInput Plugins\n"); + fprintf(stderr, "Char Name Description\n"); + fprintf(stderr, "---- ---------------- --------------------------\n"); + for(i=0;i<num_inp;i++) + { + plug=input_list[i].plug; + fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, + plug->longname); + } + fprintf(stderr, "\n"); + + fprintf(stderr, "Output Plugins\n"); + fprintf(stderr, "Char Name Description\n"); + fprintf(stderr, "---- ---------------- --------------------------\n"); + for(i=0;i<num_out;i++) + { + plug=output_list[i].plug; + fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, + plug->longname); + } + fprintf(stderr, "\n"); + + fprintf(stderr, "Network Plugins\n"); + fprintf(stderr, "Char Name Description\n"); + fprintf(stderr, "---- ---------------- --------------------------\n"); + for(i=0;i<num_net;i++) + { + plug=network_list[i].plug; + fprintf(stderr, " %c %15s %25s\n",plug->plugin_char,plug->shortname, + plug->longname); + } + fprintf(stderr, "\n"); + } Index: sonar.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/sonar.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** sonar.c 8 Apr 2004 19:11:03 -0000 1.42 --- sonar.c 11 Apr 2004 02:20:48 -0000 1.43 *************** *** 60,73 **** { char *temp, *pv; ! sonar_t *mthis; assert(in != NULL); ! mthis = (sonar_t *) in; ! memset((void *) mthis, 0, sizeof(sonar_t)); ! mthis->ver_major = 0; ! mthis->ver_minor = 0; ! mthis->revision = 0; pv = (char *) Malloc(strlen(PACKAGE_VERSION)); strncpy(pv, PACKAGE_VERSION, strlen(PACKAGE_VERSION)); --- 60,73 ---- { char *temp, *pv; ! sonar_t *mthat; assert(in != NULL); ! mthat = (sonar_t *) in; ! memset((void *) mthat, 0, sizeof(sonar_t)); ! mthat->ver_major = 0; ! mthat->ver_minor = 0; ! mthat->revision = 0; pv = (char *) Malloc(strlen(PACKAGE_VERSION)); strncpy(pv, PACKAGE_VERSION, strlen(PACKAGE_VERSION)); *************** *** 75,108 **** while(pv != NULL) { ! if(temp) ! *temp++ = 0x00; ! if(mthis->ver_major == 0) ! mthis->ver_major = atoi(pv); ! else if(mthis->ver_minor == 0) ! mthis->ver_minor = atoi(pv); ! else if(mthis->revision == 0) ! mthis->revision = atoi(pv); ! else ! pv = NULL; ! pv = temp; ! if(!pv) ! break; ! temp = strpbrk(pv, "."); } free(pv); // plugin API number ! mthis->api = API_VER; ! mthis->memput = &bput; ! mthis->message = &sonar_msg; ! mthis->resolve = &Host_serv; ! mthis->output = &sonar_rawoutput; ! mthis->usage = &sonar_usage; ! mthis->getprivs = &sonar_getprivs; ! mthis->dropprivs = &sonar_dropprivs; ! mthis->find_target = &sonar_find_target; // no targets yet ;) ! mthis->vectors = NULL; ! mthis->num_targets = 0; ! mthis->num_ports = 0; } --- 75,108 ---- while(pv != NULL) { ! if(temp) ! *temp++ = 0x00; ! if(mthat->ver_major == 0) ! mthat->ver_major = atoi(pv); ! else if(mthat->ver_minor == 0) ! mthat->ver_minor = atoi(pv); ! else if(mthat->revision == 0) ! mthat->revision = atoi(pv); ! else ! pv = NULL; ! pv = temp; ! if(!pv) ! break; ! temp = strpbrk(pv, "."); } free(pv); // plugin API number ! mthat->api = API_VER; ! mthat->memput = &bput; ! mthat->message = &sonar_msg; ! mthat->resolve = &Host_serv; ! mthat->output = &sonar_rawoutput; ! mthat->usage = &sonar_usage; ! mthat->getprivs = &sonar_getprivs; ! mthat->dropprivs = &sonar_dropprivs; ! mthat->find_target = &sonar_find_target; // no targets yet ;) ! mthat->vectors = NULL; ! mthat->num_targets = 0; ! mthat->num_ports = 0; } *************** *** 158,162 **** } ! while((opt = getopt_long(argc, argv, "v::qrfd:c:s:i:o:p:w:t:h:be:?", optionsTable, &opt_ind)) >= 0) { --- 158,162 ---- } ! while((opt = getopt_long(argc, argv, "v::qrfld:c:s:i:o:p:w:t:h:be:?", optionsTable, &opt_ind)) >= 0) { *************** *** 164,167 **** --- 164,168 ---- switch (opt) { + /* select a plugin */ case 's': plugin = (char *) optarg; *************** *** 338,341 **** --- 339,346 ---- mthis.opts.iVerbose); break; + case 'l': + sonar_opt_pluginlist(); + exit(0); + break; case 'q': mthis.opts.iVerbose = -1; |
From: Jacob F. <ph...@us...> - 2004-04-09 15:54:56
|
Update of /cvsroot/autosec/sonar/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16085 Modified Files: rfc793.c Log Message: Minor changes Index: rfc793.c =================================================================== RCS file: /cvsroot/autosec/sonar/plugins/rfc793.c,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** rfc793.c 8 Apr 2004 21:08:30 -0000 1.45 --- rfc793.c 9 Apr 2004 15:41:36 -0000 1.46 *************** *** 313,318 **** mthis->output(" \tsrcprt: set TCP source port\n"); mthis->output(" \tprog: set command line to execute if host(s) is/are online\n"); ! mthis->output(" If no port is specified, this will scan *all* ports\n"); ! mthis->output(" in /etc/services\n"); mthis->output(" Example: sonar -sA,ttl=64,srcprt=53,prog=\"echo hi\" target.example.com:80/24\n"); } --- 313,317 ---- mthis->output(" \tsrcprt: set TCP source port\n"); mthis->output(" \tprog: set command line to execute if host(s) is/are online\n"); ! mthis->output(" If no port is specified, this will scan *all* ports in /etc/services\n"); mthis->output(" Example: sonar -sA,ttl=64,srcprt=53,prog=\"echo hi\" target.example.com:80/24\n"); } |
From: red0x <re...@us...> - 2004-04-09 15:39:53
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13147/src Modified Files: log.c Log Message: Removed an include line that was commented Index: log.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/log.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** log.c 28 Feb 2004 12:43:40 -0000 1.7 --- log.c 9 Apr 2004 15:26:33 -0000 1.8 *************** *** 18,22 **** #include <syslog.h> #include "sonar.h" - /*#include "plugin.h"*/ #include "log.h" --- 18,21 ---- |
From: Jacob F. <ph...@us...> - 2004-04-09 07:17:20
|
Update of /cvsroot/autosec/sonar/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17126 Modified Files: plugin.c plugin.h Log Message: Fixed formatting, moved some magic numbers Index: plugin.c =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.c,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** plugin.c 8 Apr 2004 21:11:48 -0000 1.32 --- plugin.c 9 Apr 2004 07:03:28 -0000 1.33 *************** *** 68,78 **** /// Number of input plugins unsigned long int num_inp, ! /// number of output plugins ! num_out, ! /// number of network plugins ! num_net; /** @name Plugin API Internals ! * These are behind the scenes functions that your plugins, * nor you, should ever need to call. * Do not call these functions! --- 68,78 ---- /// Number of input plugins unsigned long int num_inp, ! /// number of output plugins ! num_out, ! /// number of network plugins ! num_net; /** @name Plugin API Internals ! * These are behind the scenes functions that neither your plugins * nor you, should ever need to call. * Do not call these functions! *************** *** 89,96 **** static int inline plugin_ready() { ! // are they all defined? ! if(!input_list || !output_list || !network_list) ! return 0; ! return 1; } --- 89,96 ---- static int inline plugin_ready() { ! // are they all defined? ! if(!input_list || !output_list || !network_list) ! return 0; ! return 1; } *************** *** 104,109 **** static void inline plugin_init(plugin_list_t * plugin_list) { ! // set the plugin to NULL ! plugin_list->plug = NULL; plugin_list->handle = NULL; memset(input_buf, 0, MAX_INP * sizeof(uint32_t)); --- 104,109 ---- static void inline plugin_init(plugin_list_t * plugin_list) { ! // set the plugin to NULL ! plugin_list->plug = NULL; plugin_list->handle = NULL; memset(input_buf, 0, MAX_INP * sizeof(uint32_t)); *************** *** 117,123 **** static int inline plugin_newid() { ! return (unsigned long int) ++first_pid; /* (first_pid += ((unsigned int) ! (200.0 * rand() / ! (RAND_MAX + 64.0))));*/ } --- 117,122 ---- static int inline plugin_newid() { ! return (unsigned long int) ++first_pid; ! /* (first_pid += ((unsigned int)(200.0 * rand() / (RAND_MAX + 64.0))));*/ } *************** *** 141,168 **** int plugin_start(sonar_t * mthis) { ! if(!input_list) ! { ! err_sys("Input Array not Initialized: %s line %d", __FILE__, ! __LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&input_list[0]); ! if(!output_list) ! { ! err_sys("Output Array not Initialized: %s line %d", ! __FILE__, __LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&output_list[0]); ! if(!network_list) ! { ! err_sys("Network Array not Initialized: %s line %d", ! __FILE__, __LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&network_list[0]); ! first_pid = 0; ! num_inp = num_out = num_net = 0; ! return PLUGIN_OK; } --- 140,164 ---- int plugin_start(sonar_t * mthis) { ! if(!input_list) ! { ! err_sys("Input Array not Initialized: %s line %d", __FILE__, __LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&input_list[0]); ! if(!output_list) ! { ! err_sys("Output Array not Initialized: %s line %d", __FILE__, __LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&output_list[0]); ! if(!network_list) ! { ! err_sys("Network Array not Initialized: %s line %d", __FILE__,__LINE__); ! return PLUGIN_ERROR; ! } ! plugin_init(&network_list[0]); ! first_pid = 0; ! num_inp = num_out = num_net = 0; ! return PLUGIN_OK; } *************** *** 175,183 **** { #ifdef DEBUG ! err_msg("plugin_end();"); #endif ! first_pid = 0; ! num_inp = num_out = num_net = 0; ! return PLUGIN_OK; } --- 171,179 ---- { #ifdef DEBUG ! err_msg("plugin_end();"); #endif ! first_pid = 0; ! num_inp = num_out = num_net = 0; ! return PLUGIN_OK; } *************** *** 191,349 **** int plugin_loadall(sonar_t * mthis) { ! /* directory to search defined as PLUGINDIR */ ! DIR *dir; ! lt_dlhandle plugin; ! void *(*plugin_init) (void *); ! struct stat *my_buf; ! /* try to get the owner and mode of sonar */ ! if((my_buf = get_stats(mthis->my_name)) == NULL) ! err_sys("could not stat %s", mthis->my_name); ! log_write(LOG_DBUG, " opendir(%s);\n", PLUGINDIR); ! dir = opendir(PLUGINDIR); ! if(dir) { ! struct dirent *entry; ! log_write(LOG_DBUG, " readdir(%p);\n", dir); ! while((entry = readdir(dir)) != NULL) { ! char str[1024]; ! struct stat stat_buf; ! int len = strlen(entry->d_name); ! log_write(LOG_DBUG, " found %s\n", entry->d_name); ! /* all plugins must have this in their names, at the ! beginning */ ! if(len < strlen("libsonar")) ! continue; ! /* this code filters out other libraries ! needed once we went libtool */ ! if(strncmp(entry->d_name, "libsonar", ! strlen("libsonar")) != 0) ! continue; /* not the one */ ! if((entry->d_name[len - 3] == '.') && ! (entry->d_name[len - 2] == 's') && ! (entry->d_name[len - 1] == 'o')) ! { ! /* found it */ ! memset(str, 0, 1024); ! snprintf(str, 1023, "%s/%s", PLUGINDIR, ! entry->d_name); ! /* check permissions */ ! /* XXX: lock, no interrupts to avoid race */ ! log_write(LOG_DBUG, " stat(%s, %p);\n", str, ! &stat_buf); ! if(stat(str, &stat_buf) < 0) ! err_sys("could not stat %s", str); ! if(stat_buf.st_mode &= S_IWOTH) ! { ! log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s is world " ! "writtable! not loading!", str); ! continue; ! } ! if(stat_buf.st_uid != my_buf->st_uid) ! { ! /* if they are owned by root, its ok */ ! if(stat_buf.st_uid != 0) ! { ! log_write(LOG_CONSOLE | ! LOG_SLOG, ! "CRITICAL: %s owned by " ! "someone else (%d, not " ! "%d)! not loading!", ! str, stat_buf.st_uid, ! my_buf->st_uid); ! continue; ! } ! } ! /* XXX: unlock */ ! /* end check */ ! lt_dlinit(); ! log_write(LOG_DBUG," lt_dlopen(%s); => ",str); ! if((plugin = lt_dlopen(str)) == NULL) ! { ! char *dl_error_msg = ! (char *) lt_dlerror(); ! log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, ! "could not load %s: %s\n", ! str, dl_error_msg); ! continue; ! } ! log_write(LOG_DBUG, " %p (ok)\n", plugin); ! log_write(LOG_DBUG, ! " lt_dlsym(%p, \"plugin_init\"); => ", ! plugin); ! plugin_init = ! (void *(*)(void *)) lt_dlsym(plugin, ! "plugin_init"); ! if(plugin_init != NULL) ! { ! plugin_t *plug; ! log_write(LOG_DBUG, ! " %p (ok)\n", plugin_init); ! log_write(LOG_DBUG, ! " plugin_init(%p) => ", ! &mthis); ! plug = (plugin_t *) ! plugin_init(mthis); ! if(!plug) ! { ! log_write(LOG_DBUG, ! " FAILED!\n"); ! log_write(LOG_CONSOLE | ! LOG_SLOG, ! " Could not load " ! "%s:\nplugin_init " ! "failed\n", str); ! } ! else ! { ! log_write(LOG_DBUG, ! " %p (ok)\n", plug); ! /* only support from version 6 ! on up */ ! if(plug->version > API_VER || ! plug->version < 6) ! { ! log_write(LOG_CONSOLE | ! LOG_SLOG, " Warning: Plugin \"%s\" wanted an unsupported api, version \'%d\', not loading\n", plug->shortname, plug->version); ! lt_dlclose(plugin); ! continue; ! } ! log_write(LOG_DBUG, ! " plugin_add(%d, %p, " ! "%p, %p);\n", plug, ! plug->type, plug, mthis, ! plugin); ! plugin_add(plug->type, plug, ! mthis, plugin); ! } ! } ! else ! { ! char *dl_error_msg = ! (char *) lt_dlerror(); ! log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, ! " could not load plugin_init " ! "in %s:\n%s\n", str, ! dl_error_msg); ! } } } } ! #ifdef CLOSEDIR_VOID ! closedir(dir); #else ! if(closedir(dir) < 0) ! err_ret("closedir failure"); #endif ! return PLUGIN_OK; } --- 187,326 ---- int plugin_loadall(sonar_t * mthis) { ! /* directory to search defined as PLUGINDIR */ ! DIR *dir; ! lt_dlhandle plugin; ! void *(*plugin_init) (void *); ! struct stat *my_buf; ! /* try to get the owner and mode of sonar */ ! if((my_buf = get_stats(mthis->my_name)) == NULL) ! err_sys("could not stat %s", mthis->my_name); ! log_write(LOG_DBUG, " opendir(%s);\n", PLUGINDIR); ! dir = opendir(PLUGINDIR); ! if(dir) ! { ! struct dirent *entry; ! log_write(LOG_DBUG, " readdir(%p);\n", dir); ! ! while((entry = readdir(dir)) != NULL) { ! char str[1024]; ! struct stat stat_buf; ! int len = strlen(entry->d_name); ! log_write(LOG_DBUG, " found %s\n", entry->d_name); ! /* all plugins must have this in their names, at the ! beginning */ ! if(len < strlen(PLUGIN_HEADER)) ! continue; ! /* this code filters out other libraries ! needed once we went libtool */ ! if(strncmp(entry->d_name, PLUGIN_HEADER, ! strlen(PLUGIN_HEADER)) != 0) ! continue; /* not the one */ ! if((entry->d_name[len - 3] == '.') && ! (entry->d_name[len - 2] == 's') && ! (entry->d_name[len - 1] == 'o')) ! { ! /* found it */ ! memset(str, 0, 1024); ! snprintf(str, 1023, "%s/%s", PLUGINDIR, entry->d_name); ! /* check permissions */ ! /* XXX: lock, no interrupts to avoid race */ ! log_write(LOG_DBUG, " stat(%s, %p);\n", str, &stat_buf); ! ! if(stat(str, &stat_buf) < 0) ! err_sys("could not stat %s", str); ! ! /* check if the file is world writable */ ! if(stat_buf.st_mode & S_IWOTH) { + log_write(LOG_CONSOLE | LOG_SLOG, + "CRITICAL: %s is world writable! not loading!", str); + continue; + } ! /* check if we own the file */ ! if(stat_buf.st_uid != my_buf->st_uid) ! { ! /* if they are owned by root, its ok */ ! if(stat_buf.st_uid != 0) ! { ! log_write(LOG_CONSOLE | LOG_SLOG, ! "CRITICAL: %s owned by someone else (%d, not %d)! " ! "not loading!", ! str, stat_buf.st_uid, my_buf->st_uid); ! continue; ! } ! } ! /* XXX: unlock */ ! /* end check */ ! lt_dlinit(); ! log_write(LOG_DBUG," lt_dlopen(%s); => ",str); ! ! if((plugin = lt_dlopen(str)) == NULL) ! { ! char *dl_error_msg = (char *) lt_dlerror(); ! log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG, ! "could not load %s: %s\n", str, dl_error_msg); ! continue; ! } ! log_write(LOG_DBUG, " %p (ok)\n", plugin); ! log_write(LOG_DBUG, " lt_dlsym(%p, \"plugin_init\"); => ", ! plugin); ! plugin_init = (void *(*)(void *)) lt_dlsym(plugin, ! "plugin_init"); ! if(plugin_init != NULL) ! { ! plugin_t *plug; ! log_write(LOG_DBUG, " %p (ok)\n", plugin_init); ! log_write(LOG_DBUG, " plugin_init(%p) => ", &mthis); ! plug = (plugin_t *) plugin_init(mthis); ! if(!plug) ! { ! log_write(LOG_DBUG, " FAILED!\n"); ! log_write(LOG_CONSOLE | LOG_SLOG," Could not load " ! "%s:\nplugin_init failed\n", str); ! } ! else ! { ! log_write(LOG_DBUG, " %p (ok)\n", plug); ! /* only support from version API_SUPPORT on up */ ! if(plug->version > API_VER || ! plug->version < API_SUPPORT) ! { ! log_write(LOG_CONSOLE | LOG_SLOG, ! " Warning: Plugin \"%s\" wanted an unsupported" ! " api, version \'%d\', not loading\n", ! plug->shortname, plug->version); ! lt_dlclose(plugin); ! continue; } + log_write(LOG_DBUG, " plugin_add(%d, %p, %p, %p);\n", + plug, plug->type, plug, mthis, plugin); + plugin_add(plug->type, plug, mthis, plugin); + } } + else + { + char *dl_error_msg = (char *) lt_dlerror(); + log_write(LOG_DBUG, " FAILED!\n"); + log_write(LOG_CONSOLE | LOG_SLOG, " could not load " + "plugin_init in %s:\n%s\n", str, dl_error_msg); + } + } } ! } ! #ifdef CLOSEDIR_VOID ! closedir(dir); #else ! if(closedir(dir) < 0) ! err_ret("closedir failure"); #endif ! return PLUGIN_OK; } *************** *** 355,443 **** int plugin_killall(void) { ! int err = PLUGIN_OK; log_write(LOG_DBUG, " plugin_killall();\n"); ! ! //get all input, output, network plugins ! //call the plugin_destroy function ! for(; num_inp > 0; num_inp--) { ! int my_err; ! assert(input_list[num_inp - 1].plug != NULL); ! assert(input_list[num_inp - 1].plug->plugin_destroy != NULL); ! //if plugin is also an output plugin, let that call its destroy ! //function ! if(!(input_list[num_inp - 1].plug->type & OUTPUT_PLUGIN)) ! { ! log_write(LOG_DBUG, " unloading %s\n", ! input_list[num_inp - 1].plug->shortname); ! log_write(LOG_DBUG, ! " input_list[%d].plug->plugin_destroy();\n", ! num_inp - 1); ! if((my_err = ! input_list[num_inp - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) ! { ! log_write(LOG_DBUG, " plugin not unloaded\n"); ! err = my_err; ! } ! input_list[num_inp - 1].plug = NULL; ! lt_dlclose(input_list[num_inp - 1].handle); ! } } ! for(; num_out > 0; num_out--) ! { ! int my_err; ! assert(output_list[num_out - 1].plug != NULL); ! assert(output_list[num_out - 1].plug->plugin_destroy != NULL); ! assert(output_list[num_out - 1].plug->plugin_close != NULL); ! //if plugin is also a network plugin, let that call it destroy ! //function ! if(!(output_list[num_out - 1].plug->type & NETWORK_PLUGIN)) ! { ! log_write(LOG_DBUG, " unloading %s\n", ! output_list[num_out - 1].plug->shortname); ! log_write(LOG_DBUG, ! " output_list[%d].plug->plugin_destroy();\n", ! num_out - 1); ! if(output_list[num_out -1].plug->ready) ! output_list[num_out - ! 1].plug->plugin_close(); ! if((my_err = ! output_list[num_out - ! 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) ! { ! log_write(LOG_DBUG, " plugin not unloaded"); ! err = my_err; ! } ! output_list[num_out - 1].plug = NULL; ! lt_dlclose(output_list[num_out - 1].handle); ! } } ! for(; num_net > 0; num_net--) { ! int my_err; ! assert(network_list[num_net - 1].plug != NULL); ! assert(network_list[num_net - 1].plug->plugin_destroy != ! NULL); ! log_write(LOG_DBUG, " unloading %s\n", ! network_list[num_net - 1].plug->shortname); ! log_write(LOG_DBUG, ! " network_list[%d].plug->plugin_destroy();\n", ! num_net - 1); ! if((my_err = ! network_list[num_net - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) ! { ! log_write(LOG_DBUG, " plugin not unloaded\n"); ! err = my_err; ! } ! network_list[num_net - 1].plug = NULL; ! lt_dlclose(network_list[num_net - 1].handle); } ! lt_dlexit(); ! return err; } --- 332,409 ---- int plugin_killall(void) { ! int err = PLUGIN_OK; log_write(LOG_DBUG, " plugin_killall();\n"); ! ! //get all input, output, network plugins ! //call the plugin_destroy function ! for(; num_inp > 0; num_inp--) ! { ! int my_err; ! assert(input_list[num_inp - 1].plug != NULL); ! assert(input_list[num_inp - 1].plug->plugin_destroy != NULL); ! //if plugin is also an output plugin, let that call its destroy function ! if(!(input_list[num_inp - 1].plug->type & OUTPUT_PLUGIN)) { ! log_write(LOG_DBUG, " unloading %s\n", ! input_list[num_inp - 1].plug->shortname); ! log_write(LOG_DBUG, " input_list[%d].plug->plugin_destroy();\n", ! num_inp - 1); ! if((my_err = input_list[num_inp - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) ! { ! log_write(LOG_DBUG, " plugin not unloaded\n"); ! err = my_err; ! } ! input_list[num_inp - 1].plug = NULL; ! lt_dlclose(input_list[num_inp - 1].handle); } ! } ! for(; num_out > 0; num_out--) ! { ! int my_err; ! assert(output_list[num_out - 1].plug != NULL); ! assert(output_list[num_out - 1].plug->plugin_destroy != NULL); ! assert(output_list[num_out - 1].plug->plugin_close != NULL); ! //if plugin is also a network plugin, let that call it destroy function ! if(!(output_list[num_out - 1].plug->type & NETWORK_PLUGIN)) ! { ! log_write(LOG_DBUG, " unloading %s\n", ! output_list[num_out - 1].plug->shortname); ! log_write(LOG_DBUG, " output_list[%d].plug->plugin_destroy();\n", ! num_out - 1); ! if(output_list[num_out -1].plug->ready) ! output_list[num_out - 1].plug->plugin_close(); ! if((my_err = output_list[num_out - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) ! { ! log_write(LOG_DBUG, " plugin not unloaded"); ! err = my_err; ! } ! output_list[num_out - 1].plug = NULL; ! lt_dlclose(output_list[num_out - 1].handle); } ! } ! for(; num_net > 0; num_net--) ! { ! int my_err; ! assert(network_list[num_net - 1].plug != NULL); ! assert(network_list[num_net - 1].plug->plugin_destroy != NULL); ! log_write(LOG_DBUG, " unloading %s\n", ! network_list[num_net - 1].plug->shortname); ! log_write(LOG_DBUG, " network_list[%d].plug->plugin_destroy();\n", ! num_net - 1); ! if((my_err = network_list[num_net - 1].plug->plugin_destroy()) != ! PLUGIN_UNLOADED) { ! log_write(LOG_DBUG, " plugin not unloaded\n"); ! err = my_err; } ! network_list[num_net - 1].plug = NULL; ! lt_dlclose(network_list[num_net - 1].handle); ! } ! lt_dlexit(); ! return err; } *************** *** 445,449 **** * @fn plugin_add(int type, plugin_t *p_data, sonar_t *mthis, void *hptr) * Add plugin to proper plugin_list ! * @param type Plugin type (ex, for input and output, it would be INPUT_PLUGIN | OUTPUT_PLUGIN * @param p_data Pointer to filled plugin_t structure * @param mthis Pointer to a filled sonar_t structure --- 411,416 ---- * @fn plugin_add(int type, plugin_t *p_data, sonar_t *mthis, void *hptr) * Add plugin to proper plugin_list ! * @param type Plugin type (ex, for input and output, it would be INPUT_PLUGIN ! * | OUTPUT_PLUGIN * @param p_data Pointer to filled plugin_t structure * @param mthis Pointer to a filled sonar_t structure *************** *** 453,462 **** static int plugin_add(int type, plugin_t * p_data, sonar_t * mthis, void *hptr) { ! if(!plugin_ready()) ! { ! log_write(LOG_CONSOLE | LOG_SLOG, ! "plugin_add: plugins not ready"); ! return PLUGIN_ERROR; ! } assert(p_data != NULL); --- 420,428 ---- static int plugin_add(int type, plugin_t * p_data, sonar_t * mthis, void *hptr) { ! if(!plugin_ready()) ! { ! log_write(LOG_CONSOLE | LOG_SLOG, "plugin_add: plugins not ready"); ! return PLUGIN_ERROR; ! } assert(p_data != NULL); *************** *** 464,516 **** assert(hptr != NULL); ! if(type & INPUT_PLUGIN) { ! plugin_init(&(input_list[num_inp])); ! ! input_list[num_inp].plug = p_data; ! input_list[num_inp].handle = hptr; ! input_list[num_inp].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, ! " input_list[%d].plug->pluginID = %d\n", num_inp, ! input_list[num_inp].plug->pluginID); ! num_inp++; ! if(num_inp > MAX_INP) ! { ! err_quit("TOO MANY INPUT PLUGINS, ABORTING!"); ! } } ! if(type & OUTPUT_PLUGIN) ! { ! plugin_init(&(output_list[num_out])); ! output_list[num_out].plug = p_data; ! output_list[num_out].handle = hptr; ! output_list[num_out].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, ! " output_list[%d].plug->pluginID = %d\n", num_out, ! output_list[num_out].plug->pluginID); ! num_out++; ! if(num_out > MAX_OUT) ! { ! err_quit("TOO MANY OUTPUT PLUGINS, ABORTING..."); ! } ! } ! if(type & NETWORK_PLUGIN) { ! plugin_init(&(network_list[num_net])); ! network_list[num_net].plug = p_data; ! network_list[num_net].handle = hptr; ! network_list[num_net].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, ! " network_list[%d].plug->pluginID = %d\n", num_net, ! network_list[num_net].plug->pluginID); ! num_net++; ! if(num_net > MAX_NET) ! { ! err_quit("TOO MANY NETWORK PLUGINS, ABORTING..."); ! } } ! return PLUGIN_OK; } --- 430,478 ---- assert(hptr != NULL); ! if(type & INPUT_PLUGIN) ! { ! plugin_init(&(input_list[num_inp])); ! input_list[num_inp].plug = p_data; ! input_list[num_inp].handle = hptr; ! input_list[num_inp].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " input_list[%d].plug->pluginID = %d\n", num_inp, ! input_list[num_inp].plug->pluginID); ! num_inp++; ! if(num_inp > MAX_INP) { ! err_quit("TOO MANY INPUT PLUGINS, ABORTING!"); } ! } ! if(type & OUTPUT_PLUGIN) ! { ! plugin_init(&(output_list[num_out])); ! output_list[num_out].plug = p_data; ! output_list[num_out].handle = hptr; ! output_list[num_out].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " output_list[%d].plug->pluginID = %d\n", num_out, ! output_list[num_out].plug->pluginID); ! num_out++; ! if(num_out > MAX_OUT) { ! err_quit("TOO MANY OUTPUT PLUGINS, ABORTING..."); ! } ! } ! if(type & NETWORK_PLUGIN) ! { ! plugin_init(&(network_list[num_net])); ! network_list[num_net].plug = p_data; ! network_list[num_net].handle = hptr; ! network_list[num_net].plug->pluginID = plugin_newid(); ! log_write(LOG_DBUG, " network_list[%d].plug->pluginID = %d\n", num_net, ! network_list[num_net].plug->pluginID); ! num_net++; ! if(num_net > MAX_NET) ! { ! err_quit("TOO MANY NETWORK PLUGINS, ABORTING..."); } ! } ! return PLUGIN_OK; } *************** *** 531,570 **** void plugin_status_hook(void) { ! unsigned int plug; ! //get all input, output, network plugins ! //call the plugin_status function ! for(plug = 0; plug < num_inp; plug++) { ! { ! assert(input_list[plug].plug != NULL); ! assert(input_list[plug].plug->plugin_status != NULL); ! } ! // each plugin has access to sonar's output function ! // so dont worry about output ! input_list[plug].plug->plugin_status(); } ! for(plug = 0; plug < num_out; plug++) { ! { ! assert(output_list[plug].plug != NULL); ! assert(output_list[plug].plug->plugin_status != NULL); ! } ! // each plugin has access to sonar's output function ! // so dont worry about output ! output_list[plug].plug->plugin_status(); } ! for(plug = 0; plug < num_net; plug++) { ! { ! assert(network_list[plug].plug != NULL); ! assert(network_list[plug].plug->plugin_status != ! NULL); ! } ! // each plugin has access to sonar's output function ! // so dont worry about output ! network_list[plug].plug->plugin_status(); } ! return; } --- 493,531 ---- void plugin_status_hook(void) { ! unsigned int plug; ! //get all input, output, network plugins ! //call the plugin_status function ! for(plug = 0; plug < num_inp; plug++) ! { { ! assert(input_list[plug].plug != NULL); ! assert(input_list[plug].plug->plugin_status != NULL); } ! // each plugin has access to sonar's output function so dont worry ! // about output ! input_list[plug].plug->plugin_status(); ! } ! for(plug = 0; plug < num_out; plug++) ! { { ! assert(output_list[plug].plug != NULL); ! assert(output_list[plug].plug->plugin_status != NULL); } ! // each plugin has access to sonar's output function so dont worry ! // about output ! output_list[plug].plug->plugin_status(); ! } ! for(plug = 0; plug < num_net; plug++) ! { { ! assert(network_list[plug].plug != NULL); ! assert(network_list[plug].plug->plugin_status != NULL); } ! // each plugin has access to sonar's output function ! // so dont worry about output ! network_list[plug].plug->plugin_status(); ! } ! return; } *************** *** 577,603 **** void plugin_message_hook(char *msg, va_list * ap) { ! unsigned int plug; ! int err_val = 0; ! //get all output plugins ! //call the plugin_output function ! for(plug = 0; plug < num_out; plug++) { ! { ! assert(output_list[plug].plug != NULL); ! assert(output_list[plug].plug->type & OUTPUT_PLUGIN); ! assert(output_list[plug].plug->plugin_output != NULL); ! } ! if(output_list[plug].plug->ready == true) ! { ! err_val = ! output_list[plug].plug->plugin_output(msg, ! ap); ! if(err_val < 0) ! err_msg("error: %d, output plugin error", ! err_val); ! } } ! return; } --- 538,561 ---- void plugin_message_hook(char *msg, va_list * ap) { ! unsigned int plug; ! int err_val = 0; ! //get all output plugins ! //call the plugin_output function ! for(plug = 0; plug < num_out; plug++) ! { { ! assert(output_list[plug].plug != NULL); ! assert(output_list[plug].plug->type & OUTPUT_PLUGIN); ! assert(output_list[plug].plug->plugin_output != NULL); } ! if(output_list[plug].plug->ready == true) ! { ! err_val = output_list[plug].plug->plugin_output(msg, ap); ! if(err_val < 0) ! err_msg("error: %d, output plugin error", err_val); ! } ! } ! return; } Index: plugin.h =================================================================== RCS file: /cvsroot/autosec/sonar/src/plugin.h,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** plugin.h 8 Apr 2004 21:42:50 -0000 1.41 --- plugin.h 9 Apr 2004 07:03:28 -0000 1.42 *************** *** 30,33 **** --- 30,35 ---- #define DEFAULT_TIMEOUT 5000 #define API_VER 6 + #define API_SUPPORT 6 + #define PLUGIN_HEADER "libsonar" /** \name Error and Success Values |
From: <no...@so...> - 2004-04-08 23:43:10
|
The following bug has been CLOSED ======================================================================= http://autosec.sourceforge.net/helpDesk/mantis/view_bug_page.php?f_id=0000043 ======================================================================= Reporter: red0x Handler: red0x ======================================================================= Project: sonar Bug ID: 0000043 Category: Bugs Reproducibility: always Severity: feature Priority: normal Status: closed ======================================================================= Date Submitted: 12-05-03 14:26 PST Last Modified: 04-08-04 16:43 PDT ======================================================================= Summary: Parallel scanning broken Description: Scanning with two different types in parallel is broken. ======================================================================= ----------------------------------------------------------------------- red0x - 02-02-04 18:04 PST ----------------------------------------------------------------------- CVS code seems to address this pretty well, however, the ACK scan (rfc793.c) still breaks the parallelism of our scanning. ----------------------------------------------------------------------- red0x - 02-28-04 04:44 PST ----------------------------------------------------------------------- I'm going to wait until the options structure is updated to address this issue. I am leaving the bug assigned to me, but open. ----------------------------------------------------------------------- red0x - 04-08-04 16:13 PDT ----------------------------------------------------------------------- CVS fix. Should work for 1.2.2. ----------------------------------------------------------------------- red0x - 04-08-04 16:43 PDT ----------------------------------------------------------------------- works in CVS. |