SlideShare a Scribd company logo
1 of 42
GET THE MOST OUT OF YOUR
SECURITY LOGS
USING SYSLOG-NG
SCALE 2017
Peter Czanik / Balabit
2
ABOUTME
 Peter Czanik from Hungary
 Community Manager at Balabit: syslog-ng
upstream
 syslog-ng packaging, support, advocacy
Balabit is an IT security company with development
HQ in Budapest, Hungary
Over 200 employees: the majority are engineers
3
OVERVIEW
 What is syslog-ng
 The four roles of syslog-ng
 Message parsing
 Enriching messages
 Blacklist filtering
 Configuring syslog-ng
 Scaling and reliability
 Analyzing logs: heat map, anonymization and more
4
syslog-ng
Loggi ng
Recording events, such as:
Jan 14 11:38:48 linux-0jbu sshd[7716]: Accepted publickey for root
from 127.0.0.1 port 48806 ssh2
sysl og- ng
Enhanced logging daemon with a focus on high-performance
central log collection.
5
WHY CENTRAL LOGGING?
EASE OF USE
one place to check
instead of many
AVAILABILITY
even if the sender
machine is down
SECURITY
logs are available even
if sender machine
is compromised
6
MAINSYSLOG-NGROLES
collector processor filter storage
(or forwarder)
7
ROLE: DATACOLLECTOR
Collectsystemandapplicationlogstogether:
contextualdataforeitherside
A wide variety of platform-specific sources:
 /dev/log & co
 Journal, Sun streams
Receive syslog messages over the network:
 Legacy or RFC5424, UDP/TCP/TLS
Logs or any kind of data from applications:
 Through files, sockets, pipes, etc.
 Application output
8
ROLE: PROCESSING
Classify, normalize and structure logs with built-in parsers:
 CSV-parser, DB-parser (PatternDB), JSON parser, key=value
parser and more to come
Rewrite messages:
 For example anonymization
Reformatting messages using templates:
 Destination might need a specific format (ISO date, JSON, etc.)
Enrich data:
 GeoIP
 Additional fields based on message content
9
ROLE: DATAFILTERING
Main uses:
 Discarding surplus logs (not storing debug level messages)
 Message routing (login events to SIEM)
Many possibilities:
 Based on message content, parameters or macros
 Using comparisons, wildcards, regular expressions and
functions
 Combining all of these with Boolean operators
10
ROLE: DESTINATIONS
“TRADITIONAL”
● File, network, TLS, SQL, etc.
“BIG DATA”
● Distributed file systems:
● Hadoop
● NoSQL databases:
● MongoDB
● Elasticsearch
● Messaging systems:
● Kafka
11
WHICHSYSLOG-NG
VERSIONISTHEMOSTUSED?
 Project started in 1998
 RHEL EPEL has version 3.5
 Latest stable version is 3.9, released three
months ago
12
Ki ndl e e- book reader
Version 1.6
13
FREE-FORMLOGMESSAGES
Most log messages are: date + hostname + text
Mar 11 13:37:56 linux-6965 sshd[4547]: Accepted
keyboard-interactive/pam for root from 127.0.0.1 port
46048 ssh2
 Text = English sentence with some variable parts
 Easy to read by a human
 Difficult to process them with scripts
14
SOLUTION: STRUCTUREDLOGGING
 Events represented as name-value pairs
 Example: an ssh login:
