This article shows how to create an alert that monitors the presence of the files and configuration items on the assets that need to be there.
Query |
indicator,indicator_type,category,description 047ba849dddb852be8244c997a458e6870f9c4b9c2ffafed67a3d30030931eea,SHA- 256,mandatory_files,/etc/sudo-ldap.conf 0444c33410ee449e062fb6aa1ae604e10faf22eb7724b758dbd276c8c8516977,SHA- 256,mandatory_files,/etc/sudo.conf dbe696add0d4c25420245c2062a7cbd853e81e8bf062bda02fa943adb1aae30f,SHA- 256,mandatory_files,/etc/mtab |
Query SELECT *FROM hashWHERE path IN ( '/etc/sudo-ldap.conf', '/etc/sudo.conf', '/etc/mtab' )
Query |
SELECT * FROM file WHERE path IN ( '/etc/sudo-ldap.conf', '/etc/sudo.conf', '/etc/mtab' ) |
Query |
WITH assets AS (SELECT DISTINCT upt_asset_id FROM upt_asset_tags tags WHERE tag = 'ubuntu' ), files AS (SELECT description AS path_exp, indicator AS sha256_exp FROM upt_threat_indicators WHERE category = 'mandatory_files'), hash AS (SELECT upt_asset_id, path, Max_by(sha256, upt_time) sha256 FROM qp_mandatory_files_q_hash GROUP BY 1, 2) SELECT 'medium' AS severity, 'asset missing mandatory file' AS description, a.upt_asset_id, CURRENT_TIMESTAMP AS time, f.path_exp AS KEY, CASE WHEN f.sha256_exp = h.sha256 THEN 'file exists with expected hash' WHEN h.sha256 IS NULL THEN 'expected file doesnt exist' WHEN f.sha256_exp != h.sha256 THEN 'file exists with unexpected hash' END AS value FROM assets a CROSS JOIN files f LEFT JOIN hash h ON a.upt_asset_id = h.upt_asset_id AND f.path_exp = h.path WHERE sha256_exp <> COALESCE(sha256, '123') |