home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / E-zine / Magazines / crh / freebsd / rootkit / sniffit.0.3.5 / sn_logfile.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-05-27  |  1.9 KB  |  89 lines

  1. /* Sniffit Logfile include file                                           */
  2. /*   - by: Brecht Claerhout                                               */
  3.                      
  4. #include "sn_config.h"
  5.  
  6. #include <stdio.h>
  7. #include <sys/stat.h>
  8. #include <sys/time.h>
  9. #include "sn_defines.h"
  10. #include "sn_structs.h"
  11. #include "sn_logfile.h"
  12.  
  13. extern char Logfile[250];                                /* name of logfile */
  14. extern FILE *LogFILE;                                     /* logfile stream */ 
  15. extern char LOGLEVEL;
  16.       
  17. void logfile_exit (void)         /* at/on_exit closing of logfile */
  18. {
  19. printf("Sniffit Logging session ended.\n");
  20. print_logline("Sniffit session ended.");
  21. fflush(LogFILE);
  22. fclose(LogFILE);
  23. }
  24.  
  25. char *gettime (void)
  26. {
  27. time_t t;
  28. char *tm;
  29.  
  30. time(&t);
  31. tm=ctime(&t);
  32. tm[24]=0;
  33. return tm;
  34. }
  35.  
  36. void print_logline (char *logline)
  37. {
  38. fprintf(LogFILE,"[%s] - %s\n",gettime(),logline);
  39. fflush(LogFILE);
  40. }
  41.  
  42. void print_ftp_user (char *conn, char *user)
  43. {
  44. char line[250];
  45. sprintf(line,"%s: USER [%s]",conn,user);
  46. print_logline (line);
  47. }
  48.  
  49. void print_ftp_pass(char *conn, char *pass)
  50. {
  51. char line[250];
  52. sprintf(line,"%s: PASS [%s]",conn,pass);
  53. print_logline (line);
  54. }
  55.  
  56. void print_login (char *conn, char *login)
  57. {
  58. char line[250];
  59. sprintf(line,"%s: login [%s]",conn,login);
  60. print_logline (line);
  61. }
  62.  
  63. void print_pwd (char *conn, char *pwd)
  64. {
  65. char line[250];
  66. sprintf(line,"%s: password [%s]",conn,pwd);
  67. print_logline (line);
  68. }
  69.  
  70. void print_conn (char *conn, char *msg)
  71. {
  72. char line[250];
  73. sprintf(line,"%s: %s",conn,msg);
  74. print_logline (line);
  75. }
  76.  
  77. void open_logfile (void)
  78. {
  79. if(Logfile[0]==0)       strcpy(Logfile,"sniffit.log");
  80. LogFILE=fopen(Logfile,"a");
  81. if(LogFILE==NULL)
  82.   printf("Sniffit hardattack.. couldn't create/open logfile...\n"), exit(1); 
  83. exit_func(logfile_exit);
  84. fchmod(LogFILE,  S_IWUSR|S_IRUSR);
  85. print_logline("Sniffit session started.");
  86. printf("Sniffit Logging started. (loglevel: %d)\n",LOGLEVEL);
  87. }
  88.  
  89.