app=sshd user=root source_ip=192.168.123.45
 syslog-ng: name-value pairs inside
 Date, facility, priority, program name, pid, etc.
 Parsers in syslog-ng can turn unstructured and some structured data (CSV,
JSON) into name-value pairs
15
JSONPARSER
Turns JSON-based log messages into name-value pairs
{"PROGRAM":"prg00000","PRIORITY":"info","PID":"1234","MESSAGE":"seq:
0000000000, thread: 0000, runid: 1374490607, stamp: 2013-07-22T12:56:47
MESSAGE... ","HOST":"localhost","FACILITY":"auth","DATE":"Jul 22 12:56:47"}
16
CSVPARSER
Parses columnar data into fields
parser p_apache {
csv-parser(columns("APACHE.CLIENT_IP", "APACHE.IDENT_NAME", "APACHE.USER_NAME",
"APACHE.TIMESTAMP", "APACHE.REQUEST_URL", "APACHE.REQUEST_STATUS",
"APACHE.CONTENT_LENGTH", "APACHE.REFERER", "APACHE.USER_AGENT",
"APACHE.PROCESS_TIME", "APACHE.SERVER_NAME")
flags(escape-double-char,strip-whitespace) delimiters(" ") quote-pairs('""[]')
);
};
destination d_file { file("/var/log/messages-${APACHE.USER_NAME:-nouser}"); };
log { source(s_local); parser(p_apache); destination(d_file);};
17
KEY=VALUEPARSER
Finds key=value pairs in messages
Introduced in version 3.7.
Typical in firewalls, like:
Aug 4 13:22:40 centos kernel: IPTables-Dropped: IN= OUT=em1 SRC=192.168.1.23
DST=192.168.1.20 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ICMP
TYPE=8 CODE=0 ID=59228 SEQ=2
Aug 4 13:23:00 centos kernel: IPTables-Dropped: IN=em1 OUT=
MAC=a2:be:d2:ab:11:af:e2:f2:00:00 SRC=192.168.2.115 DST=192.168.1.23 LEN=52
TOS=0x00 PREC=0x00 TTL=127 ID=9434 DF PROTO=TCP SPT=58428 DPT=443
WINDOW=8192 RES=0x00 SYN URGP=0
18
PATTERNDBPARSER
Extracts information from unstructured messages into name-value pairs
 Add status fields based on message text
 Message classification (like LogCheck)
Needs XML describing log messages
Example: an ssh login failure:
 Parsed: app=sshd, user=root, source_ip=192.168.123.45
 Added: action=login, status=failure
 Classified as “violation”
<pattern>Failed @ESTRING:usracct.authmethod: @for
@ESTRING:usracct.username: @from @ESTRING:usracct.device: @port
@ESTRING:: @@ANYSTRING:usracct.service@</pattern>
19
PARSERSWRITTENINRUST
Rust parsers
 Rust: https://www.rust-lang.org/
 Supported from 3.8
Example modules in separate repository: https://github.com/balabit/syslog-ng-rust-modules/
 Regexp parser
 Actiondb parser (similar to, but easier to use than patterndb)
 Correlation parser
20
PARSERSWRITTENINPYTHON
Python parsers
 Not yet released, merged to git HEAD
 Regexp parser example
 Slower than Rust, but does not need compilation or a complex development environment
21
ENRICHINGLOGMESSAGES
Additional name-value pairs based on message content
PatternDB
GeoIP: find the geo-location of an IP address
 Country name or longitude/latitude
 Detect anomalies
 Display locations on a map
Add metadata from CSV files
 For example: host role, contact person
 Less time spent on locating extra information
 More accurate alerts or dashboards

22
THEINLIST()FILTER
Filtering based on white or blacklisting
 Compares a single field with a list of values
 One value per line text file
 Case sensitive
Use cases
 Poor mans SIEM: alerting based on spammer / C&C / etc IP address lists
 Filtering based on a list of application names
23
CONFIGURATION
 “Don't Panic”
 Simple and logical, even if it looks difficult at first
 Pipeline model:
 Many different building blocks (sources, destinations,
filters, parsers, etc.)
 Connected into a pipeline using “log” statements
24
syslog-ng.conf: globaloptions
@version:3.7
@include "scl.conf"
# this is a comment :)
options {
flush_lines (0);
# [...]
keep_hostname (yes);
};
25
syslog-ng.conf: sources
source s_sys {
system();
internal();
};
source s_net {
udp(ip(0.0.0.0) port(514));
};
26
syslog-ng.conf: destinations
destination d_mesg { file("/var/log/messages"); };
destination d_es {
elasticsearch(
index("syslog-ng_${YEAR}.${MONTH}.${DAY}")
type("test")
cluster("syslog-ng")
template("$(format-json --scope rfc3164 --scope nv-pairs --exclude R_DATE --key ISODATE)n");
);
};
27
syslog-ng.conf: filters, parsers
filter f_nodebug { level(info..emerg); };
filter f_messages { level(info..emerg) and
not (facility(mail)
or facility(authpriv)
or facility(cron)); };
parser pattern_db {
db-parser(file("/opt/syslog-ng/etc/patterndb.xml") );
};
28
syslog-ng.conf: logpath
log { source(s_sys); filter(f_messages); destination(d_mesg); };
log {
source(s_net);
source(s_sys);
filter(f_nodebug);
parser(pattern_db);
destination(d_es);
flags(flow-control);
};
29
Patterndb&ElasticSearch&Kibana
30
SCALINGSYSLOG-NG
 Traditionally: Client > Server
 Too much processing
 UDP is problematic
 Client > Relay > Server
 Distribute some of the processing to Client/Relay
 Collect UDP as close to the source as possible
 Adds reliability: logs are collected even if central server
inaccessible
31
SCALINGSYSLOG-NG
32
SCALINGWITHLOGROUTING
 Based on filtering
 Send the right logs to the right places
 Message parsing can increase accuracy
 E-mail on root logins
 Can optimize SIEM / log analyzer tools
 Only relevant messages: cheaper licensing
 Throttling: evening out peaks
33
ANONYMIZINGMESSAGES
Many regulations about what can be logged
 PCI-DSS: credit card numbers
 Europe: IP addresses, user names
Locating sensitive information:
 Regular expression: slow, works also in unknown logs
 Patterndb, CSV parser: fast, works only in known log messages
Anonymizing:
 Overwrite it with a constant
 Overwrite it with a hash of the original
34
35
GeoIP
● parser p_kv{ kv-parser(prefix("kv.")); };
●
● parser p_geoip { geoip( "${kv.SRC}", prefix( "geoip." ) database( "/usr/share/GeoIP/GeoLiteCity.dat" ) ); };
●
● rewrite r_geoip {
● set(
● "${geoip.latitude},${geoip.longitude}",
● value( "geoip.location" ),
● condition(not "${geoip.latitude}" == "")
● );
● };
●
● log {
● source(s_tcp);
● parser(p_kv);
● parser(p_geoip);
● rewrite(r_geoip);
● destination(d_elastic);
● };
●
36
PEG(ELSA2.0): https://github.com/mcholste/
37
PEG(ELSA2.0)
38
WHATISNEWINSYSLOG-NG3.8AND3.9
 Disk-based buffering
 Grouping-by(): correlation independent
of patterndb
 Parsers written in Rust
 Elasticsearch 2.x & 5.0 support
 Curl (HTTP) destination
 Performance improvements
 Many more :-)
