Archivace eventlogů z Windows NT serverů


Provádět pravidelné kontroly eventlogů na větším množství Windows serverů je z časového hlediska poměrně náročná činnost. V případě že máte na serveru zapnut audit filesystému, nebo logujete tisky jde o velké množství dat, které není možné zkontrolovat. Řešením je sbírat události z jednotlivých Windows eventlogů, ukládat  je v nějakém centrálním úložišti a zde je také prohlížet a kontrolovat. Existují drahé profi nástroje jako např. MOM2005, Tivoli nebo TNG. Vyzkoušel jsem MOM a TNG s výsledkem nevyhovující. Události se ukládají do databáze a při velkých objemech dat pomalé, neustále vyžadující obsluhu, spousty chybových stavů. Pustil jsem se do řešení pro sběr Windows Eventlogů postaveném na UNIX Syslogu spoužitím Sběr klientského software SNARE a severového úložiště FreeBSD – Syslog

Skládá se s klientské části, kterou představuje free software (freeware) SNARE pod GNU Public Licence (GPL). SNARE client je nestažení na <a href=“http://www.intersectalliance.com/“ target=“_blank“>http://www.intersectalliance.com</a> . SW běží jako NT service a hlídá Eventlog a podle filtru odesílá přibývající zprávy jako UDP na portu 514 na server.
Filtr pro odesílání jsem nastavil následovně:

Podle ID:
<em>624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,643,644,645,
646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,
669,670,672,680,10,
</em>Podle typu:
<em>error – any
success,failure,info,warn,error – security policy events,proces events,logon_logoff events
success,failure – reboot events</em>

Toto nastavení lze exportovat rovnou do registry.
<em>[HKEY_LOCAL_MACHINE\SOFTWARE\InterSect Alliance\AuditService\Objective]
„Objective0″=“1 31 32 528,529,530,531,532,533,534,535,536,537,538,539,540,541,542,543,544,545,
546,547,672,673,674,675,676,677,678,680,681,682,683 *** 0 *“
„Objective1″=“1 2 16 10 *** 0 *“
„Objective2″=“0 31 32 592,593,594,595 *** 0 *“
„Objective3″=“2 31 32 624,625,626,627,628,629,630,631,632,633,634,635,636,637,638,639,640,641,642,
643,644,645,646,647,648,649,650,651,652,653,654,655,656,657,658,659,660,661,662,663,664,665,666,667,668,669,670,672,680 *** 0 *“
„Objective4″=“1 24 32 512,513 *** 0 *“
„Objective5″=“3 31 32 516,517,608,609,610,611,612,613,614,615,616,617,618,620,643 *** 0 *“
„Objective6″=“4 4 31 * *** 0 *“
</em>

Filtr si nastavte individuálně podle toho jaké eventy chcete sbírat. Seznam eventů lze získat např.na:
<a href=“http://technet.microsoft.com/en-us/library/cc754424%28WS.10%29.aspx“ target=“_blank“>http://technet.microsoft.com/en-us/library/cc754424%28WS.10%29.aspx</a>

Konfigurace Snare na klientské stanici se provádí z prohlížeče(IE,FF) na http://localhost:6161/, je nutné doplnit jméno sledované stanice(serveru) a serveru kam se odesílají eventy.

<a href=“https://www.pr-software.net/wp-content/uploads/2011/11/snare.gif“><img style=“border: 0pt none;“ src=“https://www.pr-software.net/wp-content/uploads/2011/11/snare.gif“ alt=““ width=“380″ height=“258″ border=“0″ /></a>
<a href=“https://www.pr-software.net/wp-content/uploads/2011/11/snare1.gif“><img style=“border: 0pt none;“ src=“https://www.pr-software.net/wp-content/uploads/2011/11/snare1.gif“ alt=““ width=“380″ height=“223″ border=“0″ /></a>
Serverová část běží na  serveru FreeBSD. Standardní syslog je nahrazen syslog-ng, který poslouchá na portu 514 a příchozí zprávy ukládá do nastaveného adresáře (např, /data/log/).
Instalace:
<strong><em>Pkg_add syslog-ng</em></strong>

V <em>/etc/rc.conf
syslogd_enable=“NO“
syslogd_program=“/usr/local/sbin/syslog-ng“
syslogd_flags=““</em>

Popis syslog-ng:

<a href=“http://www.freebsdwiki.net/index.php/Syslog-NG_Installation“ target=“_blank“>http://www.freebsdwiki.net/index.php/Syslog-NG_Installation</a>

Nastavení syslogu <em>(/usr/local/etc/syslog-ng</em>/):

