Centralized Logging With Syslog-Ng and Sec: Leon Towns-Von Stauber, Intelius Linuxfest Northwest, April 2010
Centralized Logging With Syslog-Ng and Sec: Leon Towns-Von Stauber, Intelius Linuxfest Northwest, April 2010
2
Introduction
This talk describes an infrastructure that provides:
– Aggregation of system logs from many UNIX hosts
and other network devices
– Automated analysis of logged events
3
Introduction
The benefits of centralized log aggregation and analysis
include:
– Log reduction and correlation reduce the workload
associated with viewing logs, making regular review
feasible
– Regular review of logs gives sysadmins a better feel
for the computing environment, allows them to spot
anomalies more readily
– Automated analysis and reporting provides early
warning of unusual and possibly problematic events
– Relaying log messages to a secure loghost makes
them immune to tampering by a local intruder, permits
later forensic analysis
4
Legal Notices
This presentation Copyright © 2008-2010 Leon Towns-von
Stauber. All rights reserved.
Trademark notices
– syslog-ng™ is a trademark of BalaBit IT Security. See
http://www.balabit.com/trademarks/.
– Other trademarks are the property of their respective
owners.
5
Introduction - Logging Environment
Loghost
– HP ProLiant DL360 G5
• Two quad-core 2.33-GHz 64-bit Intel Xeon CPUs
• 16 GB RAM
• Two Gigabit Ethernet interfaces (1 used)
• Two 146-GB disks, RAID 1 => 136-GB boot volume
• Fifteen 146-GB disks, RAID 5 => 1.9 TB for log data
– Red Hat Enterprise Linux 4.6
– syslog-ng 2.0.9, SEC 2.4.2
• This host placed in service May 2008, previous
server in November 2007
6
Introduction - Logging Environment
Clients
– About 320 Red Hat Enterprise Linux hosts
– Over 80 networking devices: F5 BIG-IP load
balancers, Juniper NetScreen firewalls and SSL-VPN
concentrators, Cisco, Juniper, and Nortel switches,
Cisco wireless controllers
7
Introduction - Logging Environment
9
Example Issues
Example Issue - Hardware problems
Loose fan
Mar 4 09:37:26 host1.intelius.com hpasmlited: WARNING: System Fans Not Redundant (Location Power Supply)
Mar 4 09:37:36 host1.intelius.com hpasmlited: NOTICE: System Fans Not Redundant (Location Power Supply) has
been repaired
Mar 4 09:55:50 host1.intelius.com hpasmlited: WARNING: System Fans Not Redundant (Location Power Supply)
Mar 4 09:56:00 host1.intelius.com hpasmlited: NOTICE: System Fans Not Redundant (Location Power Supply) has
been repaired
Broken fan
Apr 2 10:00:11 host2.intelius.com hpasmlited: CRITICAL: Fan Failure (Fan 2, Location CPU)
Apr 2 10:00:11 host2.intelius.com hpasmlited: WARNING: System Fans Not Redundant (Location CPU)
Apr 2 10:00:21 host2.intelius.com hpasmlited: NOTICE: Fan Failure (Fan 2, Location CPU) has been repaired
Apr 2 10:00:21 host2.intelius.com hpasmlited: NOTICE: System Fans Not Redundant (Location CPU) has been
repaired
Apr 2 10:39:13 host2.intelius.com hpasmlited: CRITICAL: Fan Failure (Fan 2, Location CPU)
Apr 2 10:39:13 host2.intelius.com hpasmlited: WARNING: System Fans Not Redundant (Location CPU)
11
Example Issue - Orphaned crontabs
crond complaining about root.cfsaved
Jan 21 16:31:01 host5.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
Jan 21 16:31:01 host7.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
Jan 21 16:31:01 host3.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
Jan 21 16:31:01 host4.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
Jan 21 16:31:01 host1.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
Jan 21 16:31:01 host2.intelius.com crond: (root.cfsaved) ORPHAN (no passwd entry)
12
Example Issue - xinetd won’t start
Recurring messages
Jan 21 17:00:08 host4.intelius.com cfengine:host4: Executing shell command: /etc/
init.d/xinetd start;/sbin/chkconfig xinetd on
Jan 21 17:00:08 host4.intelius.com cfengine:host4: (Done with /etc/init.d/xinetd
start;/sbin/chkconfig xinetd on)
Problem in /etc/sysconfig/network
– Changed
• NETWORKING=YES
– to
• NETWORKING=yes
– Who knew that was case-sensitive?
13
Example Issue - DHCP misconfiguration
Errors from dhcpd
Apr 7 12:56:34 host1.intelius.com dhcpd: /etc/dhcpd/172.27.4.conf line 153: expecting numeric value.
Apr 7 12:56:34 host1.intelius.com dhcpd: hardware ethernet 00:b0:c7:82:3u:
Apr 7 12:56:34 host1.intelius.com dhcpd: ^
Apr 7 12:56:34 host1.intelius.com dhcpd: /etc/dhcpd/172.27.4.conf line 158: expecting numeric value.
Apr 7 12:56:34 host1.intelius.com dhcpd: /etc/dhcpd.conf line 17: /etc/dhcpd/172.27.4.conf: bad parse.
Apr 7 12:56:34 host1.intelius.com dhcpd: include "/etc/dhcpd/172.27.4.conf"
Apr 7 12:56:34 host1.intelius.com dhcpd: ^
Apr 7 12:56:34 host1.intelius.com dhcpd: Configuration file errors encountered -- exiting
14
Example Issue - NTP problems
Time not synced very well on some hosts, as indicated by
weekly cron jobs running off schedule
This rule suppresses logs associated with weekly syslogd
restart, if they’re within 10 secs of scheduled time of 04:02
type=suppress
desc=Syslogd restart after regular log rotation
ptype=regexp
pattern=04:02:0\d [\w.-]+ syslogd [\d.]+: restart\.
15
Example Issue - NTP problems
Variety of fixes
– Resetting clock
– Starting ntpd
– Updating zoneinfo files
– Relinking /etc/localtime
– Replacing /etc/ntp.conf to use correct servers
16
Example Issue - DNS probes
Lots of DNS zone transfer attempts on our external
nameservers from a variety of sources
Dec 4 17:08:50 MULTIPLE-HOSTS named: PROBE from 12.108.127.137: zone transfer '125.94.64.in-addr.arpa'
denied
Dec 4 17:08:52 MULTIPLE-HOSTS named: PROBE from 208.117.131.116: zone transfer 'intelius.com' denied
Dec 4 17:08:52 MULTIPLE-HOSTS named: PROBE from 129.24.211.26: zone transfer 'intelius.com' denied
Dec 4 17:08:52 MULTIPLE-HOSTS named: PROBE from 142.150.238.13: zone transfer 'intelius.com' denied
Dec 4 17:08:53 MULTIPLE-HOSTS named: PROBE from 131.246.191.41: zone transfer 'intelius.com' denied
17
syslog-ng
syslog-ng - Intro
syslog-ng is a replacement for UNIX syslogd, started by
Balázs Scheider in 1998
– Now also offered in a commercial version by BalaBit
– http://www.balabit.com/network-security/syslog-ng/
– Central Logging for Unix
• http://sial.org/talks/central-logging/
This talk is based on version 2.0.9
– Current versions are 2.0.10, 3.0.6, and 3.1.1
19
syslog-ng - Client Setup
Clients continue to use stock syslogd
– They require only one configuration change
/etc/syslog.conf
– Send all logs to loghost
• *.debug @loghost
– Here’s the full config file used on our Linux hosts:
*.info;mail.none;authpriv.none;cron.none! /var/log/messages
authpriv.*! ! ! ! ! ! ! ! ! ! /var/log/secure
local7.*! ! ! ! ! ! ! ! ! ! ! /var/log/boot.log
*.emerg! ! ! ! ! ! ! ! ! ! ! *
*.debug! ! ! ! ! ! ! ! ! ! ! @loghost
20
syslog-ng - Server Setup
Dedicated account for use by syslog-ng
– syslog:x:514:514::/mnt0/syslog:/bin/false
– Locked password
– Group is used by those who need to view logs
After compiling, installed under /usr/local/
Created init script
Disabled syslogd
21
syslog-ng - Server Setup
All the log files are under /mnt0/syslog/
– The complete record for the day is all
– The working files used by SEC for regular updates are
net.tmp and unix.tmp
• These files go away when a regular update is sent
out
– syslog-ng-filtered logs are in byfac/ and byapp/
• Some handy symlinks are in bylnk/, to help
remember what the various local facilities
(local1, local2, etc.) are used for
– SEC-filtered logs are in sec/
– Rotated log files are in archive/ 22
syslog-ng - Client Setup
-rw-r--r-- 1 syslog syslog 388844629 2008-04-18 16:38 all
drwxr-sr-x 6 syslog syslog 4096 2007-11-30 15:03 archive
drwxr-sr-x 2 syslog syslog 4096 2008-04-13 23:50 byapp
drwxr-sr-x 2 syslog syslog 4096 2008-04-13 23:52 byfac
drwxr-sr-x 2 syslog syslog 4096 2008-02-25 16:44 bylnk
-rw-r--r-- 1 root syslog 206 2008-04-18 16:09 net.tmp
drwxr-xr-x 2 syslog syslog 4096 2008-04-14 16:29 sec
-rw-r--r-- 1 root syslog 1448 2008-04-18 16:22 unix.tmp
Contents of /mnt0/syslog/ 23
syslog-ng - Client Setup
byapp:
total 336
-rw-r--r-- 1 syslog syslog 299657 2008-04-24 09:38 emerg
-rw-r--r-- 1 syslog syslog 34988 2008-04-24 10:11 su
byfac:
total 1863780
-rw-r--r-- 1 syslog syslog 6060090 2008-04-24 10:25 auth
-rw-r--r-- 1 syslog syslog 254037293 2008-04-24 10:25 authpriv
-rw-r--r-- 1 syslog syslog 33953953 2008-04-24 10:25 cron
-rw-r--r-- 1 syslog syslog 80001833 2008-04-24 10:25 daemon
-rw-r--r-- 1 syslog syslog 2682950 2008-04-24 09:34 kern
-rw-r--r-- 1 syslog syslog 641499016 2008-04-24 10:25 local0
-rw-r--r-- 1 syslog syslog 28625 2008-04-23 23:50 local1
-rw-r--r-- 1 syslog syslog 948894 2008-04-24 10:23 local3
-rw-r--r-- 1 syslog syslog 990184 2008-04-24 10:25 local4
-rw-r--r-- 1 syslog syslog 228 2008-04-21 10:24 local5
-rw-r--r-- 1 syslog syslog 44242940 2008-04-24 10:25 local6
-rw-r--r-- 1 syslog syslog 139737 2008-04-24 09:54 local7
-rw-r--r-- 1 syslog syslog 840311651 2008-04-24 10:25 mail
-rw-r--r-- 1 syslog syslog 344949 2008-04-24 10:20 syslog
-rw-r--r-- 1 syslog syslog 1311198 2008-04-24 10:24 user
Contents of /mnt0/syslog/ 24
syslog-ng - Client Setup
bylnk:
total 0
lrwxrwxrwx 1 root syslog 15 2007-12-14 12:04 boot -> ../byfac/local7
lrwxrwxrwx 1 root syslog 15 2007-11-30 14:21 cisco -> ../byfac/local7
lrwxrwxrwx 1 root syslog 15 2007-12-19 15:05 named -> ../byfac/local4
lrwxrwxrwx 1 root syslog 13 2007-12-03 13:58 netbackup -> ../byfac/user
lrwxrwxrwx 1 root syslog 15 2007-11-30 14:22 netscreen -> ../byfac/local0
lrwxrwxrwx 1 root syslog 15 2007-11-30 14:19 rsyncd -> ../byfac/local3
lrwxrwxrwx 1 root syslog 15 2007-11-30 14:18 sec -> ../byfac/local1
lrwxrwxrwx 1 root syslog 15 2008-02-25 16:44 slapd -> ../byfac/local4
lrwxrwxrwx 1 root syslog 15 2008-02-22 15:05 snmpd -> ../byfac/local5
lrwxrwxrwx 1 root syslog 17 2007-12-03 10:32 sudo -> ../byfac/authpriv
Contents of /mnt0/syslog/ 25
syslog-ng - Config File
Config file is /usr/local/etc/syslog-ng.conf
The config file has 5 kinds of statements
– General options
– Sources and destinations
– Filters
– Log statements, where you direct messages from
sources to destinations through filters
I use this configuration for rough filtering and message
routing, and to launch SEC processes for further, finer-
grained parsing
– Also, SEC can’t filter based on facility or severity
unless they’re included in the message text, so
syslog-ng is useful for that 26
syslog-ng - Config File
Options
options {
! group("syslog");
! perm(0644);
! create_dirs(yes);
! dir_group("syslog");
! dir_perm(0755);
! use_fqdn(yes);
! chain_hostnames(no);
! dns_cache_expire(21600);
! dns_cache_size(2000);
! log_fifo_size(200000);
};
29
syslog-ng - Config File
Here’s the first log statement
log { source(s_all); destination(d_all); };
30
syslog-ng - Config File
Here’s the first log statement
log { source(s_all); destination(d_all); };
31
syslog-ng - Config File
The second log statement
log { source(s_all); destination(d_fac); };
32
syslog-ng - Config File
One more example, with a simple filter attached
log { source(s_all); filter(f_emerg); destination(d_emerg); };
– Destination
destination d_emerg! { file("/mnt0/syslog/byapp/emerg"
! ! ! template("$R_DATE $HOST $MSG\n")
! ! ! template_escape(no));
! ! ! program("`/usr/local/bin/secStart emerg`"
! ! ! template("$R_DATE $HOST $MSG\n")
! ! ! template_escape(no)); };
34
syslog-ng - Performance
Loghost Syslog Metrics
24,000,000
21,000,000
18,000,000
11/11/08
McColo shutdown
Categorized Messages Per Day
15,000,000
12,000,000
9,000,000
6,000,000
3,000,000
weekly periodicity
0
11/07! 12/07! 1/08! 2/08! 3/08! 4/08! 5/08! 6/08! 7/08! 8/08! 9/08! 10/08! 11/08! 12/08! 1/09! 2/09! 3/09! 4/09
Firewall Firewall
BIG-IP BIG-IP
Email Email
nrpe nrpe
cron cron
sshd sshd
dhcpd dhcpd
80,000,000
70,000,000
60,000,000
Categorized Messages Per Day
50,000,000
40,000,000
11/11/08
McColo shutdown
30,000,000
20,000,000
10,000,000
weekly periodicity
0
11/07! 1/08! 3/08! 5/08! 7/08! 9/08! 11/08! 1/09! 3/09! 5/09! 7/09! 9/09! 11/09! 1/10! 3/10
Firewall Firewall
BIG-IP BIG-IP
Email Email
nrpe nrpe
cron cron
sshd sshd
dhcpd dhcpd
39
SEC - Intro
#!/bin/sh
#
# secStart - Print SEC command line with default options.
usage () {
! echo "usage:!$progname config
progname=`basename $0`
[ $# -eq 1 ] || usage
41
SEC - Configuration
An SEC configuration is composed of multi-line stanzas, or
rule definitions, with each line containing a key and value
Keys include:
– type - Type of rule (examples later)
– desc - Textual description of rule
– ptype - Type of pattern (typically regexp)
– pattern - String or Perl-style regular expression
used to match log message
– context - Apply rule only when named context in
effect
– action - What to do when rule is matched
– continue - After this rule, continue or stop (default) 42
SEC - Configuration
Rule types used in the examples
– suppress - Simple rule to toss messages that match
– single - If message matches, take immediate action
– singlewithsuppress - If message matches, take
immediate action, but then ignore similar messages
for a time given by value of window
– singlewiththreshold - Take action if the number
of matching messages within a given window reaches
a threshold
– pairwithwindow - Specify 2 patterns; when 1st
pattern matches, watch for 2nd pattern to appear
within window; if it does, execute action; if not,
execute different action 43
SEC - Configuration
For each message, rules are processed one at a time, in
order, until the message matches a rule without
continue=takenext, or end-of-file is reached
A few examples from the main config follow
44
SEC - Configuration Example: main
Lots of simple suppress rules like these:
type=suppress
ptype=regexp
pattern=last message repeated
type=suppress
desc=SEC logs
ptype=regexp
pattern=loghost\.intelius\.com sec\[\d+\]: SEC \(Simple Event Correlator\)
type=suppress
desc=xinetd startup/reconfig msgs
ptype=regexp
pattern=xinetd\[\d+\]: (Reading included configuration file:|removing|Exiting\.\.\.|
xinetd Version|Started working: \d+ available service|Starting reconfiguration|
Swapping defaults|readjusting service)
type=suppress
desc=CRON
ptype=regexp
pattern=(CROND|crond|crond\(pam_unix\)|\/USR\/SBIN\/CRON|\/usr\/sbin\/cron)\[\d+\]:
\(\w+\) (CMD|RELOAD|STARTUP)
45
SEC - Configuration Example: main
Correlation of boot logs
##############
# BOOT RULES #
##############
type=single
desc=Create boot context
ptype=regexp
pattern=(\w+\s+\d+\s+\d+:\d+:\d+) ([\w.-]+) kernel: Linux version
action=create BOOT_$2 180; create CFENGINE_BOOT_$2 900;\
create NTP_STOPSTART_$2 900; event 0 UNDUPED:$1 $2 starting up...
context=!BOOT_$2
47
SEC - Configuration Example: main
Correlation of boot logs
– Into this
Apr 24 14:22:50 host2.intelius.com starting up...
:-)
48
SEC - Configuration Example: main
Example Sendmail correlation
– Sendmail events are split across multiple messages
type=single
desc=Save from address
ptype=regexp
pattern=\w+\s+\d+\s+\d+:\d+:\d+ ([\w.-]+) (sendmail|.+sm-mta)\[\d+\]: (\w+): from=
(\S+),
action=create MAIL_$1_$3 360; fill MAIL_$1_$3 $4
49
SEC - Configuration Example: main
Example Sendmail correlation
type=single
desc=Mail receiver unknown
ptype=regexp
pattern=(\w+\s+\d+\s+\d+:\d+:\d+) ([\w.-]+) (sendmail|.+sm-mta)\[\d+\]: (\w+): to=
(\S+),.+(relay=[^,]+),.+stat=(User unknown|Service unavailable)
action=copy MAIL_$2_$4 %from;\
event 0 PARSED:$1 $2 sendmail: User $5 unknown from %from ($6)
context=MAIL_$2_$4
50
SEC - Configuration Example: main
Example Sendmail correlation
– Along with some suppression rules, they turn this
Apr 25 04:59:46 host5.intelius.com sendmail[14779]: m3PBxkhp014779: Authentication-
Warning: host5.intelius.com: apache set sender to [email protected] using -f
Apr 25 04:59:46 host5.intelius.com sendmail[14779]: m3PBxkhp014779:
[email protected], size=738, class=0, nrcpts=1,
msgid=<[email protected]>, relay=apache@localhost
Apr 25 04:59:46 host5.intelius.com sendmail[14782]: m3PBxkHF014782:
from=<[email protected]>, size=1076, class=0, nrcpts=1,
msgid=<[email protected]>, proto=ESMTP, daemon=MTA,
relay=localhost.localdomain [127.0.0.1]
Apr 25 04:59:46 host5.intelius.com sendmail[14779]: m3PBxkhp014779:
[email protected], [email protected] (48/48), delay=00:00:00,
xdelay=00:00:00, mailer=relay, pri=30738, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0,
stat=Sent (m3PBxkHF014782 Message accepted for delivery)
Apr 25 04:59:53 host5.intelius.com sendmail[14784]: m3PBxkHF014782:
to=<[email protected]>, delay=00:00:07, xdelay=00:00:07, mailer=esmtp, pri=121076,
relay=mx2.yandex.ru. [213.180.223.88], dsn=5.1.1, stat=User unknown
Apr 25 04:59:53 host5.intelius.com sendmail[14784]: m3PBxkHF014782: m3PBxrHF014784:
DSN: User unknown
51
SEC - Configuration Example: main
Example Sendmail correlation
– Into this
Apr 25 04:59:53 host5.intelius.com sendmail: User <[email protected]> unknown from
<[email protected]> (relay=mx2.yandex.ru. [213.180.223.88])
52
SEC - Configuration Example: main
Example Sendmail correlation
– Remember that order of rules can make a difference
– For instance, these suppress rules appear after all
the correlations of mail message logs are complete
# Suppress this after reducing mail errors, otherwise we can miss second message
# of pair.
type=suppress
desc=Deferred email
ptype=regexp
pattern=(sendmail|.+sm-mta).+stat=Deferred
# Suppress this after reducing mail errors, otherwise we can miss second message
# of pair when there are multiple addressees and some are successful.
type=suppress
desc=Successful email
ptype=regexp
pattern=(sendmail|.+sm-mta).+msgid=
54
SEC - Configuration Example: main
Another Sendmail correlation: Load average
– Turns this
Apr 17 17:54:19 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 48
Apr 17 17:54:34 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 54
Apr 17 17:54:49 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 58
Apr 17 17:55:04 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 57
Apr 17 17:55:19 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 57
Apr 17 17:55:34 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 58
Apr 17 17:55:49 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 54
Apr 17 17:56:04 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 52
Apr 17 17:56:19 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 51
Apr 17 17:56:34 host3.intelius.com sendmail[2942]: rejecting connections on daemon MTA: load average: 48
– Into this
Apr 17 17:54:19 host3.intelius.com sendmail: load average: 40+
Apr 17 17:54:34 host3.intelius.com sendmail: load average: 50+
55
SEC - Configuration Example: main
Detecting syslog-ng overflow
– syslog-ng logs statistics on messages it’s processed
• Via internal source, every 10 minutes by default
• Messages look like this
Apr 25 08:40:05 loghost.intelius.com syslog-ng[16671]: Log statistics;
dropped='program(`/usr/local/bin/secStart emerg`)=0', dropped='program(`/usr/local/
bin/secStart main`)=0', dropped='program(`/usr/local/bin/secStart nmi`)=0',
dropped='program(`/usr/local/bin/secStart outbound`)=0', processed='center(queued)
=2419827', processed='center(received)=1205703', processed='destination(d_emerg)
=3204', processed='destination(d_fac)=1205703', processed='destination(d_all)
=1205703', processed='destination(d_su)=13', processed='destination(d_nmi)=0',
processed='destination(d_outbound)=5204', processed='destination(d_int)=0',
processed='source(s_int)=0', processed='source(s_all)=1205703'
type=singlewithsuppress
desc=Dropped $2 messages
ptype=regexp
pattern=(\w+\s+\d+\s+\d+:\d+:\d+ loghost\.intelius\.com syslog-ng)\[\d+\]: Log
statistics\;.+dropped=\'program\(\`\/usr\/local\/bin\/secStart main\`\)=(\d+)\'
action=event 0 PARSED:$1: dropped $2 messages
window=3600
57
SEC - Configuration Example: main
Email sent when overflow detected
type=single
desc=syslog-ng overwhelmed
continue=takenext
ptype=regexp
pattern=^UNDUPED:(\w+\s+\d+\s+\d+:\d+:\d+ log1\.tuk\.intelius\.com syslog-ng:
dropped \d+ messages)
action=pipe '$1' /bin/mail -s "SEC: syslog-ng message buffer overrun" %a
58
SEC - Configuration Example: main
Password expiration notification
– This rule sends email to a user when his or her
password is about to expire
# Window is set to a day, which basically means as long as SEC/syslog-ng go
# without restarting (and thus, resetting this correlation).
type=singlewithsuppress
desc=The user account "$2" on $1 $3. If you use this account, please log in and
change your password.
continue=takenext
ptype=regexp
pattern=^UNDUPED:\w+\s+\d+\s+\d+:\d+:\d+ ([\w.-]+) sshd: password for user (\w+)
(will expire in \d+ days)
action=pipe '%s' /usr/bin/mail -s "SEC: Your account on $1 $3" [email protected]
window=86400
59
SEC - Emailed Reports
sendLogs
– cron calls sendLogs to issue regular reports of
anomalous events
0 0,6-18 * * 1-5 /usr/local/bin/sendLogs
0 0,6,12,18 * * 0,6 /usr/local/bin/sendLogs
# Temporary holiday schedule
#0 0,6,12,18 * * * /usr/local/bin/sendLogs
60
SEC - Emailed Reports
#!/bin/sh
#
# sendLogs - Email accumulated reduced logs to admins.
#
PATH=/bin:/usr/bin
LOG_DIR=/mnt0/syslog
62
SEC - Conclusion
By far, the bulk of the setup work is creating the log filters
– The process is iterative
• Let logs through, figure out what you don’t care to
see, create filters to suppress or correlate
• Repeat until volume is bearable
• Learn your Perl-style regular expressions
Missing important log messages is bad
– But having so many to look at that you ignore them
can be just as bad
63
SEC - Conclusion
How effective is the log reduction and correlation at
highlighting anomalous events?
– Let’s look at how many messages make it to the
regular reports
Current volume is about 4.4 million messages per day (not
counting NetScreen traffic logs)
– Lately, an average of 300 messages per day (~13 per
hour) make it to the regular emailed reports
• Pretty stable over last year; down from ~26/hr 11/08,
~36/hr 5/08
• Reduced to about 0.007% of total
–99.993% of messages filtered or correlated
64
SEC - Conclusion
Loghost Syslog Metrics
60,000
50,000
40,000
SEC-Processed Messages Per Day
10/3/08
SMTP RCPT floods
start
30,000
1/15/09-1/16/09
SMTP RCPT floods
are back
20,000
11/11/08
McColo shutdown
10,000
0
11/07! 1/08! 3/08! 5/08! 7/08! 9/08! 11/08! 1/09! 3/09! 5/09! 7/09! 9/09! 11/09! 1/10! 3/10
66
SEC - Conclusion
Juniper NetScreen firewall traffic logs are processed by a
specialized SEC config, bypassing the main config
– Only one singlewithsuppress rule that rewrites
the logs into a simpler format
– Current volume: 55-75 million msgs/day
– This SEC process uses nearly 200 MB and ~65% of a
CPU
67
Centralized Logging
with syslog-ng and
SEC
Leon Towns-von Stauber, Intelius
LinuxFest Northwest, April 2010
http://www.occam.com/