{"id":11855,"date":"2022-07-30T08:53:21","date_gmt":"2022-07-30T05:53:21","guid":{"rendered":"https:\/\/kifarunix.com\/?p=11855"},"modified":"2024-03-09T16:16:02","modified_gmt":"2024-03-09T13:16:02","slug":"monitor-changes-to-critical-files-on-windows-systems-using-wazuh-and-elk","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/monitor-changes-to-critical-files-on-windows-systems-using-wazuh-and-elk\/","title":{"rendered":"Monitor Changes to Critical Files on Windows Systems using Wazuh and ELK"},"content":{"rendered":"\n
In this tutorial, you will learn how to monitor changes to critical files on Windows systems using Wazuh and ELK Stack. <\/em>File operations are logged when a file is created, updated, overwritten or deleted. Such file changes events are useful for monitoring files under the directories such as the startup folders, download, temporary directories or any other custom directory.<\/em> File\/Folder activities are part of the file integrity monitoring (FIM) and registry change monitoring<\/a><\/em>. Thus, to detect changes to these critical files, file integrity monitoring against the folder where these critical files resides needs to be enabled.<\/p>\n\n\n\n In order to monitor changes to critical files on Windows systems, you need to collect the events associated with the changes made and push them to Wazuh Manager for visualization on Kibana Wazuh app.<\/p>\n\n\n\n Thus before you begin, ensure that you have ELK Stack integrated with Wazuh manager and is up and running. See example tutorials below;<\/p>\n\n\n\n Integrate Wazuh Manager with ELK Stack<\/a><\/p>\n\n\n\n Install Wazuh Server on Rocky Linux 8<\/a><\/p>\n\n\n\n NOTE: We are running ELK 7.17.0 and Wazuh Manager 4.3.6.<\/p>\n\n\n\n Kibana (ELK) version;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n Wazuh Manager version;<\/p>\n\n\n\n Sample output;<\/p>\n\n\n\n In this example setup, I will be using Windows 10 system for demonstration purposes.<\/p>\n\n\n\n To install Wazuh agent on Windows 10 and automatically add it to Wazuh manager, then;<\/p>\n\n\n\n It should also be showing on the Kibana Wazuh App.<\/p>\n\n\n\n To confirm on Wazuh Manager command line;<\/p>\n\n\n\n You should see it among the active agents.<\/p>\n\n\n\n By default, Wazuh enables file integrity monitoring for some system files as defined in the So how can you add your custom folders in to the configuration for file integrity monitoring?<\/p>\n\n\n\n Let’s assume we have a folder, This is how I placed the above line in the Once you have made the changes to the configuration file, restart the agent. You can execute the command below on Powershell as administrator;<\/p>\n\n\n\n Check the status of the service;<\/p>\n\n\n\n If the service stops for any reason, be sure to check the agent logs to find out what the problem is.<\/p>\n\n\n\n Under our custom folder, So, try to make some changes in the file001.txt and file002.txt.<\/p>\n\n\n\n Immediately, you should be able to see the changes on the Wazuh dashboard. Select the respective agent and navigate to integrity monitoring<\/strong> dashboard;<\/p>\n\n\n\n Let’s check the related events under Events<\/strong> tab for more information;<\/p>\n\n\n\n As you can see, it shows files added, deleted and those modified.<\/p>\n\n\n\n Let’s check the file modification events. For file001.txt, we added a line. For file002.txt, we removed some line.<\/p>\n\n\n\n So, expand these two events. You will notice under File001.txt;<\/p>\n\n\n\n File002.txt;<\/p>\n\n\n\n Awesome, isn’t it?<\/p>\n\n\n\n And that is how you can easily monitor changes to critical files on Windows systems.<\/p>\n\n\n\n Monitor Process Creation Events on Windows Systems using Wazuh and ELK stack<\/a><\/p>\n\n\n\n Process ModSecurity Logs using Wazuh<\/a><\/a><\/p>\n","protected":false},"excerpt":{"rendered":" In this tutorial, you will learn how to monitor changes to critical files on Windows systems using Wazuh and ELK Stack. File operations are logged<\/p>\n","protected":false},"author":3,"featured_media":13594,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[72,121,34],"tags":[5599,5598,5600,5602,5601],"class_list":["post-11855","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-monitoring","category-howtos","category-security","tag-detect-file-changes-using-wazuh-on-windows","tag-monitor-changes-to-critical-files-on-windows-systems-using-wazuh-and-elk","tag-monitor-file-changes-using-wazuh-on-windows","tag-monitoring-file-integrity-with-wazuh","tag-windows-file-integrity-monitoring-with-wazuh","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11855"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=11855"}],"version-history":[{"count":22,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11855\/revisions"}],"predecessor-version":[{"id":20583,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/11855\/revisions\/20583"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/13594"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=11855"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=11855"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=11855"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}Monitor Changes to Critical Files on Windows Systems using Wazuh and ELK<\/h2>\n\n\n\n
Install and Integrate Wazuh Manager with ELK Stack<\/h3>\n\n\n\n
cat \/usr\/share\/kibana\/package.json | grep version<\/code><\/pre>\n\n\n\n
\"version\": \"7.17.0\",<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/wazuh-control info | grep WAZUH_VERSION<\/code><\/pre>\n\n\n\n
WAZUH_VERSION=\"v4.3.6\"<\/code><\/pre>\n\n\n\n
Install Wazuh Agents on Windows Systems<\/h3>\n\n\n\n
\n
<\/figure><\/a><\/div>\n\n\n\n
\n
<\/figure><\/a><\/div>\n\n\n\n
Invoke-WebRequest -Uri `\nhttps:\/\/packages.wazuh.com\/4.x\/windows\/wazuh-agent-4.3.6-1.msi `\n-OutFile ${env:tmp}\\wazuh-agent-4.3.6.msi; msiexec.exe \/i ${env:tmp}\\wazuh-agent-4.3.6.msi `\n\/q WAZUH_MANAGER='192.168.58.22' WAZUH_REGISTRATION_SERVER='192.168.58.22' <\/code><\/pre>\n\n\n\n
\n
NET START WazuhSvc<\/code><\/pre>\n\n\n\n
\/var\/ossec\/bin\/agent_control -l<\/code><\/pre>\n\n\n\n
Wazuh agent_control. List of available agents:\n ID: 000, Name: debian11 (server), IP: 127.0.0.1, Active\/Local\n ID: 001, Name: DESKTOP-JQ6I3Q8, IP: any, Active<\/strong>\n\nList of agentless devices:<\/code><\/pre>\n\n\n\n
Enable File Integrity Monitoring on Folders Containing Critical Files<\/h3>\n\n\n\n
<!-- File integrity monitoring --><\/code> section of the
ossec.conf<\/strong><\/code> configuration file;<\/p>\n\n\n\n
\n <!-- File integrity monitoring -->\n <syscheck>\n\n <disabled>no<\/disabled>\n\n <!-- Frequency that syscheck is executed default every 12 hours -->\n <frequency>43200<\/frequency>\n\n <!-- Default files to be monitored. -->\n <directories recursion_level=\"0\" restrict=\"regedit.exe$|system.ini$|win.ini$\">%WINDIR%<\/directories>\n\n <directories recursion_level=\"0\" restrict=\"at.exe$|attrib.exe$|cacls.exe$|cmd.exe$|eventcreate.exe$|ftp.exe$|lsass.exe$|net.exe$|net1.exe$|netsh.exe$|reg.exe$|regedt32.exe|regsvr32.exe|runas.exe|sc.exe|schtasks.exe|sethc.exe|subst.exe$\">%WINDIR%\\SysNative<\/directories>\n <directories recursion_level=\"0\">%WINDIR%\\SysNative\\drivers\\etc<\/directories>\n <directories recursion_level=\"0\" restrict=\"WMIC.exe$\">%WINDIR%\\SysNative\\wbem<\/directories>\n <directories recursion_level=\"0\" restrict=\"powershell.exe$\">%WINDIR%\\SysNative\\WindowsPowerShell\\v1.0<\/directories>\n <directories recursion_level=\"0\" restrict=\"winrm.vbs$\">%WINDIR%\\SysNative<\/directories>\n\n <!-- 32-bit programs. -->\n <directories recursion_level=\"0\" restrict=\"at.exe$|attrib.exe$|cacls.exe$|cmd.exe$|eventcreate.exe$|ftp.exe$|lsass.exe$|net.exe$|net1.exe$|netsh.exe$|reg.exe$|regedit.exe$|regedt32.exe$|regsvr32.exe$|runas.exe$|sc.exe$|schtasks.exe$|sethc.exe$|subst.exe$\">%WINDIR%\\System32<\/directories>\n <directories recursion_level=\"0\">%WINDIR%\\System32\\drivers\\etc<\/directories>\n <directories recursion_level=\"0\" restrict=\"WMIC.exe$\">%WINDIR%\\System32\\wbem<\/directories>\n <directories recursion_level=\"0\" restrict=\"powershell.exe$\">%WINDIR%\\System32\\WindowsPowerShell\\v1.0<\/directories>\n <directories recursion_level=\"0\" restrict=\"winrm.vbs$\">%WINDIR%\\System32<\/directories>\n\n <directories realtime=\"yes\">%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup<\/directories>\n\n <ignore>%PROGRAMDATA%\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\desktop.ini<\/ignore>\n\n <ignore type=\"sregex\">.log$|.htm$|.jpg$|.png$|.chm$|.pnf$|.evtx$<\/ignore>\n\n <!-- Windows registry entries to monitor. -->\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\batfile<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\cmdfile<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\comfile<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\exefile<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\piffile<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\AllFilesystemObjects<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\Directory<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Classes\\Folder<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Classes\\Protocols<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Policies<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Security<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Internet Explorer<\/windows_registry>\n\n <windows_registry>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\Session Manager\\KnownDLLs<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Control\\SecurePipeServers\\winreg<\/windows_registry>\n\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce<\/windows_registry>\n <windows_registry>HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\URL<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Windows<\/windows_registry>\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon<\/windows_registry>\n\n <windows_registry arch=\"both\">HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Active Setup\\Installed Components<\/windows_registry>\n\n <!-- Windows registry entries to ignore. -->\n <registry_ignore>HKEY_LOCAL_MACHINE\\Security\\Policy\\Secrets<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\Security\\SAM\\Domains\\Account\\Users<\/registry_ignore>\n <registry_ignore type=\"sregex\">\\Enum$<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\AppCs<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\PortKeywords\\DHCP<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\PortKeywords\\IPTLSIn<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\PortKeywords\\IPTLSOut<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\PortKeywords\\RPC-EPMap<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\MpsSvc\\Parameters\\PortKeywords\\Teredo<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\PolicyAgent\\Parameters\\Cache<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\RunOnceEx<\/registry_ignore>\n <registry_ignore>HKEY_LOCAL_MACHINE\\System\\CurrentControlSet\\Services\\ADOVMPPackage\\Final<\/registry_ignore>\n\n <!-- Frequency for ACL checking (seconds) -->\n <windows_audit_interval>60<\/windows_audit_interval>\n\n <!-- Nice value for Syscheck module -->\n <process_priority>10<\/process_priority>\n\n <!-- Maximum output throughput -->\n <max_eps>100<\/max_eps>\n\n <!-- Database synchronization settings -->\n <synchronization>\n <enabled>yes<\/enabled>\n <interval>5m<\/interval>\n <max_interval>1h<\/max_interval>\n <max_eps>10<\/max_eps>\n <\/synchronization>\n <\/syscheck>\n<\/code><\/pre>\n\n\n\n
C:\\FIM<\/code>, for example, that you would like to monitor all the changes in the files within it, then you can add the following configuration line into the
<syscheck> <\/syscheck><\/strong><\/code> section.<\/p>\n\n\n\n
<directories check_all=\"yes\" realtime=\"yes\" report_changes=\"yes\">C:\\FIM<\/directories><\/code><\/pre>\n\n\n\n
\n
check_all<\/code><\/strong>: Enables the following check_* options;
check_sum, check_sha1sum, check_md5sum, check_size, check_owner, check_group, check_perm<\/code>.<\/li>\n\n\n\n
realtime<\/code><\/strong>: Enables realtime\/continuous monitoring.<\/li>\n\n\n\n
report_changes<\/strong><\/code>: Report diffs of file changes\/registry value changes.<\/li>\n<\/ul>\n\n\n\n
C:\\Program Files (x86)\\ossec-agent\\ossec.conf<\/code>;<\/p>\n\n\n\n
\n <!-- File integrity monitoring -->\n <syscheck>\n\n <disabled>no<\/disabled>\n\n <!-- Frequency that syscheck is executed default every 12 hours -->\n <frequency>43200<\/frequency>\n \n <!-- Custom Folder -->\n <directories check_all=\"yes\" realtime=\"yes\" report_changes=\"yes\">C:\\FIM<\/directories>\n<\/strong>\n <!-- Default files to be monitored. -->\n <directories recursion_level=\"0\" restrict=\"regedit.exe$|system.ini$|win.ini$\">%WINDIR%<\/directories>\n...\n<\/code><\/pre>\n\n\n\n
Restart-Service WazuhSvc<\/code><\/pre>\n\n\n\n
Get-Service WazuhSvc<\/code><\/pre>\n\n\n\n
Simulate Changes to Critical Files;<\/h3>\n\n\n\n
C:\\FIM<\/code>, we have two files;<\/p>\n\n\n\n
ls C:\\FIM<\/code><\/pre>\n\n\n\n
\n\n\n Directory: C:\\FIM\n\n\nMode LastWriteTime Length Name\n---- ------------- ------ ----\n-a---- 7\/30\/2022 7:40 AM 667 file001.txt\n-a---- 7\/30\/2022 7:40 AM 667 file002.txt\n<\/code><\/pre>\n\n\n\n
\n
echo \"This is a tes FIM line 001\" >> 'C:\\FIM\\file001.txt'<\/code><\/pre>\n\n\n\n
\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
syscheck.diffs<\/code> field you will see what changes are actually made on the files.<\/p>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
<\/figure><\/a><\/div>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n