| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Parse::Log::Smbd; |
|
2
|
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
51754
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
74
|
|
|
4
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
69
|
|
|
5
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
8
|
|
|
|
2
|
|
|
|
|
160
|
|
|
6
|
2
|
|
|
2
|
|
1881
|
use IO::File; |
|
|
2
|
|
|
|
|
23958
|
|
|
|
2
|
|
|
|
|
425
|
|
|
7
|
2
|
|
|
2
|
|
2107
|
use Devel::CheckOS qw/ os_is die_unsupported /; |
|
|
2
|
|
|
|
|
2354
|
|
|
|
2
|
|
|
|
|
1441
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
die_unsupported() if os_is('MicrosoftWindows'); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Parse::Log::Smbd - parse log.smbd files to fetch usernames and connections to network shares |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.02 |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
This module retrieves users successfully authenticated and connections to SMB/CIFS network shares from Samba C files. |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Parse::Log::Smbd; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $log = Parse::Log::Smbd->new( '/var/log/log.smbd' ); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
my @users = $log->users; |
|
33
|
|
|
|
|
|
|
my @shares = $log->shares; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head2 new |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Creates a new C object, with the intended log filename as argument. |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
|
44
|
1
|
|
|
1
|
1
|
838
|
my ($class, $file) = @_; |
|
45
|
1
|
50
|
|
|
|
4
|
croak "Log filename missing" unless defined $file; |
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
3
|
my $self = {}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
9
|
my $fh = IO::File->new("< $file"); |
|
50
|
1
|
50
|
|
|
|
106
|
croak "Can't read from $file: $!" unless $fh; |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
|
|
2
|
$self->{fh} = $fh; |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
3
|
_parse_log($self); |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
8
|
bless ($self, $class); |
|
57
|
1
|
|
|
|
|
7
|
return $self; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub _parse_log { |
|
61
|
1
|
|
|
1
|
|
2
|
my $self = shift; |
|
62
|
1
|
|
|
|
|
1
|
my $fh = $self->{fh}; |
|
63
|
|
|
|
|
|
|
|
|
64
|
1
|
|
|
|
|
31
|
while (<$fh>) { |
|
65
|
2123
|
100
|
|
|
|
6241
|
if (/authentication for user \[(\w+)\].*?/) { |
|
66
|
153
|
|
|
|
|
155
|
push @{ $self->{users} }, $1; |
|
|
153
|
|
|
|
|
480
|
|
|
67
|
|
|
|
|
|
|
} |
|
68
|
2123
|
100
|
|
|
|
7141
|
if (/connect to service (\w+).*?/) { |
|
69
|
316
|
|
|
|
|
313
|
push @{ $self->{shares} }, $1; |
|
|
316
|
|
|
|
|
4386
|
|
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 users |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Lists users that authenticated successfully to the smbd server. Returns a sorted list of unique usernames. |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub users { |
|
81
|
1
|
|
|
1
|
1
|
808
|
my $self = shift; |
|
82
|
|
|
|
|
|
|
|
|
83
|
1
|
|
|
|
|
2
|
undef my %seen; |
|
84
|
1
|
|
|
|
|
2
|
return sort grep(!$seen{$_}++, @{ $self->{users} }); |
|
|
1
|
|
|
|
|
137
|
|
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 shares |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Lists successful connections to network shares. Returns a sorted list of unique shares. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=cut |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub shares { |
|
94
|
1
|
|
|
1
|
1
|
3
|
my $self = shift; |
|
95
|
|
|
|
|
|
|
|
|
96
|
1
|
|
|
|
|
2
|
undef my %seen; |
|
97
|
1
|
|
|
|
|
3
|
return sort grep(!$seen{$_}++, @{ $self->{shares} }); |
|
|
1
|
|
|
|
|
136
|
|
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 AUTHOR |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Ari Constancio, C<< >> |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 BUGS |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
107
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
|
108
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SUPPORT |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
perldoc Parse::Log::Smbd |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
You can also look for information at: |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=over 4 |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
L |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
L |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
L |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * Search CPAN |
|
134
|
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
L |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=back |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Thanks to the Samba Team (L) for a great software. |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Copyright 2010 Ari Constancio. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
149
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
150
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; # End of Parse::Log::Smbd |