39
SYSLOG-NGBENEFITS
FORLARGEENVIRONMENTS
High-performance
reliable log collection
Simplified
architecture
Single application for both
syslog and application data
Easier-to-use data
Parsed and presented in a
ready-to-use format
Lower load on
destinations
Efficient message filtering
and routing
40
JOININGTHECOMMUNITY
 syslog-ng: http://syslog-ng.org/
 Source on GitHub: https://github.com/balabit/syslog-ng
 Mailing list: https://lists.balabit.hu/pipermail/syslog-ng/
 IRC: #syslog-ng on freenode
41
QUESTIONS?
My blog: https://www.balabit.com/blog/author/peterczanik/
My e-mail: peter.czanik@balabit.com
Twitter: https://twitter.com/PCzanik
42
SAMPLEXML
● <?xml version='1.0' encoding='UTF-8'?>
● <patterndb version='3' pub_date='2010-07-13'>
● <ruleset name='opensshd' id='2448293e-6d1c-412c-a418-a80025639511'>
● <pattern>sshd</pattern>
● <rules>
● <rule provider="patterndb" id="4dd5a329-da83-4876-a431-ddcb59c2858c" class="system">
● <patterns>
● <pattern>Accepted @ESTRING:usracct.authmethod: @for @ESTRING:usracct.username: @from @ESTRING:usracct.device: @port @ESTRING::
@@ANYSTRING:usracct.service@</pattern>
● </patterns>
● <examples>
● <example>
● <test_message program="sshd">Accepted password for bazsi from 127.0.0.1 port 48650 ssh2</test_message>
● <test_values>
● <test_value name="usracct.username">bazsi</test_value>
● <test_value name="usracct.authmethod">password</test_value>
● <test_value name="usracct.device">127.0.0.1</test_value>
● <test_value name="usracct.service">ssh2</test_value>
● </test_values>
● </example>
● </examples>
● <values>
● <value name="usracct.type">login</value>
● <value name="usracct.sessionid">$PID</value>
● <value name="usracct.application">$PROGRAM</value>
● <value name="secevt.verdict">ACCEPT</value>
● </values>
● </rule>

