2023-01-18 19:10:33 +00:00
|
|
|
-- Find unexpected hidden directories in operating-system foldersbin/
|
2022-10-14 18:19:13 +00:00
|
|
|
--
|
2022-10-18 14:08:34 +00:00
|
|
|
-- references:
|
|
|
|
-- * https://themittenmac.com/what-does-apt-activity-look-like-on-macos/
|
|
|
|
--
|
2022-10-14 18:19:13 +00:00
|
|
|
-- false positives:
|
|
|
|
-- * unusual installers
|
|
|
|
--
|
2022-10-18 14:08:34 +00:00
|
|
|
-- platform: posix
|
2022-10-14 18:19:13 +00:00
|
|
|
-- tags: persistent filesystem state
|
2023-01-20 14:24:24 +00:00
|
|
|
SELECT
|
|
|
|
file.path,
|
2023-02-17 15:41:42 +00:00
|
|
|
file.inode,
|
2022-10-18 18:26:47 +00:00
|
|
|
file.directory,
|
2022-09-24 15:12:23 +00:00
|
|
|
uid,
|
|
|
|
gid,
|
|
|
|
mode,
|
|
|
|
mtime,
|
2023-01-19 16:42:44 +00:00
|
|
|
((strftime('%s', 'now') - file.ctime) / 86400) AS mtime_age_days,
|
2022-09-24 15:12:23 +00:00
|
|
|
ctime,
|
|
|
|
type,
|
|
|
|
size,
|
|
|
|
hash.sha256,
|
|
|
|
magic.data
|
2023-01-20 14:24:24 +00:00
|
|
|
FROM
|
|
|
|
file
|
2022-09-24 15:12:23 +00:00
|
|
|
LEFT JOIN hash ON file.path = hash.path
|
|
|
|
LEFT JOIN magic ON file.path = magic.path
|
2023-01-20 14:24:24 +00:00
|
|
|
WHERE
|
|
|
|
(
|
2022-10-13 18:59:32 +00:00
|
|
|
file.path LIKE '/lib/.%'
|
|
|
|
OR file.path LIKE '/.%'
|
|
|
|
OR file.path LIKE '/bin/%/.%'
|
2022-10-18 18:26:47 +00:00
|
|
|
OR file.path LIKE '/dev/.%'
|
|
|
|
OR file.path LIKE '/etc/.%'
|
|
|
|
OR file.path LIKE '/etc/%/.%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR file.path LIKE '/lib/%/.%'
|
|
|
|
OR file.path LIKE '/libexec/.%'
|
|
|
|
OR file.path LIKE '/Library/.%'
|
|
|
|
OR file.path LIKE '/sbin/.%'
|
|
|
|
OR file.path LIKE '/sbin/%/.%'
|
|
|
|
OR file.path LIKE '/tmp/.%'
|
|
|
|
OR file.path LIKE '/usr/bin/.%'
|
|
|
|
OR file.path LIKE '/usr/lib/.%'
|
|
|
|
OR file.path LIKE '/usr/lib/%/.%'
|
|
|
|
OR file.path LIKE '/usr/libexec/.%'
|
|
|
|
OR file.path LIKE '/usr/local/bin/.%'
|
|
|
|
OR file.path LIKE '/usr/local/lib/.%'
|
|
|
|
OR file.path LIKE '/usr/local/lib/.%'
|
|
|
|
OR file.path LIKE '/usr/local/libexec/.%'
|
|
|
|
OR file.path LIKE '/usr/local/sbin/.%'
|
|
|
|
OR file.path LIKE '/usr/sbin/.%'
|
|
|
|
OR file.path LIKE '/var/.%'
|
2023-01-19 16:42:44 +00:00
|
|
|
OR file.path LIKE '/var/%/.%'
|
2022-10-13 18:59:32 +00:00
|
|
|
OR file.path LIKE '/var/lib/.%'
|
|
|
|
OR file.path LIKE '/var/tmp/.%'
|
2023-01-19 16:42:44 +00:00
|
|
|
)
|
|
|
|
AND file.path NOT LIKE '%/../'
|
|
|
|
AND file.path NOT LIKE '%/./' -- Avoid mentioning extremely temporary files
|
2022-10-13 18:59:32 +00:00
|
|
|
AND strftime('%s', 'now') - file.ctime > 20
|
2022-09-24 15:12:23 +00:00
|
|
|
AND file.path NOT IN (
|
2022-10-13 18:59:32 +00:00
|
|
|
'/.autorelabel',
|
|
|
|
'/dev/.mdadm/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/etc/.clean',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/etc/.java/',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/etc/.resolv.conf.systemd-resolved.bak',
|
2022-10-19 19:26:03 +00:00
|
|
|
'/etc/selinux/.config_backup',
|
|
|
|
'/etc/skel/.mozilla/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/.file',
|
2023-02-03 02:46:53 +00:00
|
|
|
'/lib/jvm/.java-1.17.0-openjdk-amd64.jinfo',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/tmp/._contentbarrier_installed',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.dotnet/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/tmp/.dracula-tmux-data',
|
|
|
|
'/tmp/.dracula-tmux-weather.lock',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/tmp/.DS_Store',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.font-unix/',
|
2023-01-23 13:13:04 +00:00
|
|
|
'/tmp/.go-version',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.ICE-unix/',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/tmp/.terraform/',
|
|
|
|
'/tmp/.terraform.lock.hcl',
|
2023-02-17 17:03:36 +00:00
|
|
|
'/tmp/.last_update_check.json',
|
|
|
|
'/tmp/.last_survey_prompt.yaml',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.Test-unix/',
|
2023-03-14 23:00:44 +00:00
|
|
|
'/tmp/.docker/',
|
|
|
|
'/tmp/.docker-tmp/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/tmp/.vbox-t-ipc/',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.X0-lock',
|
|
|
|
'/tmp/.X11-unix/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/tmp/.X1-lock',
|
2023-02-08 19:37:09 +00:00
|
|
|
'/tmp/.eos-update-notifier.log',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/tmp/.X2-lock',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/tmp/.XIM-unix/',
|
2023-02-03 02:46:53 +00:00
|
|
|
'/usr/lib/jvm/.java-1.17.0-openjdk-amd64.jinfo',
|
|
|
|
'/var/db/.AppleInstallType.plist',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/var/db/.AppleUpgrade',
|
|
|
|
'/var/db/.com.apple.iokit.graphics',
|
|
|
|
'/var/db/.GKRearmTimer',
|
|
|
|
'/var/db/.LastGKApp',
|
|
|
|
'/var/db/.LastGKReject',
|
|
|
|
'/var/db/.MASManifest',
|
2023-01-26 16:40:54 +00:00
|
|
|
'/var/db/.SoftwareUpdateOptions',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/var/db/.StagedAppleUpgrade',
|
|
|
|
'/var/db/.SystemPolicy-default',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/var/.ntw_cache',
|
2023-02-17 16:57:23 +00:00
|
|
|
'/var/setup/.TemporaryItems',
|
2022-10-13 18:59:32 +00:00
|
|
|
'/var/.Parallels_swap/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/var/.pwd_cache',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/var/root/.bash_history',
|
2023-02-03 02:46:53 +00:00
|
|
|
'/var/root/.bash_profile',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/var/root/.cache/',
|
|
|
|
'/var/root/.CFUserTextEncoding',
|
|
|
|
'/var/root/.forward',
|
|
|
|
'/var/root/.nix-channels',
|
|
|
|
'/var/root/.nix-defexpr/',
|
|
|
|
'/var/root/.nix-profile/',
|
|
|
|
'/var/root/.osquery/',
|
|
|
|
'/var/root/.Trash/',
|
2023-02-03 02:46:53 +00:00
|
|
|
'/var/root/.viminfo',
|
2023-01-19 16:42:44 +00:00
|
|
|
'/var/run/.heim_org.h5l.kcm-socket',
|
|
|
|
'/var/run/.sim_diagnosticd_socket',
|
|
|
|
'/var/run/.vfs_rsrc_streams_0x2b725bbfb94ba4ef0/',
|
2023-02-03 02:46:53 +00:00
|
|
|
'/var/setup/.AppleSetupUser',
|
2023-03-06 20:11:11 +00:00
|
|
|
'/var/setup/.TemporaryItems/',
|
2022-10-18 18:26:47 +00:00
|
|
|
'/.vol/',
|
|
|
|
'/.VolumeIcon.icns'
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-10-18 18:26:47 +00:00
|
|
|
AND file.directory NOT IN ('/etc/skel', '/etc/skel/.config')
|
|
|
|
AND file.path NOT LIKE '/%bin/bootstrapping/.default_components'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.#%'
|
2023-01-13 20:24:18 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.wine-%'
|
2022-10-18 18:26:47 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.%.gcode'
|
2022-10-19 19:26:03 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.vbox-%-ipc/'
|
2023-01-18 19:10:33 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.io.nwjs.%'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.com.google.Chrome.%'
|
|
|
|
AND file.path NOT LIKE '/tmp/.org.chromium.Chromium%'
|
2023-02-24 21:30:17 +00:00
|
|
|
AND file.path NOT LIKE '/var/run/.vfs_rsrc_streams_%/'
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.path NOT LIKE '/tmp/.X1%-lock'
|
|
|
|
AND file.path NOT LIKE '/usr/local/%/.keepme'
|
|
|
|
AND file.path NOT LIKE '%/.build-id/'
|
|
|
|
AND file.path NOT LIKE '%/.dwz/'
|
|
|
|
AND file.path NOT LIKE '%/.updated'
|
|
|
|
AND file.path NOT LIKE '%/google-cloud-sdk/.install/'
|
2022-09-24 15:12:23 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
type = 'regular'
|
2022-09-24 15:12:23 +00:00
|
|
|
AND (
|
2022-10-13 18:59:32 +00:00
|
|
|
filename LIKE '%.swp'
|
2022-09-24 15:12:23 +00:00
|
|
|
OR size < 2
|
2022-08-31 18:34:42 +00:00
|
|
|
)
|
2022-09-24 15:12:23 +00:00
|
|
|
)
|
2022-10-18 18:26:47 +00:00
|
|
|
AND NOT (
|
|
|
|
type = 'regular'
|
|
|
|
AND filename = '.placeholder'
|
2023-01-09 14:34:20 +00:00
|
|
|
) -- A curious addition seen on NixOS and Fedora machines
|
2022-09-29 19:42:27 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
file.path = '/.cache/'
|
2022-09-29 19:42:27 +00:00
|
|
|
AND file.uid = 0
|
|
|
|
AND file.gid = 0
|
2023-01-09 14:34:20 +00:00
|
|
|
AND file.mode IN ('0755', '0700')
|
|
|
|
AND file.size < 4
|
2022-09-29 19:42:27 +00:00
|
|
|
)
|
2023-02-14 13:33:05 +00:00
|
|
|
-- Ecamm Live
|
2023-02-08 20:12:10 +00:00
|
|
|
AND NOT (
|
2023-02-14 13:33:05 +00:00
|
|
|
file.path LIKE "/tmp/.elive%"
|
|
|
|
AND file.size < 7
|
2023-02-08 20:12:10 +00:00
|
|
|
)
|
2022-09-29 19:42:27 +00:00
|
|
|
AND NOT (
|
2022-10-13 18:59:32 +00:00
|
|
|
file.path = '/.config/'
|
2022-09-29 19:42:27 +00:00
|
|
|
AND file.uid = 0
|
|
|
|
AND file.gid = 0
|
2022-10-13 18:59:32 +00:00
|
|
|
AND file.mode IN ('0755', '0700')
|
2022-09-29 19:42:27 +00:00
|
|
|
AND file.size = 4
|
2022-10-19 20:19:53 +00:00
|
|
|
)
|
2023-01-09 14:04:38 +00:00
|
|
|
AND NOT (
|
|
|
|
file.path LIKE '/tmp/.java_pid%'
|
|
|
|
AND file.type = 'socket'
|
|
|
|
AND file.size = 0
|
|
|
|
)
|
2023-01-19 16:42:44 +00:00
|
|
|
AND NOT (
|
|
|
|
file.path = '/var/root/.oracle_jre_usage/'
|
|
|
|
AND file.size = 96
|
2023-01-20 14:24:24 +00:00
|
|
|
)
|