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

Add teleport collection #822

Merged
merged 8 commits into from
Jan 29, 2024
Merged
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
13 changes: 13 additions & 0 deletions .tests/teleport-bf/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parsers:
- crowdsecurity/syslog-logs
- crowdsecurity/dateparse-enrich
- ./parsers/s01-parse/crowdsecurity/teleport-logs.yaml
scenarios:
- ./scenarios/crowdsecurity/teleport-bf.yaml
postoverflows:
- ""
log_file: teleport-bf.log
log_type: teleport
labels: {}
ignore_parsers: true
override_statics: []
Empty file.
69 changes: 69 additions & 0 deletions .tests/teleport-bf/scenario.assert
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
len(results) == 1
"172.19.0.2" in results[0].Overflow.GetSources()
results[0].Overflow.Sources["172.19.0.2"].IP == "172.19.0.2"
results[0].Overflow.Sources["172.19.0.2"].Range == ""
results[0].Overflow.Sources["172.19.0.2"].GetScope() == "Ip"
results[0].Overflow.Sources["172.19.0.2"].GetValue() == "172.19.0.2"
results[0].Overflow.Alert.Events[0].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[0].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[0].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[0].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[0].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[0].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[0].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[0].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[0].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[0].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.Events[1].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[1].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[1].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[1].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[1].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[1].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[1].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[1].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[1].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[1].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.Events[2].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[2].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[2].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[2].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[2].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[2].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[2].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[2].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[2].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[2].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.Events[3].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[3].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[3].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[3].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[3].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[3].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[3].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[3].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[3].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[3].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.Events[4].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[4].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[4].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[4].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[4].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[4].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[4].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[4].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[4].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[4].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.Events[5].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[5].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[5].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[5].GetMeta("log_type") == "auth_failed"
results[0].Overflow.Alert.Events[5].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[5].GetMeta("source_ip") == "172.19.0.2"
results[0].Overflow.Alert.Events[5].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[5].GetMeta("success") == "false"
results[0].Overflow.Alert.Events[5].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[5].GetMeta("user") == "Bekekrb"
results[0].Overflow.Alert.GetScenario() == "crowdsecurity/teleport-bf"
results[0].Overflow.Alert.Remediation == true
results[0].Overflow.Alert.GetEventsCount() == 6
6 changes: 6 additions & 0 deletions .tests/teleport-bf/teleport-bf.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"Bekekrb","success":false,"error":"invalid username, password or second factor","method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"172.19.0.2:34204"}
15 changes: 15 additions & 0 deletions .tests/teleport-impossible-travel/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parsers:
- crowdsecurity/syslog-logs
- crowdsecurity/dateparse-enrich
- crowdsecurity/geoip-enrich
- ./parsers/s01-parse/crowdsecurity/teleport-logs.yaml
scenarios:
- crowdsecurity/impossible-travel
- crowdsecurity/impossible-travel-user
postoverflows:
- ""
log_file: teleport-bf.log
log_type: teleport
labels: {}
ignore_parsers: true
override_statics: []
Empty file.
74 changes: 74 additions & 0 deletions .tests/teleport-impossible-travel/scenario.assert
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
len(results) == 2
"1.2.3.4" in results[0].Overflow.GetSources()
results[0].Overflow.Sources["1.2.3.4"].IP == "1.2.3.4"
results[0].Overflow.Sources["1.2.3.4"].Range == ""
results[0].Overflow.Sources["1.2.3.4"].GetScope() == "Ip"
results[0].Overflow.Sources["1.2.3.4"].GetValue() == "1.2.3.4"
"9.8.8.8" in results[0].Overflow.GetSources()
results[0].Overflow.Sources["9.8.8.8"].IP == "9.8.8.8"
results[0].Overflow.Sources["9.8.8.8"].Range == ""
results[0].Overflow.Sources["9.8.8.8"].GetScope() == "Ip"
results[0].Overflow.Sources["9.8.8.8"].GetValue() == "9.8.8.8"
results[0].Overflow.Alert.Events[0].GetMeta("ASNNumber") == "0"
results[0].Overflow.Alert.Events[0].GetMeta("IsInEU") == "false"
results[0].Overflow.Alert.Events[0].GetMeta("IsoCode") == "AU"
results[0].Overflow.Alert.Events[0].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[0].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[0].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[0].GetMeta("log_type") == "auth_success"
results[0].Overflow.Alert.Events[0].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[0].GetMeta("source_ip") == "1.2.3.4"
results[0].Overflow.Alert.Events[0].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[0].GetMeta("success") == "true"
results[0].Overflow.Alert.Events[0].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[0].Overflow.Alert.Events[0].GetMeta("user") == "root"
results[0].Overflow.Alert.Events[1].GetMeta("ASNNumber") == "0"
results[0].Overflow.Alert.Events[1].GetMeta("IsInEU") == "false"
results[0].Overflow.Alert.Events[1].GetMeta("IsoCode") == "US"
results[0].Overflow.Alert.Events[1].GetMeta("datasource_path") == "teleport-bf.log"
results[0].Overflow.Alert.Events[1].GetMeta("datasource_type") == "file"
results[0].Overflow.Alert.Events[1].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[0].Overflow.Alert.Events[1].GetMeta("log_type") == "auth_success"
results[0].Overflow.Alert.Events[1].GetMeta("service") == "teleport"
results[0].Overflow.Alert.Events[1].GetMeta("source_ip") == "9.8.8.8"
results[0].Overflow.Alert.Events[1].GetMeta("sub_type") == "user.login"
results[0].Overflow.Alert.Events[1].GetMeta("success") == "true"
results[0].Overflow.Alert.Events[1].GetMeta("timestamp") == "2023-09-05T07:16:26.133Z"
results[0].Overflow.Alert.Events[1].GetMeta("user") == "root"
results[0].Overflow.Alert.GetScenario() == "crowdsecurity/impossible-travel"
results[0].Overflow.Alert.Remediation == false
results[0].Overflow.Alert.GetEventsCount() == 2
"root" in results[1].Overflow.GetSources()
results[1].Overflow.Sources["root"].IP == ""
results[1].Overflow.Sources["root"].Range == ""
results[1].Overflow.Sources["root"].GetScope() == "username"
results[1].Overflow.Sources["root"].GetValue() == "root"
results[1].Overflow.Alert.Events[0].GetMeta("ASNNumber") == "0"
results[1].Overflow.Alert.Events[0].GetMeta("IsInEU") == "false"
results[1].Overflow.Alert.Events[0].GetMeta("IsoCode") == "AU"
results[1].Overflow.Alert.Events[0].GetMeta("datasource_path") == "teleport-bf.log"
results[1].Overflow.Alert.Events[0].GetMeta("datasource_type") == "file"
results[1].Overflow.Alert.Events[0].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[1].Overflow.Alert.Events[0].GetMeta("log_type") == "auth_success"
results[1].Overflow.Alert.Events[0].GetMeta("service") == "teleport"
results[1].Overflow.Alert.Events[0].GetMeta("source_ip") == "1.2.3.4"
results[1].Overflow.Alert.Events[0].GetMeta("sub_type") == "user.login"
results[1].Overflow.Alert.Events[0].GetMeta("success") == "true"
results[1].Overflow.Alert.Events[0].GetMeta("timestamp") == "2023-09-05T07:16:25.133Z"
results[1].Overflow.Alert.Events[0].GetMeta("user") == "root"
results[1].Overflow.Alert.Events[1].GetMeta("ASNNumber") == "0"
results[1].Overflow.Alert.Events[1].GetMeta("IsInEU") == "false"
results[1].Overflow.Alert.Events[1].GetMeta("IsoCode") == "US"
results[1].Overflow.Alert.Events[1].GetMeta("datasource_path") == "teleport-bf.log"
results[1].Overflow.Alert.Events[1].GetMeta("datasource_type") == "file"
results[1].Overflow.Alert.Events[1].GetMeta("http_user_agent") == "Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1"
results[1].Overflow.Alert.Events[1].GetMeta("log_type") == "auth_success"
results[1].Overflow.Alert.Events[1].GetMeta("service") == "teleport"
results[1].Overflow.Alert.Events[1].GetMeta("source_ip") == "9.8.8.8"
results[1].Overflow.Alert.Events[1].GetMeta("sub_type") == "user.login"
results[1].Overflow.Alert.Events[1].GetMeta("success") == "true"
results[1].Overflow.Alert.Events[1].GetMeta("timestamp") == "2023-09-05T07:16:26.133Z"
results[1].Overflow.Alert.Events[1].GetMeta("user") == "root"
results[1].Overflow.Alert.GetScenario() == "crowdsecurity/impossible-travel-user"
results[1].Overflow.Alert.Remediation == false
results[1].Overflow.Alert.GetEventsCount() == 2
2 changes: 2 additions & 0 deletions .tests/teleport-impossible-travel/teleport-bf.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:25.133Z","cluster_name":"teleport.home.example.com","user":"root","success":true,"method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"1.2.3.4:34204"}
{"ei":0,"event":"user.login","uid":"a487975c-a132-4b76-81c1-225284b2a129","code":"T1000W","time":"2023-09-05T07:16:26.133Z","cluster_name":"teleport.home.example.com","user":"root","success":true,"method":"local","user_agent":"Mozilla/5.0 (iPhone; CPU iPhone OS 16_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Mobile/15E148 Safari/604.1","addr.remote":"9.8.8.8:34204"}
13 changes: 13 additions & 0 deletions .tests/teleport-logs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
parsers:
- crowdsecurity/syslog-logs
- crowdsecurity/dateparse-enrich
- ./parsers/s01-parse/crowdsecurity/teleport-logs.yaml
scenarios:
- ""
postoverflows:
- ""
log_file: teleport-logs.log
log_type: teleport
labels: {}
ignore_parsers: false
override_statics: []
Loading