More Related Content

What's hot

Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified LoggingGabor Kozma
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layerKiyoto Tamura
 
Redis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamRedis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamCodemotion
 
Building the Right Platform Architecture for Hadoop
Building the Right Platform Architecture for HadoopBuilding the Right Platform Architecture for Hadoop
Building the Right Platform Architecture for HadoopAll Things Open
 
InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)Gene Leybzon
 
Passive DNS Collection – Henry Stern, Cisco
Passive DNS Collection – Henry Stern, CiscoPassive DNS Collection – Henry Stern, Cisco
Passive DNS Collection – Henry Stern, CiscoHenry Stern
 
Like loggly using open source
Like loggly using open sourceLike loggly using open source
Like loggly using open sourceThomas Alrin
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com琛琳 饶
 
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...APNIC
 
Life of an Fluentd event
Life of an Fluentd eventLife of an Fluentd event
Life of an Fluentd eventKiyoto Tamura
 
Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.Alex Borysov
 
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOS
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOSPart 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOS
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOSMen and Mice
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12N Masahiro
 

What's hot (20)

Centralized + Unified Logging
Centralized + Unified LoggingCentralized + Unified Logging
Centralized + Unified Logging
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Fluentd unified logging layer
Fluentd   unified logging layerFluentd   unified logging layer
Fluentd unified logging layer
 
Fluentd meetup
Fluentd meetupFluentd meetup
Fluentd meetup
 
Redis - for duplicate detection on real time stream
Redis - for duplicate detection on real time streamRedis - for duplicate detection on real time stream
Redis - for duplicate detection on real time stream
 
The basics of fluentd
The basics of fluentdThe basics of fluentd
The basics of fluentd
 
Building the Right Platform Architecture for Hadoop
Building the Right Platform Architecture for HadoopBuilding the Right Platform Architecture for Hadoop
Building the Right Platform Architecture for Hadoop
 
InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)InterPlanetary File System (IPFS)
InterPlanetary File System (IPFS)
 
Passive DNS Collection – Henry Stern, Cisco
Passive DNS Collection – Henry Stern, CiscoPassive DNS Collection – Henry Stern, Cisco
Passive DNS Collection – Henry Stern, Cisco
 
Like loggly using open source
Like loggly using open sourceLike loggly using open source
Like loggly using open source
 
7 technical-dns-workshop-day3
7 technical-dns-workshop-day37 technical-dns-workshop-day3
7 technical-dns-workshop-day3
 
