Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Handle just timestamps in apache-guacamole #1239

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .tests/apache-guacamole-logs/apache-guacamole-logs.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
28-Mar-2022 07:01:48.459 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
2023-04-06T09:05:54,991Z [http-nio-8080-exec-9] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user "test" failed.
2023-04-06T09:06:01,059Z [http-nio-8080-exec-10] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user "[email protected]" failed.
2023-04-06T09:06:01,059Z [http-nio-8080-exec-10] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user "[email protected]" failed.
07:27:04.499 [http-nio-8080-exec-1] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [192.168.1.1, 172.30.0.4] for user "test" failed.

66 changes: 54 additions & 12 deletions .tests/apache-guacamole-logs/parser.assert
Original file line number Diff line number Diff line change
@@ -1,77 +1,119 @@
len(results) == 4
len(results["s00-raw"]["crowdsecurity/non-syslog"]) == 3
len(results["s00-raw"]["crowdsecurity/non-syslog"]) == 4
results["s00-raw"]["crowdsecurity/non-syslog"][0].Success == true
results["s00-raw"]["crowdsecurity/non-syslog"][0].Evt.Parsed["message"] == "28-Mar-2022 07:01:48.459 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler [\"http-nio-8080\"]"
results["s00-raw"]["crowdsecurity/non-syslog"][0].Evt.Parsed["program"] == "apache-guacamole"
results["s00-raw"]["crowdsecurity/non-syslog"][0].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s00-raw"]["crowdsecurity/non-syslog"][0].Evt.Meta["datasource_type"] == "file"
results["s00-raw"]["crowdsecurity/non-syslog"][0].Evt.Whitelisted == false
results["s00-raw"]["crowdsecurity/non-syslog"][1].Success == true
results["s00-raw"]["crowdsecurity/non-syslog"][1].Evt.Parsed["message"] == "2023-04-06T09:05:54,991Z [http-nio-8080-exec-9] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"test\" failed."
results["s00-raw"]["crowdsecurity/non-syslog"][1].Evt.Parsed["program"] == "apache-guacamole"
results["s00-raw"]["crowdsecurity/non-syslog"][1].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s00-raw"]["crowdsecurity/non-syslog"][1].Evt.Meta["datasource_type"] == "file"
results["s00-raw"]["crowdsecurity/non-syslog"][1].Evt.Whitelisted == false
results["s00-raw"]["crowdsecurity/non-syslog"][2].Success == true
results["s00-raw"]["crowdsecurity/non-syslog"][2].Evt.Parsed["message"] == "2023-04-06T09:06:01,059Z [http-nio-8080-exec-10] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"[email protected]\" failed."
results["s00-raw"]["crowdsecurity/non-syslog"][2].Evt.Parsed["program"] == "apache-guacamole"
results["s00-raw"]["crowdsecurity/non-syslog"][2].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s00-raw"]["crowdsecurity/non-syslog"][2].Evt.Meta["datasource_type"] == "file"
len(results["s00-raw"]["crowdsecurity/syslog-logs"]) == 3
results["s00-raw"]["crowdsecurity/non-syslog"][2].Evt.Whitelisted == false
results["s00-raw"]["crowdsecurity/non-syslog"][3].Success == true
results["s00-raw"]["crowdsecurity/non-syslog"][3].Evt.Parsed["message"] == "07:27:04.499 [http-nio-8080-exec-1] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [192.168.1.1, 172.30.0.4] for user \"test\" failed."
results["s00-raw"]["crowdsecurity/non-syslog"][3].Evt.Parsed["program"] == "apache-guacamole"
results["s00-raw"]["crowdsecurity/non-syslog"][3].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s00-raw"]["crowdsecurity/non-syslog"][3].Evt.Meta["datasource_type"] == "file"
results["s00-raw"]["crowdsecurity/non-syslog"][3].Evt.Whitelisted == false
len(results["s00-raw"]["crowdsecurity/syslog-logs"]) == 4
results["s00-raw"]["crowdsecurity/syslog-logs"][0].Success == false
results["s00-raw"]["crowdsecurity/syslog-logs"][1].Success == false
results["s00-raw"]["crowdsecurity/syslog-logs"][2].Success == false
len(results["s01-parse"]["corvese/apache-guacamole-logs"]) == 3
results["s00-raw"]["crowdsecurity/syslog-logs"][3].Success == false
len(results["s01-parse"]["corvese/apache-guacamole-logs"]) == 4
results["s01-parse"]["corvese/apache-guacamole-logs"][0].Success == false
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Success == true
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Parsed["message"] == "2023-04-06T09:05:54,991Z [http-nio-8080-exec-9] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"test\" failed."
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Parsed["program"] == "apache-guacamole"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Parsed["source_ip"] == "127.0.0.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Parsed["timestamp"] == "2023-04-06T09:05:54,991Z"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Parsed["username"] == "test"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["datasource_type"] == "file"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["service"] == "apache-guacamole"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["source_ip"] == "127.0.0.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["target_user"] == "test"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Meta["datasource_type"] == "file"
results["s01-parse"]["corvese/apache-guacamole-logs"][1].Evt.Whitelisted == false
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Success == true
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Parsed["message"] == "2023-04-06T09:06:01,059Z [http-nio-8080-exec-10] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"[email protected]\" failed."
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Parsed["program"] == "apache-guacamole"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Parsed["source_ip"] == "127.0.0.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Parsed["timestamp"] == "2023-04-06T09:06:01,059Z"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Parsed["username"] == "[email protected]"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["source_ip"] == "127.0.0.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["target_user"] == "[email protected]"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["datasource_type"] == "file"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["service"] == "apache-guacamole"
len(results["s02-enrich"]["crowdsecurity/dateparse-enrich"]) == 2
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["source_ip"] == "127.0.0.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Meta["target_user"] == "[email protected]"
results["s01-parse"]["corvese/apache-guacamole-logs"][2].Evt.Whitelisted == false
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Success == true
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Parsed["message"] == "07:27:04.499 [http-nio-8080-exec-1] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [192.168.1.1, 172.30.0.4] for user \"test\" failed."
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Parsed["program"] == "apache-guacamole"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Parsed["source_ip"] == "192.168.1.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Parsed["timestamp"] == "07:27:04.499"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Parsed["username"] == "test"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["datasource_type"] == "file"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["service"] == "apache-guacamole"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["source_ip"] == "192.168.1.1"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Meta["target_user"] == "test"
results["s01-parse"]["corvese/apache-guacamole-logs"][3].Evt.Whitelisted == false
len(results["s02-enrich"]["crowdsecurity/dateparse-enrich"]) == 3
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Success == true
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Parsed["message"] == "2023-04-06T09:05:54,991Z [http-nio-8080-exec-9] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"test\" failed."
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Parsed["program"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Parsed["source_ip"] == "127.0.0.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Parsed["timestamp"] == "2023-04-06T09:05:54,991Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Parsed["username"] == "test"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["datasource_type"] == "file"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["service"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["source_ip"] == "127.0.0.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["target_user"] == "test"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["timestamp"] == "2023-04-06T09:05:54.991Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Enriched["MarshaledTime"] == "2023-04-06T09:05:54.991Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][0].Evt.Whitelisted == false
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Success == true
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Parsed["message"] == "2023-04-06T09:06:01,059Z [http-nio-8080-exec-10] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [127.0.0.1, 127.0.0.2] for user \"[email protected]\" failed."
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Parsed["program"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Parsed["source_ip"] == "127.0.0.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Parsed["timestamp"] == "2023-04-06T09:06:01,059Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Parsed["username"] == "[email protected]"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["datasource_type"] == "file"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["service"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["source_ip"] == "127.0.0.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["target_user"] == "[email protected]"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["timestamp"] == "2023-04-06T09:06:01.059Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Meta["datasource_type"] == "file"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Enriched["MarshaledTime"] == "2023-04-06T09:06:01.059Z"
len(results["success"][""]) == 0
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][1].Evt.Whitelisted == false
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Success == true
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Parsed["message"] == "07:27:04.499 [http-nio-8080-exec-1] WARN o.a.g.r.auth.AuthenticationService - Authentication attempt from [192.168.1.1, 172.30.0.4] for user \"test\" failed."
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Parsed["program"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Parsed["source_ip"] == "192.168.1.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Parsed["timestamp"] == "07:27:04.499"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Parsed["username"] == "test"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["datasource_path"] == "apache-guacamole-logs.log"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["datasource_type"] == "file"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["log_type"] == "apache-guacamole_failed_auth"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["service"] == "apache-guacamole"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["source_ip"] == "192.168.1.1"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["target_user"] == "test"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Meta["timestamp"][10:] == "T07:27:04.499Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Enriched["MarshaledTime"][10:] == "T07:27:04.499Z"
results["s02-enrich"]["crowdsecurity/dateparse-enrich"][2].Evt.Whitelisted == false
len(results["success"][""]) == 0
15 changes: 13 additions & 2 deletions parsers/s01-parse/corvese/apache-guacamole-logs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,30 @@ filter: "evt.Parsed.program == 'apache-guacamole'"
onsuccess: next_stage
pattern_syntax:
GUAC_CUSTOMUSER: "(%{EMAILADDRESS}|%{USERNAME})"
GUAC_FAILED_AUTH: 'Authentication attempt from \[%{IP:source_ip}.*for user \"%{GUAC_CUSTOMUSER:username}\" failed'
nodes:
- grok:
pattern: '%{TIMESTAMP_ISO8601:timestamp}.*Authentication attempt from \[%{IP:source_ip}.*for user "%{GUAC_CUSTOMUSER:username}" failed'
pattern: '%{TIMESTAMP_ISO8601:timestamp}.*%{GUAC_FAILED_AUTH}'
apply_on: message
statics:
- meta: log_type
value: apache-guacamole_failed_auth
- meta: target_user
expression: evt.Parsed.username
- grok:
pattern: '%{TIME:timestamp}.*%{GUAC_FAILED_AUTH}'
apply_on: message
statics:
- target: evt.StrTimeFormat
value: "15:04:05"
- meta: log_type
value: apache-guacamole_failed_auth
- meta: target_user
expression: evt.Parsed.username
statics:
- meta: service
value: apache-guacamole
- meta: source_ip
expression: evt.Parsed.source_ip
- target: evt.StrTime
expression: evt.Parsed.timestamp
expression: evt.Parsed.timestamp