<em># This sample configuration file is essentially equilivent to the stock
# FreeBSD /etc/syslog.conf file.
# options
options { long_hostnames(off); sync(0); };
# sources
source src { unix-dgram(„/var/run/log“);
unix-dgram(„/var/run/logpriv“ perm(0600));
udp(); internal(); file(„/dev/klog“); };
# destinations
destination messages { file(„/var/log/messages“); };
destination security { file(„/var/log/security“); };
destination authlog { file(„/var/log/authlog“); };
destination maillog { file(„/var/log/maillog“); };
destination lpd-errs { file(„/var/log/lpd-errs“); };
destination xferlog { file(„/var/log/xferlog“); };
destination cron { file(„/var/log/cron“); };
destination debuglog { file(„/var/log/debuglog“); };
destination consolelog { file(„/var/log/consolelog“); };
destination all { file(„/data/log/alllog“); };
destination newscrit { file(„/var/log/newscrit“); };
destination newserr { file(„/var/log/newserr“); };
destination newsnotice { file(„/var/log/newsnotice“); };
destination slip { file(„/var/log/sliplog“); };
destination ppp { file(„/var/log/ppplog“); };
destination console { file(„/dev/console“); };
destination allusers { usertty(„*“); };
destination winevent { file(„/data/log/winevent“); };
#destination loghost { udp(„loghost“ port(514)); };
# log facility filters
filter f_auth { facility(auth); };
filter f_authpriv { facility(authpriv); };
filter f_not_authpriv { not facility(authpriv); };
filter f_console { facility(console); };
filter f_cron { facility(cron); };
filter f_daemon { facility(daemon); };
filter f_ftp { facility(ftp); };
filter f_kern { facility(kern); };
filter f_lpr { facility(lpr); };
filter f_mail { facility(mail); };
filter f_news { facility(news); };
filter f_security { facility(security); };
filter f_user { facility(user); };
filter f_uucp { facility(uucp); };
filter f_local0 { facility(local0); };
filter f_not_local0 { not facility(local0); };
filter f_local1 { facility(local1); };
filter f_local2 { facility(local2); };
filter f_local3 { facility(local3); };
filter f_local4 { facility(local4); };
filter f_local5 { facility(local5); };
filter f_local6 { facility(local6); };
filter f_local7 { facility(local7); };
# log level filters
filter f_emerg { level(emerg); };
filter f_alert { level(alert..emerg); };
filter f_crit { level(crit..emerg); };
filter f_err { level(err..emerg); };
filter f_warning { level(warning..emerg); };
filter f_notice { level(notice..emerg); };
filter f_info { level(info..emerg); };
filter f_debug { level(debug..emerg); };
filter f_is_debug { level(debug); };
filter f_is_warning { level(warning); };
filter f_is_info { level(info); };
# program filters
filter f_ppp { program(„ppp“); };
filter f_slip { program(„startslip“); };
# *.err;kern.warning;auth.notice;mail.crit  /dev/console
log { source(src); filter(f_err); destination(console); };
log { source(src); filter(f_kern); filter(f_warning); destination(console); };
log { source(src); filter(f_auth); filter(f_notice); destination(console); };
log { source(src); filter(f_mail); filter(f_crit); destination(console); };
# *.notice;authpriv.none;kern.debug;lpr.info;mail.crit;news.err /var/log/messages
log { source(src); filter(f_notice); filter(f_not_authpriv); filter(f_not_local0); destination(messages); };
log { source(src); filter(f_kern); filter(f_debug); destination(messages); };
log { source(src); filter(f_lpr); filter(f_info); destination(messages); };
log { source(src); filter(f_mail); filter(f_crit); destination(messages); };
log { source(src); filter(f_news); filter(f_err); destination(messages); };
# security.*      /var/log/security
log { source(src); filter(f_security); filter(f_not_local0); destination(security); };
# auth.info;authpriv.info    /var/log/authlog
log { source(src); filter(f_auth); filter(f_info); destination(authlog); };
log { source(src); filter(f_authpriv); filter(f_info); destination(authlog); };
# mail.info      /var/log/maillog
log { source(src); filter(f_mail); filter(f_info); destination(maillog); };
# lpr.info      /var/log/lpd-errs
log { source(src); filter(f_lpr); filter(f_info); destination(lpd-errs); };
# </em>ftp.info<em>      /var/log/xferlog
log { source(src); filter(f_ftp); filter(f_info); destination(xferlog); };
# cron.*      /var/log/cron
log { source(src); filter(f_cron); destination(cron); };
# *.=debug      /var/log/debuglog
log { source(src); filter(f_is_debug); filter(f_not_local0); destination(debuglog); };
# *.emerg      *
log { source(src); filter(f_emerg); filter(f_not_local0); destination(allusers); };
# uncomment this to log all writes to /dev/console to /var/log/consolelog
# console.info      /var/log/consolelog
#log { source(src); filter(f_console); filter(f_info); destination(consolelog); };
# uncomment this to enable logging of all log messages to /var/log/alllog
# touch /var/log/all.log and chmod it to mode 600 before it will work
# *.*       /var/log/alllog
#log { source(src); destination(all); };
# uncomment this to enable logging to a remote loghost named loghost
# *.*       @loghost
#log { source(src); destination(loghost); };
# uncomment these if you’re running inn
# news.crit      /var/log/newscrit
# news.err      /var/log/newserr
# news.notice      /var/log/newsnotice
#log { source(src); filter(f_news); filter(f_crit); destination(newscrit); };
#log { source(src); filter(f_news); filter(f_err); destination(newserr); };
#log { source(src); filter(f_news); filter(f_notice); destination(newsnotice); };
# !startslip
# *.*       /var/log/sliplog
log { source(src); filter(f_slip); destination(slip); };
# !ppp
# *.*       /var/log/ppplog
log { source(src); filter(f_ppp); destination(ppp); };
# logs from snare winevent
# local0.*
#
log { source(src); filter(f_local0); destination(winevent); };
</em>

Rotace logů je zajištěna utilitou newsyslog, kterou je potřeba nainstalovat. Tato je spouštěna denně z cronu, do <em>/etc/crontab</em> přidat řádek

<em># Rotate log files every hour, if necessary.
0 * * * * root newsyslog</em>

Logy se na serveru drží rok a komprimují se.
Nastavení:
<em>/etc/newsyslog.conf
/data/log/winevent   644  365   * $D0   ZC     /var/run/syslog.pid</em>

Na serveru běží www server Apache jako webový interface pro vyhledávání v lozích jednoduchým php scriptem ke stažení <a href=“https://www.pr-software.net/wp-content/uploads/2011/11/winevent_source.zip“ target=“_blank“>zde</a>.

,