ELK stack at weibo.com
ELK stack at weibo.comELK stack at weibo.com
ELK stack at weibo.com
 
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...
Passive DNS Collection -- the 'dnstap' approach, by Paul Vixie [APNIC 38 / AP...
 
Life of an Fluentd event
Life of an Fluentd eventLife of an Fluentd event
Life of an Fluentd event
 
6 technical-dns-workshop-day3
6 technical-dns-workshop-day36 technical-dns-workshop-day3
6 technical-dns-workshop-day3
 
Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.Enabling Googley microservices with HTTP/2 and gRPC.
Enabling Googley microservices with HTTP/2 and gRPC.
 
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOS
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOSPart 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOS
Part 3 - Local Name Resolution in Linux, FreeBSD and macOS/iOS
 
Fluentd introduction at ipros
Fluentd introduction at iprosFluentd introduction at ipros
Fluentd introduction at ipros
 
Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12Dive into Fluentd plugin v0.12
Dive into Fluentd plugin v0.12
 
Stress your DUT
Stress your DUTStress your DUT
Stress your DUT
 

Similar to Get the most out of your security logs using syslog-ng

Scaling Your Logging Infrastructure With Syslog-NG
Scaling Your Logging Infrastructure With Syslog-NGScaling Your Logging Infrastructure With Syslog-NG
Scaling Your Logging Infrastructure With Syslog-NGAll Things Open
 
Fedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 TalkFedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 TalkRainer Gerhards
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyTim Bunce
 
Low cost multi-sensor IDS system
Low cost multi-sensor IDS systemLow cost multi-sensor IDS system
Low cost multi-sensor IDS systemRobert Schrack
 
Advanced Log Processing
Advanced Log ProcessingAdvanced Log Processing
Advanced Log ProcessingAnton Chuvakin
 
Logging in dockerized environment
Logging in dockerized environmentLogging in dockerized environment
Logging in dockerized environmentYury Bushmelev
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchVic Hargrave
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'Cloud Elements
 
Securing Syslog On FreeBSD
Securing Syslog On FreeBSDSecuring Syslog On FreeBSD
Securing Syslog On FreeBSDAlbert Mietus
 
securing_syslog_onFreeBSD
securing_syslog_onFreeBSDsecuring_syslog_onFreeBSD
securing_syslog_onFreeBSDwebuploader
 
Tim eberhard bajug3_talk
Tim eberhard bajug3_talkTim eberhard bajug3_talk
Tim eberhard bajug3_talkTim Eberhard
 
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsPostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsFaisal Akber
 
import rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Pythonimport rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Pythongroveronline
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logsJeremy Cook
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsCommand Prompt., Inc
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a gamejackpot201
 

Similar to Get the most out of your security logs using syslog-ng (20)

Scaling Your Logging Infrastructure With Syslog-NG
Scaling Your Logging Infrastructure With Syslog-NGScaling Your Logging Infrastructure With Syslog-NG
Scaling Your Logging Infrastructure With Syslog-NG
 
GrayLog for Java developers FOSDEM 2018
GrayLog for Java developers FOSDEM 2018GrayLog for Java developers FOSDEM 2018
GrayLog for Java developers FOSDEM 2018
 
Fedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 TalkFedora Developer's Conference 2014 Talk
Fedora Developer's Conference 2014 Talk
 
Application Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.keyApplication Logging in the 21st century - 2014.key
Application Logging in the 21st century - 2014.key
 
D4 Project Presentation
D4 Project PresentationD4 Project Presentation
D4 Project Presentation
 
Low cost multi-sensor IDS system
Low cost multi-sensor IDS systemLow cost multi-sensor IDS system
Low cost multi-sensor IDS system
 
Advanced Log Processing
Advanced Log ProcessingAdvanced Log Processing
Advanced Log Processing
 
Logging in dockerized environment
Logging in dockerized environmentLogging in dockerized environment
Logging in dockerized environment
 
Advances in Open Source Password Cracking
Advances in Open Source Password CrackingAdvances in Open Source Password Cracking
Advances in Open Source Password Cracking
 
Managing Your Security Logs with Elasticsearch
Managing Your Security Logs with ElasticsearchManaging Your Security Logs with Elasticsearch
Managing Your Security Logs with Elasticsearch
 
'Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash''Scalable Logging and Analytics with LogStash'
'Scalable Logging and Analytics with LogStash'
 
Securing Syslog On FreeBSD
Securing Syslog On FreeBSDSecuring Syslog On FreeBSD
Securing Syslog On FreeBSD
 
securing_syslog_onFreeBSD
securing_syslog_onFreeBSDsecuring_syslog_onFreeBSD
securing_syslog_onFreeBSD
 
Tim eberhard bajug3_talk
Tim eberhard bajug3_talkTim eberhard bajug3_talk
Tim eberhard bajug3_talk
 
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption OptionsPostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
PostgresOpen 2013 A Comparison of PostgreSQL Encryption Options
 
Hotsos Advanced Linux Tools
Hotsos Advanced Linux ToolsHotsos Advanced Linux Tools
Hotsos Advanced Linux Tools
 
import rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Pythonimport rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Python
 
Turbo charge your logs
Turbo charge your logsTurbo charge your logs
Turbo charge your logs
 
PostgreSQL Administration for System Administrators
PostgreSQL Administration for System AdministratorsPostgreSQL Administration for System Administrators
PostgreSQL Administration for System Administrators
 
Shall we play a game
Shall we play a gameShall we play a game
Shall we play a game
 

Recently uploaded

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Angel Borroy López
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...OnePlan Solutions
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 

Recently uploaded (20)

PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
Alfresco TTL#157 - Troubleshooting Made Easy: Deciphering Alfresco mTLS Confi...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
Tech Tuesday - Mastering Time Management Unlock the Power of OnePlan's Timesh...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 

Get the most out of your security logs using syslog-ng

  • 1. GET THE MOST OUT OF YOUR SECURITY LOGS USING SYSLOG-NG SCALE 2017 Peter Czanik / Balabit
  • 2. 2 ABOUTME  Peter Czanik from Hungary  Community Manager at Balabit: syslog-ng upstream  syslog-ng packaging, support, advocacy Balabit is an IT security company with development HQ in Budapest, Hungary Over 200 employees: the majority are engineers
  • 3. 3 OVERVIEW  What is syslog-ng  The four roles of syslog-ng  Message parsing  Enriching messages  Blacklist filtering  Configuring syslog-ng  Scaling and reliability  Analyzing logs: heat map, anonymization and more
  • 4. 4 syslog-ng Loggi ng Recording events, such as: Jan 14 11:38:48 linux-0jbu sshd[7716]: Accepted publickey for root from 127.0.0.1 port 48806 ssh2 sysl og- ng Enhanced logging daemon with a focus on high-performance central log collection.
  • 5. 5 WHY CENTRAL LOGGING? EASE OF USE one place to check instead of many AVAILABILITY even if the sender machine is down SECURITY logs are available even if sender machine is compromised
  • 7. 7 ROLE: DATACOLLECTOR Collectsystemandapplicationlogstogether: contextualdataforeitherside A wide variety of platform-specific sources:  /dev/log & co  Journal, Sun streams Receive syslog messages over the network:  Legacy or RFC5424, UDP/TCP/TLS Logs or any kind of data from applications:  Through files, sockets, pipes, etc.  Application output
  • 8. 8 ROLE: PROCESSING Classify, normalize and structure logs with built-in parsers:  CSV-parser, DB-parser (PatternDB), JSON parser, key=value parser and more to come Rewrite messages:  For example anonymization Reformatting messages using templates:  Destination might need a specific format (ISO date, JSON, etc.) Enrich data:  GeoIP  Additional fields based on message content
  • 9. 9 ROLE: DATAFILTERING Main uses:  Discarding surplus logs (not storing debug level messages)  Message routing (login events to SIEM) Many possibilities:  Based on message content, parameters or macros  Using comparisons, wildcards, regular expressions and functions  Combining all of these with Boolean operators
  • 10. 10 ROLE: DESTINATIONS “TRADITIONAL” ● File, network, TLS, SQL, etc. “BIG DATA” ● Distributed file systems: ● Hadoop ● NoSQL databases: ● MongoDB ● Elasticsearch ● Messaging systems: ● Kafka
  • 11. 11 WHICHSYSLOG-NG VERSIONISTHEMOSTUSED?  Project started in 1998  RHEL EPEL has version 3.5  Latest stable version is 3.9, released three months ago
  • 12. 12 Ki ndl e e- book reader Version 1.6
  • 13. 13 FREE-FORMLOGMESSAGES Most log messages are: date + hostname + text Mar 11 13:37:56 linux-6965 sshd[4547]: Accepted keyboard-interactive/pam for root from 127.0.0.1 port 46048 ssh2  Text = English sentence with some variable parts  Easy to read by a human  Difficult to process them with scripts
  • 14. 14 SOLUTION: STRUCTUREDLOGGING  Events represented as name-value pairs  Example: an ssh login: app=sshd user=root source_ip=192.168.123.45  syslog-ng: name-value pairs inside  Date, facility, priority, program name, pid, etc.  Parsers in syslog-ng can turn unstructured and some structured data (CSV, JSON) into name-value pairs
  • 15. 15 JSONPARSER Turns JSON-based log messages into name-value pairs {"PROGRAM":"prg00000","PRIORITY":"info","PID":"1234","MESSAGE":"seq: 0000000000, thread: 0000, runid: 1374490607, stamp: 2013-07-22T12:56:47 MESSAGE... ","HOST":"localhost","FACILITY":"auth","DATE":"Jul 22 12:56:47"}
  • 16. 16 CSVPARSER Parses columnar data into fields parser p_apache { csv-parser(columns("APACHE.CLIENT_IP", "APACHE.IDENT_NAME", "APACHE.USER_NAME", "APACHE.TIMESTAMP", "APACHE.REQUEST_URL", "APACHE.REQUEST_STATUS", "APACHE.CONTENT_LENGTH", "APACHE.REFERER", "APACHE.USER_AGENT", "APACHE.PROCESS_TIME", "APACHE.SERVER_NAME") flags(escape-double-char,strip-whitespace) delimiters(" ") quote-pairs('""[]') ); }; destination d_file { file("/var/log/messages-${APACHE.USER_NAME:-nouser}"); }; log { source(s_local); parser(p_apache); destination(d_file);};
  • 17. 17 KEY=VALUEPARSER Finds key=value pairs in messages Introduced in version 3.7. Typical in firewalls, like: Aug 4 13:22:40 centos kernel: IPTables-Dropped: IN= OUT=em1 SRC=192.168.1.23 DST=192.168.1.20 LEN=84 TOS=0x00 PREC=0x00 TTL=64 ID=0 DF PROTO=ICMP TYPE=8 CODE=0 ID=59228 SEQ=2 Aug 4 13:23:00 centos kernel: IPTables-Dropped: IN=em1 OUT= MAC=a2:be:d2:ab:11:af:e2:f2:00:00 SRC=192.168.2.115 DST=192.168.1.23 LEN=52 TOS=0x00 PREC=0x00 TTL=127 ID=9434 DF PROTO=TCP SPT=58428 DPT=443 WINDOW=8192 RES=0x00 SYN URGP=0
  • 18. 18 PATTERNDBPARSER Extracts information from unstructured messages into name-value pairs  Add status fields based on message text  Message classification (like LogCheck) Needs XML describing log messages Example: an ssh login failure:  Parsed: app=sshd, user=root, source_ip=192.168.123.45  Added: action=login, status=failure  Classified as “violation” <pattern>Failed @ESTRING:usracct.authmethod: @for @ESTRING:usracct.username: @from @ESTRING:usracct.device: @port @ESTRING:: @@ANYSTRING:usracct.service@</pattern>
  • 19. 19 PARSERSWRITTENINRUST Rust parsers  Rust: https://www.rust-lang.org/  Supported from 3.8 Example modules in separate repository: https://github.com/balabit/syslog-ng-rust-modules/  Regexp parser  Actiondb parser (similar to, but easier to use than patterndb)  Correlation parser
  • 20. 20 PARSERSWRITTENINPYTHON Python parsers  Not yet released, merged to git HEAD  Regexp parser example  Slower than Rust, but does not need compilation or a complex development environment
  • 21. 21 ENRICHINGLOGMESSAGES Additional name-value pairs based on message content PatternDB GeoIP: find the geo-location of an IP address  Country name or longitude/latitude  Detect anomalies  Display locations on a map Add metadata from CSV files  For example: host role, contact person  Less time spent on locating extra information  More accurate alerts or dashboards 
  • 22. 22 THEINLIST()FILTER Filtering based on white or blacklisting  Compares a single field with a list of values  One value per line text file  Case sensitive Use cases  Poor mans SIEM: alerting based on spammer / C&C / etc IP address lists  Filtering based on a list of application names
  • 23. 23 CONFIGURATION  “Don't Panic”  Simple and logical, even if it looks difficult at first  Pipeline model:  Many different building blocks (sources, destinations, filters, parsers, etc.)  Connected into a pipeline using “log” statements
  • 24. 24 syslog-ng.conf: globaloptions @version:3.7 @include "scl.conf" # this is a comment :) options { flush_lines (0); # [...] keep_hostname (yes); };
  • 25. 25 syslog-ng.conf: sources source s_sys { system(); internal(); }; source s_net { udp(ip(0.0.0.0) port(514)); };
  • 26. 26 syslog-ng.conf: destinations destination d_mesg { file("/var/log/messages"); }; destination d_es { elasticsearch( index("syslog-ng_${YEAR}.${MONTH}.${DAY}") type("test") cluster("syslog-ng") template("$(format-json --scope rfc3164 --scope nv-pairs --exclude R_DATE --key ISODATE)n"); ); };
  • 27. 27 syslog-ng.conf: filters, parsers filter f_nodebug { level(info..emerg); }; filter f_messages { level(info..emerg) and not (facility(mail) or facility(authpriv) or facility(cron)); }; parser pattern_db { db-parser(file("/opt/syslog-ng/etc/patterndb.xml") ); };
  • 28. 28 syslog-ng.conf: logpath log { source(s_sys); filter(f_messages); destination(d_mesg); }; log { source(s_net); source(s_sys); filter(f_nodebug); parser(pattern_db); destination(d_es); flags(flow-control); };
  • 30. 30 SCALINGSYSLOG-NG  Traditionally: Client > Server  Too much processing  UDP is problematic  Client > Relay > Server  Distribute some of the processing to Client/Relay  Collect UDP as close to the source as possible  Adds reliability: logs are collected even if central server inaccessible
  • 32. 32 SCALINGWITHLOGROUTING  Based on filtering  Send the right logs to the right places  Message parsing can increase accuracy  E-mail on root logins  Can optimize SIEM / log analyzer tools  Only relevant messages: cheaper licensing  Throttling: evening out peaks
  • 33. 33 ANONYMIZINGMESSAGES Many regulations about what can be logged  PCI-DSS: credit card numbers  Europe: IP addresses, user names Locating sensitive information:  Regular expression: slow, works also in unknown logs  Patterndb, CSV parser: fast, works only in known log messages Anonymizing:  Overwrite it with a constant  Overwrite it with a hash of the original
  • 34. 34
  • 35. 35 GeoIP ● parser p_kv{ kv-parser(prefix("kv.")); }; ● ● parser p_geoip { geoip( "${kv.SRC}", prefix( "geoip." ) database( "/usr/share/GeoIP/GeoLiteCity.dat" ) ); }; ● ● rewrite r_geoip { ● set( ● "${geoip.latitude},${geoip.longitude}", ● value( "geoip.location" ), ● condition(not "${geoip.latitude}" == "") ● ); ● }; ● ● log { ● source(s_tcp); ● parser(p_kv); ● parser(p_geoip); ● rewrite(r_geoip); ● destination(d_elastic); ● }; ●
  • 38. 38 WHATISNEWINSYSLOG-NG3.8AND3.9  Disk-based buffering  Grouping-by(): correlation independent of patterndb  Parsers written in Rust  Elasticsearch 2.x & 5.0 support  Curl (HTTP) destination  Performance improvements  Many more :-)
  • 39. 39 SYSLOG-NGBENEFITS FORLARGEENVIRONMENTS High-performance reliable log collection Simplified architecture Single application for both syslog and application data Easier-to-use data Parsed and presented in a ready-to-use format Lower load on destinations Efficient message filtering and routing
  • 40. 40 JOININGTHECOMMUNITY  syslog-ng: http://syslog-ng.org/  Source on GitHub: https://github.com/balabit/syslog-ng  Mailing list: https://lists.balabit.hu/pipermail/syslog-ng/  IRC: #syslog-ng on freenode
  • 41. 41 QUESTIONS? My blog: https://www.balabit.com/blog/author/peterczanik/ My e-mail: peter.czanik@balabit.com Twitter: https://twitter.com/PCzanik
  • 42. 42 SAMPLEXML ● <?xml version='1.0' encoding='UTF-8'?> ● <patterndb version='3' pub_date='2010-07-13'> ● <ruleset name='opensshd' id='2448293e-6d1c-412c-a418-a80025639511'> ● <pattern>sshd</pattern> ● <rules> ● <rule provider="patterndb" id="4dd5a329-da83-4876-a431-ddcb59c2858c" class="system"> ● <patterns> ● <pattern>Accepted @ESTRING:usracct.authmethod: @for @ESTRING:usracct.username: @from @ESTRING:usracct.device: @port @ESTRING:: @@ANYSTRING:usracct.service@</pattern> ● </patterns> ● <examples> ● <example> ● <test_message program="sshd">Accepted password for bazsi from 127.0.0.1 port 48650 ssh2</test_message> ● <test_values> ● <test_value name="usracct.username">bazsi</test_value> ● <test_value name="usracct.authmethod">password</test_value> ● <test_value name="usracct.device">127.0.0.1</test_value> ● <test_value name="usracct.service">ssh2</test_value> ● </test_values> ● </example> ● </examples> ● <values> ● <value name="usracct.type">login</value> ● <value name="usracct.sessionid">$PID</value> ● <value name="usracct.application">$PROGRAM</value> ● <value name="secevt.verdict">ACCEPT</value> ● </values> ● </rule>

Editor's Notes

  1. Global leader in: - privileged activity monitoring - trusted logging - proxy based gateway technologies Active member of the open source community