2023-01-13 16:21:48 +00:00
|
|
|
-- Indicative of stored GCP service account keys just sitting around unencrypted
|
|
|
|
--
|
|
|
|
-- tags: persistent state filesystem
|
|
|
|
-- platform: posix
|
|
|
|
SELECT
|
|
|
|
file.path,
|
|
|
|
file.type,
|
|
|
|
file.size,
|
|
|
|
file.mtime,
|
|
|
|
file.uid,
|
|
|
|
file.ctime,
|
|
|
|
file.gid,
|
|
|
|
hash.sha256,
|
2023-01-13 20:24:18 +00:00
|
|
|
magic.data
|
2023-01-13 16:21:48 +00:00
|
|
|
FROM
|
|
|
|
file
|
|
|
|
LEFT JOIN hash ON file.path = hash.path
|
|
|
|
LEFT JOIN users u ON file.uid = u.uid
|
|
|
|
LEFT JOIN magic ON file.path = magic.path
|
|
|
|
WHERE
|
|
|
|
(
|
|
|
|
file.directory LIKE '/Users/%/Downloads/%'
|
|
|
|
OR file.directory LIKE '/home/%/%'
|
|
|
|
OR file.directory LIKE '/home/%/'
|
|
|
|
OR file.directory LIKE '/home/%/.%'
|
|
|
|
OR file.directory LIKE '/home/%/Downloads/%'
|
|
|
|
OR file.directory LIKE '/tmp/%'
|
|
|
|
OR file.directory LIKE '/tmp/'
|
|
|
|
OR file.directory LIKE '/Users/%/%'
|
|
|
|
OR file.directory LIKE '/Users/%/'
|
|
|
|
OR file.directory LIKE '/Users/%/.%'
|
|
|
|
OR file.directory LIKE '/var/tmp/%'
|
|
|
|
OR file.directory LIKE '/var/tmp/'
|
|
|
|
)
|
|
|
|
AND file.directory NOT LIKE "%/../%"
|
|
|
|
AND file.directory NOT LIKE "%/./%"
|
|
|
|
AND filename LIKE "%-%-%.json"
|
|
|
|
AND size BETWEEN 2311 AND 2385
|
|
|
|
-- Don't alert on tokens that begin with the username-, as they may be personal
|
2023-01-20 14:24:24 +00:00
|
|
|
AND NOT INSTR(filename, CONCAT (u.username, "-")) == 1
|
2023-01-13 16:21:48 +00:00
|
|
|
-- Don't alert on tokens that begin with the users full name and a dash
|
2023-01-20 14:24:24 +00:00
|
|
|
AND NOT INSTR(
|
|
|
|
filename,
|
|
|
|
REPLACE(LOWER(TRIM(description)), " ", "-")
|
|
|
|
) == 1
|
2023-05-02 21:49:53 +00:00
|
|
|
-- Demo keys
|
2023-05-05 16:44:46 +00:00
|
|
|
AND NOT file.filename LIKE 'host-project-%'
|
2023-05-05 19:10:54 +00:00
|
|
|
AND NOT file.filename LIKE 'ulabs-%'
|
2023-05-02 21:49:53 +00:00
|
|
|
AND NOT hash.sha256 IN (
|
|
|
|
"c7d6bac8e942511e25973889ac38656d4d46f68044650d694721017fda23716e",
|
2023-05-05 19:10:54 +00:00
|
|
|
"bd5f4c01ebb5636b94584ee4ae42514b27d371859f7344f6aa5a37332ee714ba",
|
2023-05-02 21:49:53 +00:00
|
|
|
"bd5f4c01ebb5636b94584ee4ae42514b27d371859f7344f6aa5a37332ee714ba"
|
2023-05-05 16:44:46 +00:00
|
|
|
)
|