Skip to content

Commit

Permalink
Import legacy release 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bostjan committed May 13, 2015
1 parent fac198a commit 22560c5
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 13 deletions.
12 changes: 10 additions & 2 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
Thu August 3 - Version 1.00
---------------------------
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
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Makefile for snoopy
# $Id: $

CC = gcc
LIBS = -ldl

Expand Down
9 changes: 8 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
------------------------------------------------------------------------------
Snoopy 1.0
Snoopy 1.1
------------------------------------------------------------------------------

[email protected]
Expand All @@ -15,6 +15,13 @@ D E S C R I P T I O N
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
Expand Down
8 changes: 8 additions & 0 deletions TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
o Decrease function-calling overhead by using macros to
replace log().
-> See where else macros could be used.

o Logging of environment (in the case of execve())
-> Would require a change in the logging mechanism

o The inclusion of Verio's parsing code in the snoopy distribution (?)
5 changes: 5 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
#!/bin/sh

#installation script for snoopy (for system wide installs)
#Run as root!
#$Id: $

[ -x snoopy.so ] && {
touch /etc/ld.so.preload
[ -w /etc/ld.so.preload ] && {
Expand Down
43 changes: 34 additions & 9 deletions snoopy.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
/* snoopy.c -- execve() logging wrapper
* Copyright (c) 2000 [email protected],[email protected]
* Version 1.1
* $Id: $
*
* 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
Expand Down Expand Up @@ -30,22 +33,17 @@

#define FN(ptr,type,name,args) ptr = (type (*)args)dlsym (REAL_LIBC, name)

int execve(const char *filename, char **argv, char **envp) {
static int (*func)(const char *, char **, char **);
static int (*guid)(void);
void log(const char *filename, char **argv) {

static char **ptr, *logstring;
static int size = MAX;
static int (*guid)(void);

FN(func,int,"execve",(const char *, char **, char **));
FN(guid,int,"getuid",(void));

ptr = (char **)&argv[1];
logstring = (char *)malloc((size_t *)size);

#if ROOT_ONLY
if ((*guid)() != 0) return (*func) (filename, argv, envp);
#endif


openlog("snoopy", LOG_PID, LOG_AUTHPRIV);

size -= snprintf(logstring, size,"[%s, uid:%d sid:%d]: %s",
Expand All @@ -57,6 +55,33 @@ if ((*guid)() != 0) return (*func) (filename, argv, envp);
syslog(LOG_INFO, "%s", logstring);
free(logstring);
closelog();
}

int execve(const char *filename, char **argv, char **envp) {
static int (*func)(const char *, char **, char **);

FN(func,int,"execve",(const char *, char **, char **));

#if ROOT_ONLY
if ((*guid)() != 0) return (*func) (filename, argv, envp);
#endif

log(filename, argv);

return (*func) (filename, argv, envp);
}

int execv(const char *filename, char **argv) {
static int (*func)(const char *, char **);

FN(func,int,"execv",(const char *, char **));

#if ROOT_ONLY
if ((*guid)() != 0) return (*func) (filename, argv);
#endif

log(filename, argv);

return (*func) (filename, argv);
}

6 changes: 5 additions & 1 deletion snoopy.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Snoopy 1.0
/* Snoopy 1.1
*
* $Id: $
*
*/

/* ROOT_ONLY
* log only the actions running under uid 0, set 1 to enable
Expand Down

0 comments on commit 22560c5

Please sign in to comment.