-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathf5.conf
169 lines (168 loc) · 10.6 KB
/
f5.conf
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# Config Name: f5.conf
# Version: v2.04.171115
# Created on: 05/06/15
# Author: Willem D'Haese
# Purpose: F5 Logstash Configuration File
# GitHub: https://github.com/willemdh/logstash_filter_f5
# Copyright:
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version. This program is distributed in the hope that it will be
# useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
input {
udp {
type => 'syslog-f5'
port => xxxx
}
}
filter {
if [type] == "syslog-f5" {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [ "message", "\A<%{POSINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} (slot1\/)?%{HOSTNAMEUND:syslog_hostname} %{LOGLEVEL:syslog_severity} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}\Z" ]
add_tag => "grok_f5"
}
translate {
dictionary_path => [ "/etc/logstash/dictionaries/syslogpri.yml" ]
field => "syslog_pri"
destination => "syslog_severity"
}
mutate {
copy => { "type" => "dig_type" }
# remove_field => [ "syslog_timestamp" ]
}
if [syslog_program] =~ /apd|apmd/ {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_apd_policy}:)?%{F5ID:f5_session_id}: %{GREEDYDATA:f5_apd_message}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: %{PROG:f5_apd_processor} %{GREEDYDATA:f5_apd_message}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: %{GREEDYDATA:f5_apd_message}\Z"
]
remove_tag => "grok_f5"
add_tag => "grok_f5_apd"
}
if [f5_apd_processor] {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"f5_apd_message", "\Afunc: (\\)?\"%{WORD:f5_apd_function}\(\)(\\)?\" line: %{NUMBER:f5_apd_processor_line} Msg: %{GREEDYDATA:f5_apd_processor_message}\Z"
]
remove_tag => "grok_f5_apd"
add_tag => "grok_f5_apd_processor"
}
}
else if [f5_session_id] {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"f5_apd_message", "\Afunc: \"%{WORD:f5_apd_function}\(\)\" line: %{NUMBER:f5_apd_processor_line} Msg: %{GREEDYDATA:f5_apd_processor_message}\Z",
"f5_apd_message", "\ASession variable '%{NOTSPACE:f5_apd_session_var_name}' set to '%{GREEDYDATA:f5_apd_session_var_value}'\Z",
"f5_apd_message", "\AAccess policy result: %{GREEDYDATA:f5_apd_policy_result}\Z",
"f5_apd_message", "\A%{GREEDYDATA:f5_apd_message}\Z"
]
overwrite => [ "f5_apd_message" ]
remove_tag => "grok_f5_apd"
add_tag => "grok_f5_apd_session"
}
}
}
else if [syslog_program] == "dcc" {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"syslog_message", "\A%{F5SEQ:f5_message_id}: \[%{WORD:f5_dcc_type}\] ((?<f5_dcc_event>Request) violations: %{GREEDYDATA:f5_dcc_violation}. )?((?<f5_dcc_event>Request blocked), violations: %{GREEDYDATA:f5_dcc_violation}. )?HTTP protocol compliance sub violations: %{GREEDYDATA:f5_dcc_http_violation}. Evasion techniques sub violations: %{GREEDYDATA:f5_dcc_evasion_violation}. Web services security sub violations: %{GREEDYDATA:f5_dcc_web_violation}. Virus name: %{GREEDYDATA:f5_dcc_virusname}. Support id: %{GREEDYDATA:f5_dcc_support_id}, source ip: %{IPNA:f5_dcc_source_ip}, xff ip: %{IPNA:f5_dcc_xff_ip}, source port: %{NUMBER:f5_dcc_source_port}, destination ip: %{IPNA:f5_dcc_destination_ip}, destination port: %{NUMBER:f5_dcc_destination_port}, route_domain: %{NUMBER:f5_dcc_route_domain}, HTTP classifier: %{GREEDYDATA:f5_dcc_http_classifier}, scheme %{SCHEME:f5_dcc_scheme}, geographic location: \<%{GREEDYDATA:f5_dcc_geolocation}\>, request: \<%{GREEDYDATA:f5_dcc_request}\>, username: \<%{GREEDYDATA:f5_dcc_username}\>, session_id: \<%{GREEDYDATA:f5_dcc_session_id}\>\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: \[%{WORD:f5_dcc_type}\] (?<f5_dcc_violation>Web scraping attack): %{WORD:f5_dcc_scraping_status}, HTTP classifier: %{GREEDYDATA:f5_dcc_http_classifier}, source ip %{IP:f5_dcc_source_ip}, route_domain: %{NUMBER:f5_dcc_route_domain}, geographic location: %{WORD:f5_dcc_geolocation}, operation mode: %{WORD:f5_dcc_operation_mode}, web scraping attack type: %{NOTSPACE:f5_dcc_scraping_type}, drop_counter = %{NUMBER:f5_dcc_drop_counter}, violation_counter = %{NUMBER:f5_dcc_violation_counter}, Transparent mode cshui injection ratio threshold = %{NUMBER:f5_dcc_injection_threshold}, Transparent mode cshui injection ratio = %{NUMBER:f5_dcc_injection_ratio}, Detected transactions on session = %{NUMBER:f5_dcc_detected_transactions}, Detected newly opened sessions from IP = %{NUMBER:f5_dcc_new_transactions}, Legitimate opened session = %{NUMBER:f5_dcc_legit_sessions}, %{GREEDYDATA:f5_dcc_rest}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: Per-invocation log rate exceeded; (?<f5_dcc_type>throttling)\.\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: (?<f5_dcc_type>Resuming log processing) at this invocation; held %{NUMBER:f5_dcc_logs_held} messages\.\Z"
]
remove_tag => "grok_f5"
add_tag => "grok_f5_dcc"
}
if [f5_dcc_violation] == "Web scraping attack" {
mutate {
add_field => {
"f5_dcc_event" => "Scraping"
}
}
}
}
else if [syslog_program] == "httpd" {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"syslog_message", "\A%{F5SEQ:f5_message_id}: AUDIT - user %{USERNAME:f5_httpd_user_name} - RAW: %{GREEDYDATA:f5_httpd_message}\Z",
"syslog_message", "\A%{GREEDYDATA:f5_httpd_message}\Z"
]
remove_tag => "grok_f5"
add_tag => "grok_f5_httpd"
}
}
else if [syslog_program] =~ /tmm.*/ {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_tmm_policy}:)?%{F5ID:f5_session_id}: (?<f5_tmm_type>Session statistics) - bytes in: %{NUMBER:f5_tmm_session_bytes_in}, bytes out: %{NUMBER:f5_tmm_session_bytes_out}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_tmm_policy}:)?%{F5ID:f5_session_id}: (?<f5_tmm_type>Received client info) - (Hostname: (%{HOSTNAME:f5_tmm_client_hostname})? )?Type: %{HOSTNAME:f5_tmm_client_browser} Version: %{NUMBER:f5_tmm_client_browser_version} Platform: %{HOSTNAME:f5_tmm_client_platform} CPU: %{WORD:f5_tmm_client_cpu} UI Mode: %{GREEDYDATA:f5_tmm_client_ui_mode} Javascript Support: %{NUMBER:f5_tmm_client_javascript} ActiveX Support: %{NUMBER:f5_tmm_client_activex} Plugin Support: %{NUMBER:f5_tmm_client_plugin}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_tmm_policy}:)?%{F5ID:f5_session_id}: (?<f5_tmm_type>New session) from client IP %{IP:f5_tmm_session_client_ip} \(%{GREEDYDATA:f5_tmm_session_location}\) at VIP %{IP:f5_tmm_session_vip_ip} Listener %{GREEDYDATA:f5_tmm_session_listener} (\(Reputation=%{WORD:f5_tmm_reputation}\))?\Z",
"syslog_message", "\A(?<f5_tmm_type>Rule) %{NOTSPACE:f5_tmm_rule} <%{NOTSPACE:f5_tmm_event}>: %{GREEDYDATA:f5_tmm_rule_message}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_tmm_policy}:)?%{F5ID:f5_session_id}: (?<f5_tmm_type>Session deleted) (due to %{GREEDYDATA:f5_tmm_session_deleted_reason})?((\()?%{GREEDYDATA:f5_tmm_session_deleted_reason}\))?\.\Z",
"syslog_message", "\AAuthplatform %{MAVEN_VERSION:f5_tmm_auth_version} \(%{CISCO_REASON:f5_tmm_auth_type}\) %{NUMBER:f5_tmm_auth_id} %{IP:f5_tmm_auth_ip}:%{NUMBER:f5_tmm_auth_port} %{GREEDYDATA:f5_tmm_auth_message}\Z",
"syslog_message", "\A%{F5SEQ:f5_message_id}: (%{NOTSPACE:f5_tmm_policy}:)?%{F5ID:f5_session_id}: %{GREEDYDATA:f5_tmm_message}\Z"
]
remove_tag => "grok_f5"
add_tag => "grok_f5_tmm"
}
if ([f5_tmm_rule_message] =~ /.+/) {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"f5_tmm_rule_message", "\AConnection to LDAP from following source: Client\(%{IP:f5_tmm_client_ip}\:%{NUMBER:f5_tmm_client_port}\) <-> \(%{IP:f5_tmm_server_ip}\:%{NUMBER:f5_tmm_server_port}\)Server\Z",
"f5_tmm_rule_message", "\A%{GREEDYDATA:f5_tmm_rule_message}\Z"
]
remove_tag => "grok_f5_tmm"
add_tag => "grok_f5_tmm_rule"
overwrite => [ "f5_tmm_rule_message" ]
}
}
if [f5_tmm_message] == "User-Agent header is absent or empty" {
mutate {
add_field => { "f5_tmm_type" => "Missing User-Agent header" }
}
}
}
else if [syslog_program] =~ /sshd.*/ {
grok {
patterns_dir => "/etc/logstash/patterns"
match => [
"syslog_message", "\AAccepted keyboard-interactive/pam for %{USERNAME:f5_ssh_username} from %{IP:f5_ssh_source_ip} port %{NUMBER:f5_ssh_source_port} ssh2",
"syslog_message", "\Apam_unix(sshd:session): session opened for user %{USERNAME:f5_ssh_username} by (uid={USERNAME:f5_ssh_username_uid})",
"syslog_message", "\Apam_unix(sshd:session): session closed for user %{USERNAME:f5_ssh_username}",
"syslog_message", "\A%{PROG:f5_message_id}: AUDIT - user %{USERNAME:f5_ssh_username} - RAW: sshd\(pam_audit\): user=%{USERNAME}\(%{USERNAME}\) partition=\[%{WORD:f5_ssh_user_partition}] level=%{WORD:f5_ssh_user_level} tty=%{WORD} host=%{IP:f5_ssh_source_ip} attempts=%{INT:f5_ssh_user_attempts} start=\"%{HTTPDERROR_DATE:f5_ssh_session_start}\" end=\"%{HTTPDERROR_DATE:f5_ssh_session_end}\"\.\Z",
"syslog_message", "\A%{GREEDYDATA:f5_ssh_message}"
]
remove_tag => "grok_f5"
add_tag => "grok_f5_sshd"
}
}
}
}
output {
if [type] == "syslog-f5" {
elasticsearch {
index => "f5-001-%{+YYYY.MM.dd}"
hosts => ["https://elastic-ingest-01:9200","https://elastic-ingest-02:9200"]
ssl => true
cacert => "path\to\ca.pem"
manage_template => false
user => "logstash_internal"
password => "<password>"
document_type => doc
}
}
}