File: pureftpd

package info (click to toggle)
logwatch 5.2.2-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,112 kB
  • ctags: 42
  • sloc: perl: 9,032; sh: 65; makefile: 54
file content (128 lines) | stat: -rwxr-xr-x 4,516 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/perl
##########################################################################
# $Id: pureftpd,v 1.3 2004/02/03 02:45:26 kirk Exp $
##########################################################################
# $Log: pureftpd,v $
# Revision 1.3  2004/02/03 02:45:26  kirk
# Tons of patches, and new 'oidentd' and 'shaperd' filters from
# Pawe? Go?aszewski" <blues@ds.pg.gda.pl>
#
##########################################################################

##########################################################################
# Written & Maintained by Chris Smith (csmith@squiz.net)
##########################################################################

$Detail = $ENV{'LOGWATCH_DETAIL_LEVEL'};
$ShowLogins  = $ENV{'show_logins'};
$ShowLogouts = $ENV{'show_logouts'};
$ShowDataTransfers = $ENV{'show_data_transfers'};
$ShowNewConnections = $ENV{'show_new_connections'};

$PureShutdown = 0;

while (defined($ThisLine = <STDIN>)) {
   if (
      ( $ThisLine =~ /last message repeated/ ) or
      ( $ThisLine =~ /Timeout/) or
      ( $ThisLine =~ /Can't change directory/) or
      ( $ThisLine =~ /pure-ftpd startup( |) succeeded/)
   ) {
      #We don't care about these
   } elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)new connection/i )) {
      $NewConnections{$IP}++;
   } elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)logout/i )) {
      $Logouts{$IP}++;
   } elsif (($IP,$j) = ($ThisLine =~ /\@(.*?)\)(.*?)unable to set up secure anonymous ftp/i )) {
      $SecureAnon{$IP}++;
   } elsif (($IP,$User) = ($ThisLine =~ /\@(.*?)\)\s*\[info\]\s*(.*?) is now logged in/i )) {
      $Logins->{$IP}->{$User}++;
   } elsif (($j,$ConnectionCount,$IP) = ($ThisLine =~ /(.*?)too many connections \((.*?)\) from this ip\: \[(.*?)\]/i )) {
      $TooManyConnections->{$ConnectionCount}->{$IP}++;
   } elsif (($User,$Location,$File,$Direction) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+(.*?)\s+(\w+)\s+/)) {
      $Direction->{$User}->{$Location}->{$File}++;
   } elsif (($User,$Location,$File) = ($ThisLine =~ /\((.*?)\@(.*?)\)\s+\[\w+\]\s+ Deleted ([^ ]+)/)) {
      $Direction = "Deleted";
      $Direction->{$User}->{$Location}->{$File}++;
   } elsif ($ThisLine =~ m/pure-ftpd shutdown( |) succeeded/) {
      $PureShutdown++;
   } else {
      # Report any unmatched entries...
      push @OtherList,$ThisLine;
   }
}

##########################
#

if ($PureShutdown > 0) {
   print "\nPure-ftpd shutdown $PureShutdown Time(s)\n";
}

if ($ShowNewConnections) {
   if (keys %NewConnections) {
      print "\nNew Connections:\n";
      foreach $Line (sort {$a cmp $b} keys %NewConnections) {
         print "\t" . $Line . " - ". $NewConnections{$Line} . " Time(s)\n";
      }
   }
}

if ($ShowLogins) {
   if (keys %{$Logins}) {
      print "\nSuccessful Logins:\n";
      foreach $Line (sort {$a cmp $b} keys %{$Logins}) {
         foreach $Detail (sort {$a cmp $b} keys %{$Logins->{$Line}}) {
            print "\t" . $Detail. " (" . $Line . ") - ". $Logins->{$Line}->{$Detail} . " Time(s)\n";
         }
      }
   }
}

if (keys %{$TooManyConnections}) {
   print "\nToo Many Connections:\n";
   foreach $Line (sort {$a cmp $b} keys %{$TooManyConnections}) {
      foreach $Detail (sort {$a cmp $b} keys %{$TooManyConnections->{$Line}}) {
         print "\t" . $Detail. " (" . $Line . " connections) - ". $TooManyConnections->{$Line}->{$Detail} . " Time(s)\n";
      }
   }
}

if ($ShowDataTransfers) {
   if (keys %{$Direction}) {
      print "\nData Transferred:\n";
      foreach $User (sort {$a cmp $b} keys %{$Direction}) {
         foreach $Location (sort {$a cmp $b} keys %{$Direction->{$User}}) {
            foreach $Filename (sort {$a cmp $b} keys %{$Direction->{$User}->{$Location}}) {
               print "\tUser " . $User . " " . $Direction . " " . $Filename . " from " . $Location . " - ". $Direction->{$User}->{$Location}->{$Filename} . " Time(s)\n";
            }
         }
      }
   }
}

if (keys %SecureAnon) {
   print "\nUnsuccessful Secure Anonymous Connections:\n";
   foreach $Line (sort {$a cmp $b} keys %SecureAnon) {
      print "\t" . $Line . " - ". $SecureAnon{$Line} . " Time(s)\n";
   }
}

if ($ShowLogouts) {
   if (keys %Logouts) {
      print "\nLogouts:\n";
      foreach $Line (sort {$a cmp $b} keys %Logouts) {
         print "\t" . $Line . " - ". $Logouts{$Line} . " Time(s)\n";
      }
   }
}

if (($#OtherList >= 0) and (not $IngoreUnmatched)){
   print "\n**Unmatched Entries**\n";
   print @OtherList;
}

exit(0);

# vi: shiftwidth=3 tabstop=3 et