pax_global_header00006660000000000000000000000064115345733420014521gustar00rootroot0000000000000052 comment=07663a75b1363e7754b8fd530a24e4590f148fdb snoopy-1.8.0/000077500000000000000000000000001153457334200130565ustar00rootroot00000000000000snoopy-1.8.0/COPYING000066400000000000000000000431271153457334200141200ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy 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. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. snoopy-1.8.0/ChangeLog000066400000000000000000000052051153457334200146320ustar00rootroot00000000000000------------------------------------------------------------------------------- SnoopyLogger ChangeLog ------------------------------------------------------------------------------- 2011-03-06 - Version 1.8.0 --------------------------- o Feature: syslog facility is now configurable o Feature: syslog level is now configurable o Feature: external filter support available o Feature: single path prefix filtering available 2010-10-10 - Version 1.7.10 --------------------------- o Fixed bug with long command lines (thanks Luis Fernando Muñoz Mejías) 2010-10-10 - Version 1.7.6 --------------------------- o Quick fix of buggy patch applied in previous release 2010-10-10 - Version 1.7.5 --------------------------- o Build for 64bit machines and destdir support for RPMs (Aldemira) o Fixed 1-byte memory leak introduced in previous release 2010-09-24 - Version 1.7.2 --------------------------- o Logs current tty (initial patch provided by Aldemira user on SourceForge) 2010-02-11 - Version 1.6.1 --------------------------- o Logs current working directory 2010-02-09 - Version 1.6.0 --------------------------- o Uses autotools now o Changed installation procedure o Rewritten logging function to avoid memory leaks o No more segfaults on 64bit platforms o Program name and argument lengths limited to 4096 bytes o Many thanks to otheus for supplying a patch on SourceForge one and a half years ago, it helped tremendously. 2010-02-09 - Version 1.5.0 --------------------------- o Updated to compile and work without segfaults on 32bit and 64bit platforms o Project maintenance taken over by Bostjan Skufca Sun December 10 - Version 1.3 ------------------------------ o Altered logging mechanism for performance o Added new way of logging (can choose) o Added an integrity check (optional) Wed October 25 - Version 1.2a ----------------------------- o ROOT_ONLY behavior now works again, thanks to adrian.head@bytecomm.com.au for notifying us! Thu October 10 - Version 1.2 ----------------------------- o Fixed small bug with rather adverse side effects. Thu August 17 - Version 1.1 ---------------------------- o Added support for execv(). Although execv() calls execve() [as described in the man page], execv() calls don't seem to log. They now do. Will investigate this issue a bit further. o Made logging code modular, as to accomodate for the extra overload that execv() brought. Thu August 3 - Version 1.00 ---------------------------- o Cleaned up the codebase a bit o Added the output of username and sid (PID of the login shell) to the logged output o Fixed install.sh to be compatible with older (v1.0) bash shells snoopy-1.8.0/Makefile.in000066400000000000000000000033031153457334200151220ustar00rootroot00000000000000# Makefile for snoopy # $Id: Makefile.in 21 2010-02-11 19:58:54Z bostjanskufca $ CC=@CC@ CFLAGS=@CFLAGS@ @DEFS@ LIBS=-ldl LDFLAGS=@LDFLAGS@ @LIBS@ prefix=@prefix@ exec_prefix=@exec_prefix@ LIBDIR=@libdir@ SNOOPY_EXCLUDE_PREFIX=@SNOOPY_EXCLUDE_PREFIX@ SNOOPY_EXTERNAL_FILTER=@SNOOPY_EXTERNAL_FILTER@ SNOOPY_FILTER_COMMAND=@SNOOPY_FILTER_COMMAND@ SNOOPY_FILTER_COMMAND_DIR=`dirname @SNOOPY_FILTER_COMMAND@` all: snoopy.so detect snoopy.so: snoopy.c snoopy.h config.h $(CC) $(CFLAGS) -shared -O3 -fomit-frame-pointer -fPIC snoopy.c -osnoopy.so $(LDFLAGS) detect: detect.c $(CC) detect.c -odetect $(LDFLAGS) install: all ifeq ($(SNOOPY_EXTERNAL_FILTER), yes) install -m 755 -d $(SNOOPY_EXCLUDE_PREFIX) install -m 755 -d $(SNOOPY_FILTER_COMMAND_DIR) if test ! -e $(SNOOPY_EXCLUDE_PREFIX)/grep; then \ ln -s /usr/bin/grep $(SNOOPY_EXCLUDE_PREFIX)/grep; \ fi if test ! -e $(SNOOPY_EXCLUDE_PREFIX)/sed; then \ ln -s /usr/bin/sed $(SNOOPY_EXCLUDE_PREFIX)/sed; \ fi if test ! -e $(SNOOPY_FILTER_COMMAND); then \ install -m 755 snoopy-filter.sh $(SNOOPY_FILTER_COMMAND); \ fi @echo @echo Your external filter is installed here: @echo $(SNOOPY_FILTER_COMMAND) @echo endif install -m 755 -d $(DESTDIR)$(LIBDIR) install -m 755 snoopy.so $(DESTDIR)$(LIBDIR)/snoopy.so @echo -e "\nSnoopy shared library installed in $(DESTDIR)$(LIBDIR)." @echo -e "Run 'make enable' to actually enable snoopy logging.\n" enable: ./enable.sh $(DESTDIR)$(LIBDIR) clean: rm -f detect snoopy.so rm -f snoopy-filter.sh rm -f contrib/sles/snoopy.spec distclean: clean rm -f autoscan.log config.h config.log config.status rm -rf autom4te.cache rm -f Makefile realclean: distclean rm -f configure configure.scan snoopy-1.8.0/README000066400000000000000000000042321153457334200137370ustar00rootroot00000000000000 ------------------------------------------------------------------------------ Snoopy 1.8 By: bostjan@a2o.si marius@umich.edu mbm@linux.com ------------------------------------------------------------------------------ D E S C R I P T I O N Snoopy is designed to aid the taks of a sysadmin by providing a log of commands executed. Snoopy is completely transparent to the user and applications it hooks in as a library providing a wrapper around calls to execve() calls. Logging is done via syslogd and written to authpriv allowing secure offsite logging of activity, generally the authpriv is stored as /var/log/auth.log. N O T E execv() calls are now explicitly logged. Although, according to the man page for execv(), it is supposed to call execve(). To this date the reason why execv() calls weren't being logged is unknown, but we are working to find out why. U S A G E Snoopy is able to log all users or just root, this functionality is configured at compile through the snoopy.h header, #define ROOT_ONLY 1 will restrict logging to root activities. Installation is as follows: # If you have pulled snoopy from GIT, you must run autoconf first: autoheader autoconf # Check configuration options: ./configure --help # Then continue with normal build procedure: ./configure [OPTIONS] make make install # Then you can actually enable snoopy: make enable Snoopy is placed in /etc/ld.so.preload to trap all occurances of exec, if you wish to monitor only certain applications you can do so through the $LD_PRELOAD environment variable - simply set it to /usr/local/lib/snoopy.so before loading the application. For example: export LD_PRELOAD=/usr/local/lib/snoopy.so lynx http://linux.com/ unset LD_PRELOAD To remove snoopy later, simply edit /etc/ld.so.preload and remove the reference to snoopy.so and delete /usr/local/lib/snoopy.so. O U T P U T The exact location of your snoopy output depends on your syslog configuration. Usually it gets stored in one of the following files: /var/log/auth* /var/log/messages /var/log/secure snoopy-1.8.0/README.filtering000066400000000000000000000022601153457334200157200ustar00rootroot00000000000000-------------------------------------------------------------------------------- Snoopy filtering support - since version 1.8.0 -------------------------------------------------------------------------------- D E S C R I P T I O N Snoopy supports basic prefix filtering and external filtering. These options can be enabled on command line and further customized by modifying external filter script. W A R N I N G W A R N I N G W A R N I N G EXTERNAL FILTER MUST RESIDE IN THE EXCLUDE PREFIX PATH. IT MUST NOT USE ANY PROGRAMS THAT RESIDE OUTSITE THE EXCLUDE PREFIX PATH. DISREGARDING THIS WARNING WILL CAUSE INFINITE LOOPS ON YOUR SYSTEM AND RENDER IT UNUSABLE. YOUR SYSTEM WILL CRASH. There, you have been warned. H O W T O E N A B L E # Enable it with configure option: ./configure --enable-external-filter # Then proceed with normal build. When installing, sample filter # script is installed for you to start with. To get its location, # read the output from 'make install'. make make install F I L T E R S C R I P T Please refer to the filter script for additional information about customization. snoopy-1.8.0/TODO000066400000000000000000000000611153457334200135430ustar00rootroot00000000000000$Id: TODO 5 2010-02-09 20:00:51Z bostjanskufca $ snoopy-1.8.0/config.h.in000066400000000000000000000047721153457334200151130ustar00rootroot00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `dl' library (-ldl). */ #undef HAVE_LIBDL /* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H /* Define to 1 if your system has a GNU libc compatible `malloc' function, and to 0 otherwise. */ #undef HAVE_MALLOC /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYSLOG_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* "http://sourceforge.net/projects/snoopylogger/" */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Enable logging of Current Working Directory */ #undef SNOOPY_CWD_LOGGING /* Prefix to commands excluded from logging */ #undef SNOOPY_EXCLUDE_PREFIX /* Enable external filtering support */ #undef SNOOPY_EXTERNAL_FILTER /* External filter command to use */ #undef SNOOPY_EXTERNAL_FILTER_COMMAND /* Syslog facility to use */ #undef SNOOPY_SYSLOG_FACILITY /* Syslog level to use */ #undef SNOOPY_SYSLOG_LEVEL /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif /* Define to rpl_malloc if the replacement function should be used. */ #undef malloc /* Define to `unsigned int' if does not define. */ #undef size_t snoopy-1.8.0/configure.ac000066400000000000000000000105641153457334200153520ustar00rootroot00000000000000# -*- Autoconf -*- # Process this file with autoconf to produce a configure script. AC_PREREQ([2.63]) AC_INIT([Snoopy Logger], [1.8.0], [http://sourceforge.net/projects/snoopylogger/], [snoopy]) AC_DEFINE(PACKAGE_URL, [], "http://sourceforge.net/projects/snoopylogger/") AC_CONFIG_SRCDIR([config.h.in]) AC_CONFIG_HEADERS([config.h]) # Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_LN_S # Checks for libraries. # FIXME: Replace `main' with a function in `-ldl': AC_CHECK_LIB([dl], [main]) # Checks for header files. AC_CHECK_HEADERS([limits.h stdlib.h string.h syslog.h unistd.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_CHECK_FUNCS([getcwd]) AC_CONFIG_FILES([ Makefile snoopy-filter.sh contrib/sles/snoopy.spec ]) dnl ============================================================================ AC_ARG_ENABLE(cwd-logging, [AC_HELP_STRING( [--disable-cwd-logging], [disable logging of Current Working Directory [default=enabled]] )], [ if test "$enableval" == "yes"; then enable_cwd_logging=yes fi ], [enable_cwd_logging=yes] ) AS_IF([test "x$enable_cwd_logging" == "xyes"], [ AC_DEFINE(SNOOPY_CWD_LOGGING, 1, [Enable logging of Current Working Directory]) ]) dnl ============================================================================ AC_ARG_WITH(exclude-prefix, [AC_HELP_STRING( [--with-exclude-prefix=PREFIX], [prefix to commands excluded from logging. This feature is mainly intended to specify path to commands which are used by external filter so snoopy does not enter infinite loop. WARNING WARNING WARNING: Do not change unless you are absolutely sure you know what you are doing [default=/usr/local/snoopy/bin] ] )], [], [with_exclude_prefix=/usr/local/snoopy/bin] ) AC_DEFINE_UNQUOTED(SNOOPY_EXCLUDE_PREFIX, ["$with_exclude_prefix"], [Prefix to commands excluded from logging]) AC_SUBST(SNOOPY_EXCLUDE_PREFIX, ["$with_exclude_prefix"]) dnl ============================================================================ AC_ARG_ENABLE(external-filter, [AC_HELP_STRING( [--enable-external-filter], [enable external filtering support [default=disabled]] )], [ if test "$enableval" == "yes"; then enable_external_filter=yes fi ], [enable_external_filter=no] ) AS_IF([test "x$enable_external_filter" == "xyes"], [ AC_DEFINE(SNOOPY_EXTERNAL_FILTER, 1, [Enable external filtering support]) ]) AC_SUBST(SNOOPY_EXTERNAL_FILTER, ["$enable_external_filter"]) dnl ============================================================================ AC_ARG_WITH(filter-command, [AC_HELP_STRING( [--with-filter-command=CMD], [external filter command to use. WARNING WARNING WARNING: Do not change unless you are absolutely sure you know what you are doing [default=/usr/local/snoopy/bin/snoopy-filter.sh] ] )], [], [with_filter_command=/usr/local/snoopy/bin/snoopy-filter.sh] ) AS_IF( [test "x$enable_external_filter" == "xyes"], [ AS_IF( [test `echo "$with_filter_command" | grep -c "^$with_exclude_prefix" | cat` == "0"], [AC_ERROR([Invalid option combination: filter command $with_filter_command must match exclude prefix $with_exclude_prefix])] ) AC_DEFINE_UNQUOTED(SNOOPY_EXTERNAL_FILTER_COMMAND, ["$with_filter_command"], [External filter command to use]) ] ) AC_SUBST(SNOOPY_FILTER_COMMAND, ["$with_filter_command"]) dnl ============================================================================ AC_ARG_WITH(syslog-facility, [AC_HELP_STRING( [--with-syslog-facility=FACILITY], [facility to use when logging, check 'man 3 syslog' or 'man openlog' [default=LOG_AUTHPRIV]] )], [], [with_syslog_facility=LOG_AUTHPRIV] ) AC_DEFINE_UNQUOTED(SNOOPY_SYSLOG_FACILITY, [$with_syslog_facility], [Syslog facility to use]) dnl ============================================================================ AC_ARG_WITH(syslog-level, [AC_HELP_STRING( [--with-syslog-level=LEVEL], [facility to use when logging, check 'man 3 syslog' or 'man openlog' [default=LOG_INFO]] )], [], [with_syslog_level=LOG_INFO] ) AC_DEFINE_UNQUOTED(SNOOPY_SYSLOG_LEVEL, [$with_syslog_level], [Syslog level to use]) dnl ============================================================================ AC_OUTPUT snoopy-1.8.0/contrib/000077500000000000000000000000001153457334200145165ustar00rootroot00000000000000snoopy-1.8.0/contrib/sles/000077500000000000000000000000001153457334200154645ustar00rootroot00000000000000snoopy-1.8.0/contrib/sles/snoopy.spec.in000066400000000000000000000022031153457334200202710ustar00rootroot00000000000000%define version @PACKAGE_VERSION@ %define release 1 %define enable 1 Summary: User monitoring and command logging Name: snoopy Version: %{version} Release: %{release} URL: https://sourceforge.net/projects/snoopylogger/ Source: https://downloads.sourceforge.net/project/snoopylogger/snoopy-%{version}.tar.gz Group: Applications/Monitoring BuildRoot: %{_tmppath}/%{name}-buildroot #BuildRequires: readline-devel License: GNU GPL Patch1: %{name}-%{version}_64bit.patch Patch2: %{name}-%{version}_ttyname.patch Packager: Aldemir Akpinar %description Snoopy Logger, logs all the commands issued by local users on the system. It is very useful to track and monitor the users. %prep %setup -q %patch1 %patch2 %build %configure make DESTDIR=%{buildroot} %install rm -rf %{buildroot} make install DESTDIR=%{buildroot} %if %enable install -d -m 755 $RPM_BUILD_ROOT/etc if [ ! -f /etc/ld.so.preload ];then echo "%{_libdir}/snoopy.so" >> $RPM_BUILD_ROOT/etc/ld.so.preload fi %endif %clean rm -rf %{buildroot} #%post %files %defattr(644 root root 755) %doc COPYING ChangeLog README* RELEASES %config /etc/ld.so.preload %{_libdir}/snoopy.so snoopy-1.8.0/detect.c000066400000000000000000000023361153457334200144760ustar00rootroot00000000000000/* detect.c -- simple execve() wrapper detection * $Id: detect.c 5 2010-02-09 20:00:51Z bostjanskufca $ * Copyright (c) 2000 marius@linux.com,mbm@linux.com * * * 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, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include #include #ifndef RTLD_DEFAULT # define RTLD_DEFAULT ((void *) 0) #endif int main(void) { void *handle = dlopen("/lib/libc.so.6", RTLD_LAZY); //simple test to see if the execve in memory matches libc.so.6 if (dlsym(handle, "execve") != dlsym(RTLD_DEFAULT, "execve")) printf("something fishy...\n"); else printf("secure\n"); return 0; } snoopy-1.8.0/dev-scripts/000077500000000000000000000000001153457334200153215ustar00rootroot00000000000000snoopy-1.8.0/dev-scripts/make-release.sh000077500000000000000000000040331153457334200202130ustar00rootroot00000000000000#!/bin/bash ### Check working directory if [ ! -d "dev-scripts" ]; then echo "ERROR: You have to run this script in the root of repository" exit 1 fi ### Check release tag RELEASE_TAG="$1" if [ "x$RELEASE_TAG" == "x" ]; then echo "ERROR: No release tag specified. Please use: $0 X.Y.Z" exit 1 fi ### Check if release tag exists RES=`git tag | grep "^$RELEASE_TAG\$"` if [ "$RES" != "$RELEASE_TAG" ]; then echo "ERROR: Release tag does not exist, please create it with: git tag X.Y.Z" exit 2 fi ### Check for uncommited changes in the current repo #RES=`git diff` #if [ "x$RES" != "x" ]; then # echo "ERROR: Uncommited changes in current working copy. Please commit/stash and try again." # exit 3 #fi ### Paths and filenames DIR_REPO=`pwd` DIR_REPO_PARENT=`dirname $DIR_REPO` DIRNAME_RELEASE="snoopy-$RELEASE_TAG" FILENAME_RELEASE="snoopy-$RELEASE_TAG.tar.gz" DIR_RELEASE="$DIR_REPO_PARENT/$DIRNAME_RELEASE" FILE_RELEASE="$DIR_REPO_PARENT/$DIRNAME_RELEASE.tar.gz" ### Check if release dirs and files do not exists if [ -e $DIR_RELEASE ]; then echo "ERROR: Release directory already exists: $DIR_RELEASE" exit 10 fi if [ -e $FILE_RELEASE ]; then echo "ERROR: Release file already exists: $FILE_RELEASE" exit 11 fi ### Checkout git checkout $RELEASE_TAG ### Check for release tags RES=`cat configure.ac | fgrep $RELEASE_TAG | cat` if [ "x$RES" == "x" ]; then echo "ERROR: Release tag $RELEASE_TAG not found in configure.ac file." exit 20 fi ### Create release directory mkdir -p $DIR_RELEASE && cp -pR $DIR_REPO/* $DIR_RELEASE && cd $DIR_RELEASE && rm -rf dev-scripts && autoheader && autoconf ### Compare configure.ac and configure.ac.generated diff configure.ac configure.ac.generated if [ "$?" != "0" ]; then echo "ERROR: configure.ac and configure.ac.generated differ." exit 40 fi ### Create package cd .. && tar -c -z -f $FILENAME_RELEASE $DIRNAME_RELEASE && rm -rf $DIRNAME_RELEASE ### Check out master branch again cd $DIR_REPO && git checkout master ### Signal success echo "Release complete. File: $FILE_RELEASE" snoopy-1.8.0/dev-scripts/scp-release.sh000077500000000000000000000003431153457334200200630ustar00rootroot00000000000000#!/bin/bash if [ "x$1" == "x" ]; then echo "ERROR: No file specified, please use: $0 file-to-copy-to-sourceforge" exit 1 fi scp $1 bostjanskufca,snoopylogger@frs.sourceforge.net:/home/frs/project/s/sn/snoopylogger/ snoopy-1.8.0/enable.sh000077500000000000000000000020201153457334200146350ustar00rootroot00000000000000#!/bin/sh # A script that enables snoopy logging for system wide installation. # You have to run it as privileged user. # $Id: enable.sh 18 2010-02-10 01:44:14Z bostjanskufca $ ### Where is the library installed? LIBDIR=$1 if [ "x$LIBDIR" == "x" ]; then echo "ERROR: No argument given, libdir expected" exit 1 fi ### Check snoopy installation if [ ! -x $LIBDIR/snoopy.so ]; then echo "ERROR: $LIBDIR/snoopy.so is not installed or is not executable" exit 1 fi ### Check user that is running this script touch /etc/ld.so.preload if [ ! -w /etc/ld.so.preload ]; then echo 'ERROR: /etc/ld.so.preload not writable - are you running this script as a unprivileged user?' exit 1 fi ### Do the actual install if [ `grep -c "^$LIBDIR/snoopy.so" /etc/ld.so.preload` == 0 ]; then echo "$LIBDIR/snoopy.so" >> /etc/ld.so.preload echo "Snoopy enabled in /etc/ld.so.preload. Check syslog messages for output." else echo "Snoopy already enabled in /etc/ld.so.preload. Check syslog messages for output." fi snoopy-1.8.0/install-sh000077500000000000000000000000001153457334200150500ustar00rootroot00000000000000snoopy-1.8.0/snoopy-filter.sh.in000077500000000000000000000015731153457334200166420ustar00rootroot00000000000000#!/bin/sh # # Sample snoopy external filter # # Log message is received as first argument, which is stored in variable $1. # Whatever this script returns is the message that snoopy sends to syslog. # Non-zero exit status will be logged to syslog. # # # WARNING # WARNING This filter should be a standalone executable. # WARNING If it uses external programs, make sure the path to those programs # WARNING was specified in EXCLUDE_PREFIX when ./configuring snoopy. # WARNING # WARNING Otherwise snoopy enters infinite loop which will hang your system. # WARNING # External programs used by this filter SNOOPY_EXCLUDE_PREFIX="@SNOOPY_EXCLUDE_PREFIX@" SNOOPY_GREP="$SNOOPY_EXCLUDE_PREFIX/grep" SNOOPY_SED="$SNOOPY_EXCLUDE_PREFIX/sed" # Here we just output whatever we have received with slight modification if [ "x$1" != "x" ]; then echo "$@" | $SNOOPY_SED -e 's/bash/bush/g' fi snoopy-1.8.0/snoopy.c000066400000000000000000000143611153457334200145560ustar00rootroot00000000000000/* snoopy.c -- execve() logging wrapper * Copyright (c) 2000 marius@linux.com,mbm@linux.com * * $Id: snoopy.c 30 2010-02-13 16:31:16Z bostjanskufca $ * * Part hacked on flight KL 0617, 30,000 ft or so over the Atlantic :) * * 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, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "config.h" #include "snoopy.h" #include #include #include #include #include #include #include #include #define min(a,b) a= logStringSize) break; logString[n++] = ' '; } logString[logStringSize-1] = '\0'; /* Create logMessage */ #if defined(SNOOPY_CWD_LOGGING) getCwdRet = getcwd(cwd, PATH_MAX+1); sprintf(logMessage, "[uid:%d sid:%d tty:%s cwd:%s filename:%s]: %s", getuid(), getsid(0), ttyPath, cwd, filename, logString); #else sprintf(logMessage, "[uid:%d sid:%d tty:%s filename:%s]: %s", getuid(), getsid(0), ttyPath, filename, logString); #endif /* Prepare logging stuff */ openlog("snoopy", LOG_PID, SNOOPY_SYSLOG_FACILITY); /* Filter it */ #if defined(SNOOPY_EXTERNAL_FILTER) filterCommandMaxSize = logMessageMaxSize; filterOutputMaxSize = logMessageMaxSize; filterCommand = malloc(filterCommandMaxSize); filterOutput = malloc(filterOutputMaxSize); /* Check filter command - existance */ fp = fopen(SNOOPY_EXTERNAL_FILTER_COMMAND, "r"); if (fp) { fclose(fp); } else { syslog(LOG_ALERT, "External snoopy filter does not exist: %s", SNOOPY_EXTERNAL_FILTER_COMMAND); goto extFilterEnd; } /* Check filter command - executable */ if (access(SNOOPY_EXTERNAL_FILTER_COMMAND, X_OK)) { syslog(LOG_ALERT, "External snoopy filter is not executable: %s", SNOOPY_EXTERNAL_FILTER_COMMAND); goto extFilterEnd; } /* Construct filter command */ sprintf(filterCommand, "%s '%s'", SNOOPY_EXTERNAL_FILTER_COMMAND, logMessage); /* Execute it */ fp = popen(filterCommand, "r"); if (fp == NULL) { syslog(LOG_ALERT, "Unable to execute external snoopy filter: %s", SNOOPY_EXTERNAL_FILTER_COMMAND); goto extFilterEnd; } /* Read output and close file descriptor */ filterOutputPtr = filterOutput; *filterOutput = '\0'; while (!feof(fp)) { fgets(buffer, bufferSize, fp); if ((strlen(filterOutput) + strlen(buffer)) > filterOutputMaxSize) { syslog(LOG_ALERT, "Snoopy external filter output is too large"); goto extFilterEnd; } strcpy(filterOutputPtr, buffer); filterOutputPtr += strlen(buffer); } /* Finish execution and check exit status */ status = pclose(fp); if (status != 0) { syslog(LOG_ALERT, "External snoopy filter returned non-zero status: %d", status); } /* Move contents to logMessage */ strcpy(logMessage, filterOutput); extFilterEnd: #endif /* defined(SNOOPY_EXTERNAL_FILTER) */ /* Log it */ if (strlen(logMessage) > 0) { syslog(SNOOPY_SYSLOG_LEVEL, "%s", logMessage); } /* Free the logString memory */ free(logString); free(logMessage); #if defined(SNOOPY_EXTERNAL_FILTER) free(filterCommand); free(filterOutput); #endif } int execve(const char *filename, char *const argv[], char *const envp[]) { static int (*func)(const char *, char **, char **); FN(func,int,"execve",(const char *, char **const, char **const)); snoopy_log(filename, argv); return (*func) (filename, (char**) argv, (char **) envp); } int execv(const char *filename, char *const argv[]) { static int (*func)(const char *, char **); FN(func,int,"execv",(const char *, char **const)); snoopy_log(filename, argv); return (*func) (filename, (char **) argv); } snoopy-1.8.0/snoopy.h000066400000000000000000000004471153457334200145630ustar00rootroot00000000000000/* * * $Id: snoopy.h 17 2010-02-10 01:25:39Z bostjanskufca $ * */ /** * SNOOPY_ROOT_ONLY * * Log only the actions running under uid 0, set 1 to enable */ #define SNOOPY_ROOT_ONLY 0 /** * SNOOPY_MAX_ARG_LENGTH * * Maximum size of any argument. */ #define SNOOPY_MAX_ARG_LENGTH 4096