Hi Fede,Thanks a lot for the prompt response.Sure . Please find below the sample log lines for your reference.Let me know, if i can use this idea, Actually from keycloak we are getting a WARN header for all kind of error messages, I taught of building a decoder to catch the "type=REFRESH TOKEN ERROR" and order userid and ip address. Rule to say the user has a refresh token error in the below example log. And i can replicate this scenario for authentication issues as a bruteforce rule or multiple login request as a DDOS attack.2023-10-17T12:34:02+02:00 2023-10-17 10:34:02,934 WARN [org.keycloak.events] (executor-thread-1353) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=MSTeamsDevAdra, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:03+02:00 2023-10-17 10:34:03,097 WARN [org.keycloak.events] (executor-thread-1443) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=MSTeamsDevAdra, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,731 WARN [org.keycloak.events] (executor-thread-1353) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,762 WARN [org.keycloak.events] (executor-thread-1622) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,789 WARN [org.keycloak.events] (executor-thread-1622) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,819 WARN [org.keycloak.events] (executor-thread-1622) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,950 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1443) getUserId: url: http://user-lookup/user/v1/bylogin/environment1/<User id> responseCode: 200
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,951 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1443) getFedInfo: result: FederatedInfo {userId=<User id>, email=<Email ID>, federatedId=<Email ID>, roles=[agent, org_admin, crm_connect_user, sms_sender, webphone_user, teams_user, user]}
2023-10-17T12:34:07+02:00 2023-10-17 10:34:07,959 WARN [org.keycloak.events] (executor-thread-1443) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=f:332e251e-df78-4431-a79f-f46833c95204:<User id>, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, refresh_token_type=Offline, refresh_token_id=1faa9072-9899-4d37-986d-e20422d5f0ce, client_auth_method=client-secret
2023-10-17T12:34:08+02:00 2023-10-17 10:34:08,092 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1443) getUserId: url: http://user-lookup/user/v1/bylogin/environment1/<User ID> responseCode: 200
2023-10-17T12:34:08+02:00 2023-10-17 10:34:08,092 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1443) getFedInfo: result: FederatedInfo {userId=<User ID>, email=<Email ID>, federatedId=<Email ID>, roles=[agent, org_admin, crm_connect_user, sms_sender, webphone_user, teams_user, user, supervisor]}
2023-10-17T12:34:08+02:00 2023-10-17 10:34:08,097 WARN [org.keycloak.events] (executor-thread-1443) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=f:332e251e-df78-4431-a79f-f46833c95204:<User ID>, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, refresh_token_type=Offline, refresh_token_id=5316b922-1885-4cc8-b4d4-9531ae21648e, client_auth_method=client-secret
2023-10-17T12:34:13+02:00 2023-10-17 10:34:13,224 WARN [org.keycloak.events] (executor-thread-1622) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=MSTeamsDevAdra, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:13+02:00 2023-10-17 10:34:13,389 WARN [org.keycloak.events] (executor-thread-1353) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=MSTeamsDevAdra, userId=null, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, client_auth_method=client-secret
2023-10-17T12:34:17+02:00 2023-10-17 10:34:17,567 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1353) getUserId: url: http://user-lookup/user/v1/bylogin/environment1/<User ID> responseCode: 200
2023-10-17T12:34:17+02:00 2023-10-17 10:34:17,567 INFO [com.telepo.iam.keycloak.provider.storage provider] (executor-thread-1353) getFedInfo: result: FederatedInfo {userId=<User ID>, email=<Email ID>, federatedId=<Email ID>, roles=[agent, org_admin, crm_connect_user, sms_sender, webphone_user, teams_user, user, supervisor]}
2023-10-17T12:34:17+02:00 2023-10-17 10:34:17,574 WARN [org.keycloak.events] (executor-thread-1353) type=REFRESH_TOKEN_ERROR, realmId=environment1, clientId=teams, userId=f:332e251e-df78-4431-a79f-f46833c95204:<User ID>, ipAddress=<ip address>, error=invalid_token, grant_type=refresh_token, refresh_token_type=Offline, refresh_token_id=46d5822c-2f27-4b20-979d-b18a83bce477, client_auth_method=client-secretRegards,jai.
--
You received this message because you are subscribed to a topic in the Google Groups "Wazuh | Mailing List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/wazuh/pj3Y9DxFHEA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/0e109032-5046-4f5e-b803-3409c118eb26n%40googlegroups.com.
![]() |
|
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/26661dcb-1ccb-4019-afd6-eddc41b5c3d5n%40googlegroups.com.
I tried enabling the log_all attribute.
When I checked the ossec.log in the agent, I caught an error message saying the logcollector cannot read the log file. Now I fixed the issue, the agent is able to read the logs now I confirmed it from the ossec.log file from the agent. But in the archives.json file in manager, there is no log from the specific monitored keycloak log file. But there are logs regarding the rootcheck, syslog monitoring from the syslog logs.
Hi Federico,I have set all the changes and still no logs are processed from the keycloak log. Please find below the agent conf file.<!--
Wazuh - Agent - Default configuration for darwin 22.6
More info at: https://documentation.wazuh.com
Mailing list: https://groups.google.com/forum/#!forum/wazuh
-->
<ossec_config>
<client>
<server>
<address>managerip</address>
<port>1514</port>
<protocol>tcp</protocol>
</server>
<config-profile>darwin, darwin22, darwin22.6</config-profile>
<notify_time>10</notify_time>
<time-reconnect>60</time-reconnect>
<auto_restart>yes</auto_restart>
<crypto_method>aes</crypto_method>
</client>
<client_buffer>
<!-- Agent buffer options -->
<disabled>no</disabled>
<queue_size>5000</queue_size>
<events_per_second>500</events_per_second>
</client_buffer>
<!-- Policy monitoring -->
<rootcheck>
<disabled>no</disabled>
<check_files>yes</check_files>
<check_trojans>yes</check_trojans>
<check_dev>yes</check_dev>
<check_sys>yes</check_sys>
<check_pids>yes</check_pids>
<check_ports>yes</check_ports>
<check_if>yes</check_if>
<!-- Frequency that rootcheck is executed - every 12 hours -->
<frequency>43200</frequency>
<rootkit_files>etc/shared/rootkit_files.txt</rootkit_files>
<rootkit_trojans>etc/shared/rootkit_trojans.txt</rootkit_trojans>
<skip_nfs>yes</skip_nfs>
</rootcheck>
<!-- Osquery integration -->
<wodle name="osquery">
<disabled>yes</disabled>
<run_daemon>yes</run_daemon>
<log_path>/var/log/osquery/osqueryd.results.log</log_path>
<config_path>/etc/osquery/osquery.conf</config_path>
<add_labels>yes</add_labels>
</wodle>
<!-- System inventory -->
<wodle name="syscollector">
<disabled>no</disabled>
<interval>1h</interval>
<scan_on_start>yes</scan_on_start>
<hardware>yes</hardware>
<os>yes</os>
<network>yes</network>
<packages>yes</packages>
<ports all="no">yes</ports>
<processes>yes</processes>
<!-- Database synchronization settings -->
<synchronization>
<max_eps>10</max_eps>
</synchronization>
</wodle>
<sca>
<enabled>yes</enabled>
<scan_on_start>yes</scan_on_start>
<interval>12h</interval>
<skip_nfs>yes</skip_nfs>
</sca>
<sca>
<policies>
<policy enabled="yes">/Library/Ossec/etc/custom-sca-files/keywordcheck.yml</policy>
</policies>
</sca>
<!-- File integrity monitoring -->
<syscheck>
<disabled>no</disabled>
<!-- Frequency that syscheck is executed default every 12 hours -->
<frequency>900</frequency>
<scan_on_start>yes</scan_on_start>
<!-- Directories to check (perform all possible verifications) -->
<directories>/etc,/usr/bin,/usr/sbin</directories>
<directories>/bin,/sbin</directories>
<directories><path>/wazuhcheck.txt</directories>
<!-- <directories realtime="yes"><path>/Desktop</directories> -->
<directories check_all="yes" report_changes="yes">wazuhcheck.txt</directories>
<!-- Files/directories to ignore -->
<ignore>/etc/mtab</ignore>
<ignore>/etc/hosts.deny</ignore>
<ignore>/etc/mail/statistics</ignore>
<ignore>/etc/random-seed</ignore>
<ignore>/etc/random.seed</ignore>
<ignore>/etc/adjtime</ignore>
<ignore>/etc/httpd/logs</ignore>
<ignore>/etc/utmpx</ignore>
<ignore>/etc/wtmpx</ignore>
<ignore>/etc/cups/certs</ignore>
<ignore>/etc/dumpdates</ignore>
<ignore>/etc/svc/volatile</ignore>
<!-- File types to ignore -->
<ignore type="sregex">.log$|.swp$</ignore>
<!-- Check the file, but never compute the diff -->
<nodiff>/etc/ssl/private.key</nodiff>
<skip_nfs>yes</skip_nfs>
<skip_dev>yes</skip_dev>
<skip_proc>yes</skip_proc>
<skip_sys>yes</skip_sys>
<!-- Nice value for Syscheck process -->
<process_priority>10</process_priority>
<!-- Maximum output throughput -->
<max_eps>100</max_eps>
<!-- Database synchronization settings -->
<synchronization>
<enabled>yes</enabled>
<interval>5m</interval>
<max_interval>1h</max_interval>
<max_eps>10</max_eps>
</synchronization>
</syscheck>
<!-- Log analysis -->
<localfile>
<log_format>full_command</log_format>
<command>netstat -an | awk '{if ((/^(tcp|udp)/) && ($4 != "*.*") && ($5 == "*.*")) {print $1" "$4" "$5}}' | sort -u</command>
<alias>netstat listening ports</alias>
<frequency>360</frequency>
</localfile>
<localfile>
<location>macos</location>
<log_format>macos</log_format>
<query type="trace,log,activity" level="info">(process == "sudo") or (process == "sessionlogoutd" and message contains "logout is complete.") or (process == "sshd") or (process == "tccd" and message contains "Update Access Record") or (message contains "SessionAgentNotificationCenter") or (process == "screensharingd" and message contains "Authentication") or (process == "securityd" and eventMessage contains "Session" and subsystem == "com.apple.securityd")</query>
</localfile>
<localfile>
<location>/var/log/system.log</location>
<log_format>syslog</log_format>
</localfile>
<localfile>
<location><path>/keycloak.log</location>
<log_format>syslog</log_format>
</localfile>
<!-- Active response -->
<active-response>
<disabled>no</disabled>
<ca_store>etc/wpk_root.pem</ca_store>
<ca_verification>yes</ca_verification>
</active-response>
<!-- Choose between "plain", "json", or "plain,json" for the format of internal logs -->
<logging>
<log_format>plain</log_format>
</logging>
</ossec_config>
Hi Fede,I truncated the path as it has my sensitive information and masked it with the <path>. But in my configuration i have given the whole relative path there instead of <path>.Regards,jai.
<localfile>
<location>/Users/user/Desktop/keycloak.log</location>
<log_format>syslog</log_format>
</localfile>
<localfile>
<location>----</location>
<log_format>syslog</log_format>
</localfile>
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/7fc5ba00-2d08-45ae-b811-7c99710abedcn%40googlegroups.com.